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));
                return((T)JsonUtility.FromJson(CustomScriptUtility.DecodeString(m_values[i].value), t));
            }
            else
            {
                return(GetDefaultValue <T>());
            }
        }
Ejemplo n.º 2
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));
        }