diff --git a/Runtime/JSON/Editor/JSONChecker.cs b/Runtime/JSON/Editor/JSONChecker.cs index e334c1a..e44fff3 100644 --- a/Runtime/JSON/Editor/JSONChecker.cs +++ b/Runtime/JSON/Editor/JSONChecker.cs @@ -81,7 +81,7 @@ void OnGUI() #if UNITY_2017_1_OR_NEWER var test = new UnityWebRequest(URL); test.SendWebRequest(); - while (!test.isDone && !test.isNetworkError) ; + while (!test.isDone && !(test.result == UnityWebRequest.Result.ConnectionError)) ; #else var test = new WWW(URL); while (!test.isDone) ; diff --git a/Runtime/OSCQuery.cs b/Runtime/OSCQuery.cs index 25f8d75..9ac6001 100644 --- a/Runtime/OSCQuery.cs +++ b/Runtime/OSCQuery.cs @@ -55,8 +55,8 @@ public enum InfoType { Property, Field, Method, VFX, Material }; public FieldInfo fieldInfo; public PropertyInfo propInfo; public MethodInfo methodInfo; - - public struct GenericInfo + + public struct GenericInfo { public GenericInfo(Type type, string name) { @@ -350,7 +350,7 @@ JSONObject getObjectData(GameObject go, string baseAddress = "") { RangeAttribute rangeAttribute = info.GetCustomAttribute(); - Debug.Log(go.name+" > Info field type : " +info.FieldType.ToString() +" /" +compType); + //Debug.Log(go.name+" > Info field type : " +info.FieldType.ToString() +" /" +compType); JSONObject io = getPropObject(info.FieldType, info.GetValue(comp), rangeAttribute, info.Name == "mainColor"); @@ -395,7 +395,7 @@ JSONObject getObjectData(GameObject go, string baseAddress = "") } } - // Debug.Log("Comp type : " + compType); + // Debug.Log("Comp type : " + compType); if (compType == "VisualEffect") { @@ -406,8 +406,8 @@ JSONObject getObjectData(GameObject go, string baseAddress = "") { //Debug.Log("Here " + p.name+" / "+p.type.ToString()); JSONObject io = getPropObject(p.type, getVFXPropValue(vfx, p.type, p.name)); - - if(io != null) + + if (io != null) { string sName = SanitizeName(p.name); string fullPath = compAddress + "/" + sName; @@ -563,21 +563,21 @@ JSONObject getPropObject(Type type, object value, RangeAttribute range = null, b } break; - /* - case "UnityEngine.Material": + /* + case "UnityEngine.Material": + { + Material m = (Material)value; + if(m != null) { - Material m = (Material)value; - if(m != null) + int numProps = m.shader.GetPropertyCount(); + for(int i=0;i args += arg.ToString() + ", "); - Debug.Log("info received : " + msg.Address); + //Debug.Log("info received : " + msg.Address); if (compInfoMap.ContainsKey(msg.Address)) { CompInfo info = compInfoMap[msg.Address]; @@ -649,11 +649,11 @@ void ProcessIncomingMessages() if (info == null) { - Debug.LogWarning("Address not found : " + msg.Address); + //Debug.LogWarning("Address not found : " + msg.Address); continue; } - + if (info.infoType == CompInfo.InfoType.Method) { int numParams = info.methodInfo.GetParameters().Length; @@ -661,7 +661,6 @@ void ProcessIncomingMessages() continue; } - Debug.Log(info.genericInfo + "/" + info.type); string typeString = info.type.ToString(); switch (typeString) @@ -687,27 +686,27 @@ void ProcessIncomingMessages() case "System.Double": case "System.Single": - data = (float)msg.Data[0]; + data = getFloatArg(msg.Data[0]); break; case "UnityEngine.Vector2": - data = new Vector2((float)msg.Data[0], (float)msg.Data[1]); + data = new Vector2(getFloatArg(msg.Data[0]), getFloatArg(msg.Data[0])); break; case "UnityEngine.Vector3": - data = new Vector3((float)msg.Data[0], (float)msg.Data[1], (float)msg.Data[2]); + data = new Vector3(getFloatArg(msg.Data[0]), getFloatArg(msg.Data[1]), getFloatArg(msg.Data[2])); break; case "UnityEngine.Quaternion": - data = Quaternion.Euler(new Vector3((float)msg.Data[0], (float)msg.Data[1], (float)msg.Data[2])); + data = Quaternion.Euler(new Vector3(getFloatArg(msg.Data[0]), getFloatArg(msg.Data[1]), getFloatArg(msg.Data[2]))); break; case "UnityEngine.Color": case "UnityEngine.Vector4": { if (msg.Data.Count == 1) data = (Color)msg.Data[0]; - else if (msg.Data.Count >= 3) data = new Color((float)msg.Data[0], (float)msg.Data[1], (float)msg.Data[2], msg.Data.Count > 3 ? (float)msg.Data[2] : 1.0f); + else if (msg.Data.Count >= 3) data = new Color(getFloatArg(msg.Data[0]), getFloatArg(msg.Data[1]), getFloatArg(msg.Data[2]), msg.Data.Count > 3 ? getFloatArg(msg.Data[2] ): 1.0f); } break; @@ -724,7 +723,7 @@ void ProcessIncomingMessages() if (field.Name.Equals("value__")) continue; if (field.Name == msg.Data[0].ToString()) { - Debug.Log("Found enum " + field.Name + " > " + field.GetRawConstantValue()); + //Debug.Log("Found enum " + field.Name + " > " + field.GetRawConstantValue()); data = field.GetRawConstantValue(); } } @@ -753,11 +752,11 @@ void ProcessIncomingMessages() break; case CompInfo.InfoType.Material: - /* { - int dotIndex = info.comp.GetType().ToString().LastIndexOf("."); - string compType = info.comp.GetType().ToString().Substring(Mathf.Max(dotIndex + 1, 0)); - setMaterialPropValue((info.comp as VisualEffect), info.genericInfo.type, info.genericInfo.name, data); - }*/ + /* { + int dotIndex = info.comp.GetType().ToString().LastIndexOf("."); + string compType = info.comp.GetType().ToString().Substring(Mathf.Max(dotIndex + 1, 0)); + setMaterialPropValue((info.comp as VisualEffect), info.genericInfo.type, info.genericInfo.name, data); + }*/ break; } } @@ -923,20 +922,20 @@ void setVFXPropValue(VisualEffect vfx, Type type, string id, object value) case "System.UInt16": case "System.Byte": case "System.SByte": - vfx.SetInt(id,(int)value); + vfx.SetInt(id, (int)value); break; case "System.Double": case "System.Single": - vfx.SetFloat(id,(float)value); + vfx.SetFloat(id, (float)value); break; case "UnityEngine.Vector2": - vfx.SetVector2(id,(Vector2)value); + vfx.SetVector2(id, (Vector2)value); break; case "UnityEngine.Vector3": - vfx.SetVector3(id,(Vector3)value); + vfx.SetVector3(id, (Vector3)value); break; case "UnityEngine.Quaternion": @@ -949,5 +948,11 @@ void setVFXPropValue(VisualEffect vfx, Type type, string id, object value) } } + + // Helper + float getFloatArg(object data) + { + return (data is int)? (float)(int)data : (float)data; + } } } \ No newline at end of file