예제 #1
0
        public SerializedInstance(T obj)
        {
            UnityEngine.Assertions.Assert.IsNotNull(obj);

            m_className    = obj.GetType().AssemblyQualifiedName;
            m_instanceData = CustomScriptUtility.EncodeString(JsonUtility.ToJson(obj));
        }
        public void Set(BuildTargetGroup g, object value)
        {
            if (value == null)
            {
                Remove(g);
                return;
            }

            bool defaultNeedsUpdate = false;

            if (m_className != value.GetType().AssemblyQualifiedName)
            {
                m_values.Clear();
                m_className        = value.GetType().AssemblyQualifiedName;
                defaultNeedsUpdate = true;
            }

            int i    = m_values.FindIndex(v => v.targetGroup == g);
            var json = CustomScriptUtility.EncodeString(JsonUtility.ToJson(value));

            if (i >= 0)
            {
                m_values[i].value = json;
            }
            else
            {
                m_values.Add(new Entry(g, json));
                if (defaultNeedsUpdate && g != BuildTargetUtility.DefaultTarget)
                {
                    m_values.Add(new Entry(BuildTargetUtility.DefaultTarget, json));
                }
            }
        }
예제 #3
0
 public void Save()
 {
     if (m_object != null)
     {
         m_className    = m_object.GetType().AssemblyQualifiedName;
         m_instanceData = CustomScriptUtility.EncodeString(JsonUtility.ToJson(m_object));
     }
 }
 public SerializableMultiTargetInstance(string assemblyQualifiedName, SerializableMultiTargetString instanceData)
 {
     m_className = assemblyQualifiedName;
     m_values    = new List <Entry>(instanceData.Values.Count);
     foreach (var v in instanceData.Values)
     {
         m_values.Add(new Entry(v.targetGroup, CustomScriptUtility.EncodeString(v.value)));
     }
 }