public T Get <T>(BuildTargetGroup g)
        {
            if (m_className == null)
            {
                return(default(T));
            }
            int i = m_values.FindIndex(v => v.targetGroup == g);

            if (i >= 0)
            {
                Type t = Type.GetType(m_className);

                if (t == null)
                {
                    LogUtility.Logger.LogFormat(LogType.Warning, "Could not retrieve Type info from classname:{0}", m_className);
                    return(default(T));
                }
                Assertions.Assert.IsTrue(typeof(T).IsAssignableFrom(t));

                if (m_values [i].instance == null)
                {
                    m_values [i].instance = JsonUtility.FromJson(CustomScriptUtility.DecodeString(m_values [i].value), t);
                }

                return((T)m_values [i].instance);
            }
            else
            {
                return(GetDefaultValue <T>());
            }
        }
Example #2
0
            public void Restore(GameObject o)
            {
                UnityEngine.Assertions.Assert.IsNotNull(m_typeInfo);

                if (m_componentType == null)
                {
                    m_componentType = Type.GetType(m_typeInfo);
                }
                UnityEngine.Assertions.Assert.IsNotNull(m_componentType);

                m_component = o.GetComponent(m_componentType);
                if (m_component == null)
                {
                    m_component = o.AddComponent(m_componentType);
                    if (m_componentData != null)
                    {
                        EditorJsonUtility.FromJsonOverwrite(CustomScriptUtility.DecodeString(m_componentData), m_component);
                    }
                }

                if (m_componentEditor == null)
                {
                    m_componentEditor = Editor.CreateEditor(m_component);
                }
            }
        private void Deserialize()
        {
            m_gameObject           = new GameObject();
            m_gameObject.hideFlags = HideFlags.HideInHierarchy | HideFlags.DontSave;
            m_gameObject.name      = (string.IsNullOrEmpty(m_newGameObjectName)) ? "New GameObject" : m_newGameObjectName;

            if (!string.IsNullOrEmpty(m_instanceData))
            {
                var decoded = CustomScriptUtility.DecodeString(m_instanceData);
                EditorJsonUtility.FromJsonOverwrite(decoded, m_gameObject);
            }

            if (m_attachedComponents == null)
            {
                m_attachedComponents = new List <ComponentInfo> ();
            }
            SortComponents();

            foreach (var info in m_attachedComponents)
            {
                info.Restore(m_gameObject);
            }

            if (m_gameObjectEditor == null)
            {
                m_gameObjectEditor = Editor.CreateEditor(m_gameObjectEditor);
            }
        }
            public T Get <T> ()
            {
                if (instance == null)
                {
                    instance = JsonUtility.FromJson(CustomScriptUtility.DecodeString(value), typeof(T));
                }

                return((T)instance);
            }
Example #5
0
		private T Deserialize() {
			Type instanceType = null;
			if(!string.IsNullOrEmpty(m_className)) {
				instanceType = Type.GetType(m_className);
			}

			if(!string.IsNullOrEmpty(m_instanceData) && instanceType != null) {
				string data = CustomScriptUtility.DecodeString(m_instanceData);
				return (T)JsonUtility.FromJson(data, instanceType);
			}

			return default(T);
		}
Example #6
0
        private GameObject Deserialize()
        {
            var obj = new GameObject();

            obj.hideFlags = HideFlags.HideInHierarchy | HideFlags.DontSave;
            obj.name      = "Attaching Component";

            if (!string.IsNullOrEmpty(m_instanceData))
            {
                var decoded = CustomScriptUtility.DecodeString(m_instanceData);
                EditorJsonUtility.FromJsonOverwrite(decoded, obj);
            }

            foreach (var info in m_attachedComponents)
            {
                info.Restore(obj);
            }

            return(obj);
        }