public void SerializeUnityObject(Object ob) { if (ob == null) { this.writer.Write(2147483647); return; } int instanceID = ob.GetInstanceID(); string name = ob.name; string assemblyQualifiedName = ob.GetType().get_AssemblyQualifiedName(); string text = string.Empty; Component component = ob as Component; GameObject gameObject = ob as GameObject; if (component != null || gameObject != null) { if (component != null && gameObject == null) { gameObject = component.gameObject; } UnityReferenceHelper unityReferenceHelper = gameObject.GetComponent <UnityReferenceHelper>(); if (unityReferenceHelper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + ob.name + "'"); unityReferenceHelper = gameObject.AddComponent <UnityReferenceHelper>(); } unityReferenceHelper.Reset(); text = unityReferenceHelper.GetGUID(); } this.writer.Write(instanceID); this.writer.Write(name); this.writer.Write(assemblyQualifiedName); this.writer.Write(text); }
private void SerializeUnityObject(UnityEngine.Object obj) { if (obj == null) { this.Serialize(null); return; } this.output.Append("{"); this.QuotedField("Name", obj.name); this.output.Append(", "); this.QuotedField("Type", obj.GetType().FullName); Component component = obj as Component; GameObject gameObject = obj as GameObject; if (component != null || gameObject != null) { if (component != null && gameObject == null) { gameObject = component.gameObject; } UnityReferenceHelper unityReferenceHelper = gameObject.GetComponent <UnityReferenceHelper>(); if (unityReferenceHelper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + obj.name + "'"); unityReferenceHelper = gameObject.AddComponent <UnityReferenceHelper>(); } unityReferenceHelper.Reset(); this.output.Append(", "); this.QuotedField("GUID", unityReferenceHelper.GetGUID().ToString()); } this.output.Append("}"); }
public void SerializeUnityObject(UnityEngine.Object ob) { if (ob == null) { this.writer.Write(0x7fffffff); } else { int instanceID = ob.GetInstanceID(); string name = ob.name; string assemblyQualifiedName = ob.GetType().AssemblyQualifiedName; string gUID = string.Empty; Component component = ob as Component; GameObject gameObject = ob as GameObject; if ((component != null) || (gameObject != null)) { if ((component != null) && (gameObject == null)) { gameObject = component.gameObject; } UnityReferenceHelper helper = gameObject.GetComponent <UnityReferenceHelper>(); if (helper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + ob.name + "'"); helper = gameObject.AddComponent <UnityReferenceHelper>(); } helper.Reset(); gUID = helper.GetGUID(); } this.writer.Write(instanceID); this.writer.Write(name); this.writer.Write(assemblyQualifiedName); this.writer.Write(gUID); } }
public override Dictionary <string, object> WriteJson(Type type, object value) { Object @object = (Object)value; Dictionary <string, object> dictionary = new Dictionary <string, object>(); if (value == null) { dictionary.Add("Name", null); return(dictionary); } dictionary.Add("Name", @object.name); dictionary.Add("Type", @object.GetType().AssemblyQualifiedName); Component component = value as Component; GameObject gameObject = value as GameObject; if (component != null || gameObject != null) { if (component != null && gameObject == null) { gameObject = component.gameObject; } UnityReferenceHelper unityReferenceHelper = gameObject.GetComponent <UnityReferenceHelper>(); if (unityReferenceHelper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + @object.name + "'"); unityReferenceHelper = gameObject.AddComponent <UnityReferenceHelper>(); } unityReferenceHelper.Reset(); dictionary.Add("GUID", unityReferenceHelper.GetGUID()); } return(dictionary); }
public override Dictionary <string, object> WriteJson(System.Type type, object value) { UnityEngine.Object obj2 = (UnityEngine.Object)value; Dictionary <string, object> dictionary = new Dictionary <string, object>(); if (value == null) { dictionary.Add("Name", null); return(dictionary); } dictionary.Add("Name", obj2.name); dictionary.Add("Type", obj2.GetType().AssemblyQualifiedName); Component component = value as Component; GameObject gameObject = value as GameObject; if ((component != null) || (gameObject != null)) { if ((component != null) && (gameObject == null)) { gameObject = component.gameObject; } UnityReferenceHelper helper = gameObject.GetComponent <UnityReferenceHelper>(); if (helper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + obj2.name + "'"); helper = gameObject.AddComponent <UnityReferenceHelper>(); } helper.Reset(); dictionary.Add("GUID", helper.GetGUID()); } return(dictionary); }
public void SerializeUnityObject(UnityEngine.Object ob) { if (ob == null) { writer.Write(int.MaxValue); return; } int inst = ob.GetInstanceID(); string name = ob.name; string type = ob.GetType().AssemblyQualifiedName; string guid = ""; //Write scene path if the object is a Component or GameObject Component component = ob as Component; GameObject go = ob as GameObject; if (component != null || go != null) { if (component != null && go == null) { go = component.gameObject; } UnityReferenceHelper helper = go.GetComponent <UnityReferenceHelper>(); if (helper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + ob.name + "'"); helper = go.AddComponent <UnityReferenceHelper>(); } //Make sure it has a unique GUID helper.Reset(); guid = helper.GetGUID(); } writer.Write(inst); writer.Write(name); writer.Write(type); writer.Write(guid); }
public override Dictionary <string, object> WriteJson(Type type, object value) { UnityEngine.Object obj = (UnityEngine.Object)value; Dictionary <string, object> dict = new Dictionary <string, object>(); if (value == null) { dict.Add("Name", null); return(dict); } dict.Add("Name", obj.name); dict.Add("Type", obj.GetType().AssemblyQualifiedName); //Write scene path if the object is a Component or GameObject Component component = value as Component; GameObject go = value as GameObject; if (component != null || go != null) { if (component != null && go == null) { go = component.gameObject; } UnityReferenceHelper helper = go.GetComponent <UnityReferenceHelper>(); if (helper == null) { Debug.Log("Adding UnityReferenceHelper to Unity Reference '" + obj.name + "'"); helper = go.AddComponent <UnityReferenceHelper>(); } //Make sure it has a unique GUID helper.Reset(); dict.Add("GUID", helper.GetGUID()); } return(dict); }