コード例 #1
0
        static public VariantData VariantDataUnity(VariantData variantData)
        {
            Type variantType = variantData.GetVariantType();

            UnityEngine.Object tmp = EditorGUILayout.ObjectField((UnityEngine.Object)variantData.rawData, variantType, true);
            return(new VariantData(tmp, variantType));
        }
コード例 #2
0
 public Variant(VariantData variantData, string typeName)
 {
     m_isArray   = false;
     m_data      = new VariantData(variantData);
     m_dataArray = null;
     m_typeName  = typeName;
 }
コード例 #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            VariantData b = (VariantData)obj;

            Type aType = GetVariantType();
            Type bType = b.GetVariantType();

            if (aType != bType)
            {
                return(false);
            }

            if (rawData == null)
            {
                return(b.rawData == null);
            }
            else if (b.rawData == null)
            {
                return(false);
            }

            return(rawData.Equals(b.rawData));
        }
コード例 #4
0
        public VariantData(VariantData other)
        {
            m_typeName = other.m_typeName;

            m_data          = other.m_data;
            m_unityObject   = other.m_unityObject;
            m_monoBehaviour = other.m_monoBehaviour;
            m_vector        = other.m_vector;
            m_quaternion    = other.m_quaternion;
            m_iEnumator     = other.m_iEnumator;
        }
コード例 #5
0
        static public VariantData VariantDataField(VariantData variantData)
        {
            Type variantType = variantData.GetVariantType();

            if (variantType == typeof(Trigger))
            {
                return(VariantDataTrigger(variantData));
            }
            else if (variantType == typeof(bool))
            {
                return(new VariantData(EditorGUILayout.Toggle(variantData.GetData <bool>()), typeof(bool)));
            }
            else if (variantType == typeof(int))
            {
                return(new VariantData(EditorGUILayout.IntField(variantData.GetData <int>()), typeof(int)));
            }
            else if (variantType == typeof(float))
            {
                return(new VariantData(EditorGUILayout.FloatField(variantData.GetData <float>()), typeof(float)));
            }
            else if (variantType == typeof(string))
            {
                return(new VariantData(EditorGUILayout.TextArea(variantData.GetData <string>()), typeof(string)));
            }
            else if (variantType == typeof(Vector2))
            {
                return(new VariantData(EditorGUILayout.Vector2Field("", variantData.GetData <Vector2>()), typeof(Vector2)));
            }
            else if (variantType == typeof(Vector3))
            {
                return(new VariantData(EditorGUILayout.Vector3Field("", variantData.GetData <Vector3>()), typeof(Vector3)));
            }
            else if (variantType == typeof(Vector4))
            {
                return(new VariantData(EditorGUILayout.Vector4Field("", variantData.GetData <Vector4>()), typeof(Vector4)));
            }
            else if (variantType == typeof(Quaternion))
            {
                Quaternion quaternion = variantData.GetData <Quaternion>();
                Vector4    buffer     = new Vector4(quaternion[0], quaternion[1], quaternion[2], quaternion[3]);
                buffer     = EditorGUILayout.Vector4Field("", buffer);
                quaternion = new Quaternion(buffer[0], buffer[1], buffer[2], buffer[3]);
                return(new VariantData(quaternion, typeof(Quaternion)));
            }
            else if (variantType.IsEnum)
            {
                return(new VariantData(EditorGUILayout.EnumPopup(variantData.GetData <Enum>()), variantType));
            }
            else
            {
                return(VariantDataUnity(variantData));
            }
        }
コード例 #6
0
 public Variant(Variant variant)
 {
     m_data = new VariantData(variant.m_data);
     if (variant.m_dataArray != null)
     {
         m_dataArray = new VariantData[variant.m_dataArray.Length];
         for (int i = 0; i < m_dataArray.Length; i++)
         {
             m_dataArray[i] = new VariantData(variant.m_dataArray[i]);
         }
     }
     m_isArray  = variant.m_isArray;
     m_typeName = variant.m_typeName;
 }
コード例 #7
0
        public void Setup(object data, Type type)
        {
            m_typeName = type.AssemblyQualifiedName;
            m_isArray  = type.IsArray;

            if (type.IsArray)
            {
                m_data         = new VariantData(data, type.GetElementType());
                m_dataArray    = new VariantData[1];
                m_dataArray[0] = new VariantData(m_data);
            }
            else
            {
                m_data = new VariantData(data, type);
            }
        }
コード例 #8
0
 public Variant(VariantData[] variantDataArray, VariantData defaultData, string typeName)
 {
     m_isArray = true;
     m_data    = new VariantData(defaultData);
     if (variantDataArray == null)
     {
         m_dataArray = null;
     }
     else
     {
         m_dataArray = new VariantData[variantDataArray.Length];
         for (int i = 0; i < m_dataArray.Length; i++)
         {
             m_dataArray[i] = new VariantData(variantDataArray[i]);
         }
     }
     m_typeName = typeName;
 }
コード例 #9
0
        static public VariantData VariantDataTrigger(VariantData variantData)
        {
            if ((TriggersManager.triggers == null) || (TriggersManager.triggers.Length == 0))
            {
                return(new VariantData(null, typeof(Trigger)));
            }

            string[] triggerNames = TriggersManager.GetTriggersNames();
            int      triggerIndex = 0;

            for (int i = 0; i < triggerNames.Length; i++)
            {
                Trigger tmp = variantData.GetData <Trigger>();
                if ((tmp != null) && (triggerNames[i] == tmp.name))
                {
                    triggerIndex = i;
                }
            }
            triggerIndex = EditorGUILayout.Popup(triggerIndex, triggerNames);
            return(new VariantData(TriggersManager.triggers[triggerIndex], typeof(Trigger)));
        }
コード例 #10
0
 static public VariantData VariantDataUnity <T>(VariantData variantData) where T : UnityEngine.Object
 {
     return(new VariantData((T)EditorGUILayout.ObjectField(variantData.GetData <T>(), typeof(T), true), typeof(T)));
 }