public override void OnInspectorGUI()
        {
            serializedObject.Update();

            CharacterDataKey dataKey = (CharacterDataKey)target;

            Rect defRect  = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
            Rect typeRect = new Rect(defRect.x, defRect.y, 75, defRect.height);

            EditorGUI.LabelField(typeRect, dataKey.GetKeyTypeName(), EditorStyles.boldLabel);
            Rect nameRect = new Rect(defRect.x + 75, defRect.y, defRect.width - 75, defRect.height);

            using (new EditorGUI.DisabledScope(true))
            {
                EditorGUI.ObjectField(nameRect, dataKey, typeof(CharacterDataKey), false);
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Description");

            SerializedProperty descriptionProp = serializedObject.FindProperty("m_description");
            Rect     descriptionRect           = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * 3);
            GUIStyle textAreaStyle             = new GUIStyle(EditorStyles.textArea);

            textAreaStyle.wordWrap      = true;
            descriptionProp.stringValue = EditorGUI.TextArea(descriptionRect, descriptionProp.stringValue, textAreaStyle);

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            SerializedProperty dataKeyProp = property.FindPropertyRelative("m_dataKey");
            CharacterDataKey   dataKey     = (CharacterDataKey)dataKeyProp.objectReferenceValue;
            float dataKeyPropHeight        = EditorGUI.GetPropertyHeight(dataKeyProp);
            Rect  dataKeyRect = new Rect(position.x, position.y, position.width, dataKeyPropHeight);

            EditorGUI.PropertyField(dataKeyRect, dataKeyProp, GUIContent.none);

            if (dataKey != null)
            {
                switch (dataKey.GetKeyType())
                {
                case DataKeyType.INTEGER:
                {
                    SerializedProperty intEventProp = property.FindPropertyRelative("m_OnIntEvents");
                    float intEventPropHeight        = EditorGUI.GetPropertyHeight(intEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, intEventPropHeight);
                    EditorGUI.PropertyField(eventRect, intEventProp);
                    break;
                }

                case DataKeyType.FLOAT:
                {
                    SerializedProperty floatEventProp = property.FindPropertyRelative("m_OnFloatEvents");
                    float floatEventPropHeight        = EditorGUI.GetPropertyHeight(floatEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, floatEventPropHeight);
                    EditorGUI.PropertyField(eventRect, floatEventProp);
                    break;
                }

                case DataKeyType.BOOLEAN:
                {
                    SerializedProperty boolEventProp = property.FindPropertyRelative("m_OnBoolEvents");
                    float boolEventPropHeight        = EditorGUI.GetPropertyHeight(boolEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, boolEventPropHeight);
                    EditorGUI.PropertyField(eventRect, boolEventProp);
                    break;
                }

                case DataKeyType.STRING:
                {
                    SerializedProperty stringEventProp = property.FindPropertyRelative("m_OnStringEvents");
                    float stringEventPropHeight        = EditorGUI.GetPropertyHeight(stringEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, stringEventPropHeight);
                    EditorGUI.PropertyField(eventRect, stringEventProp);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }

            EditorGUI.EndProperty();
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            SerializedProperty dataKeyProp = property.FindPropertyRelative("m_dataKey");
            CharacterDataKey   dataKey     = (CharacterDataKey)dataKeyProp.objectReferenceValue;

            float height = EditorGUI.GetPropertyHeight(dataKeyProp);

            if (dataKey != null)
            {
                switch (dataKey.GetKeyType())
                {
                case DataKeyType.INTEGER:
                {
                    SerializedProperty intEventProp = property.FindPropertyRelative("m_OnIntEvents");
                    height += EditorGUI.GetPropertyHeight(intEventProp);
                    break;
                }

                case DataKeyType.FLOAT:
                {
                    SerializedProperty floatEventProp = property.FindPropertyRelative("m_OnFloatEvents");
                    height += EditorGUI.GetPropertyHeight(floatEventProp);
                    break;
                }

                case DataKeyType.BOOLEAN:
                {
                    SerializedProperty boolEventProp = property.FindPropertyRelative("m_OnBoolEvents");
                    height += EditorGUI.GetPropertyHeight(boolEventProp);
                    break;
                }

                case DataKeyType.STRING:
                {
                    SerializedProperty stringEventProp = property.FindPropertyRelative("m_OnStringEvents");
                    height += EditorGUI.GetPropertyHeight(stringEventProp);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }

            return(height);
        }
예제 #4
0
        void DispatchCharacterDataList(List <CharacterData> characterDataList)
        {
            foreach (CharacterData data in characterDataList)
            {
                CharacterDataKey dataKey = data.dataKey;
                if (m_characterDataKeyEventMap.ContainsKey(dataKey))
                {
                    CharacterDataKeyEvent e = m_characterDataKeyEventMap[dataKey];
                    switch (dataKey.GetKeyType())
                    {
                    case DataKeyType.INTEGER:
                    {
                        e.Dispatch(data.intValue);
                        break;
                    }

                    case DataKeyType.FLOAT:
                    {
                        e.Dispatch(data.floatValue);
                        break;
                    }

                    case DataKeyType.BOOLEAN:
                    {
                        e.Dispatch(data.boolValue);
                        break;
                    }

                    case DataKeyType.STRING:
                    {
                        e.Dispatch(data.stringValue);
                        break;
                    }

                    default:
                    {
                        break;
                    }
                    }
                }
            }
        }
예제 #5
0
        void DispatchDefaultCharacterDataList()
        {
            foreach (DefaultCharacterDataKeyEvent e in m_defaultCharacterDataKeyEventList)
            {
                CharacterDataKey dataKey = e.dataKey;
                switch (dataKey.GetKeyType())
                {
                case DataKeyType.INTEGER:
                {
                    e.Dispatch(e.defaultIntValue);
                    break;
                }

                case DataKeyType.FLOAT:
                {
                    e.Dispatch(e.defaultFloatValue);
                    break;
                }

                case DataKeyType.BOOLEAN:
                {
                    e.Dispatch(e.defaultBoolValue);
                    break;
                }

                case DataKeyType.STRING:
                {
                    e.Dispatch(e.defaultStringValue);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            int prevIndentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            Rect typeRect    = new Rect(position.x, position.y, 75, position.height);
            Rect dataKeyRect = new Rect(position.x + 75, position.y, 110, position.height);
            Rect valueRect   = new Rect(position.x + 190, position.y, position.width - 190, position.height);

            EditorGUI.BeginProperty(position, label, property);

            SerializedProperty dataKeyProp = property.FindPropertyRelative("m_dataKey");

            EditorGUI.PropertyField(dataKeyRect, dataKeyProp, GUIContent.none);

            CharacterDataKey dataKey = (CharacterDataKey)dataKeyProp.objectReferenceValue;

            if (dataKey == null)
            {
                if (GUI.Button(typeRect, "New", EditorStyles.miniButtonLeft))
                {
                    GenericMenu newKeyMenu = new GenericMenu();
                    newKeyMenu.AddItem(new GUIContent("String"), false, () => {
                        CharacterDataKeyString newStringKey = PromptToCreate <CharacterDataKeyString>("New String Key", "Name");
                        dataKeyProp.objectReferenceValue    = newStringKey;
                        property.serializedObject.ApplyModifiedProperties();
                    });
                    newKeyMenu.AddItem(new GUIContent("Integer"), false, () => {
                        CharacterDataKeyInteger newIntegerKey = PromptToCreate <CharacterDataKeyInteger>("New Integer Key", "Name");
                        dataKeyProp.objectReferenceValue      = newIntegerKey;
                        property.serializedObject.ApplyModifiedProperties();
                    });
                    newKeyMenu.AddItem(new GUIContent("Float"), false, () => {
                        CharacterDataKeyFloat newFloatKey = PromptToCreate <CharacterDataKeyFloat>("New Float Key", "Name");
                        dataKeyProp.objectReferenceValue  = newFloatKey;
                        property.serializedObject.ApplyModifiedProperties();
                    });
                    newKeyMenu.AddItem(new GUIContent("Boolean"), false, () => {
                        CharacterDataKeyBoolean newBooleanKey = PromptToCreate <CharacterDataKeyBoolean>("New Boolean Key", "Name");
                        dataKeyProp.objectReferenceValue      = newBooleanKey;
                        property.serializedObject.ApplyModifiedProperties();
                    });
                    newKeyMenu.DropDown(new Rect(typeRect.x, typeRect.y, 0, typeRect.height));
                }
                EditorGUI.BeginDisabledGroup(true);
                EditorGUI.TextField(valueRect, "");
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                switch (dataKey.GetKeyType())
                {
                case DataKeyType.INTEGER:
                {
                    EditorGUI.LabelField(typeRect, "Integer", EditorStyles.boldLabel);
                    SerializedProperty intValueProp = property.FindPropertyRelative("m_intValue");
                    EditorGUI.PropertyField(valueRect, intValueProp, GUIContent.none);
                    break;
                }

                case DataKeyType.FLOAT:
                {
                    EditorGUI.LabelField(typeRect, "Float", EditorStyles.boldLabel);
                    SerializedProperty floatValueProp = property.FindPropertyRelative("m_floatValue");
                    EditorGUI.PropertyField(valueRect, floatValueProp, GUIContent.none);
                    break;
                }

                case DataKeyType.BOOLEAN:
                {
                    EditorGUI.LabelField(typeRect, "Boolean", EditorStyles.boldLabel);
                    SerializedProperty boolValueProp = property.FindPropertyRelative("m_boolValue");
                    EditorGUI.PropertyField(valueRect, boolValueProp, GUIContent.none);
                    break;
                }

                case DataKeyType.STRING:
                {
                    EditorGUI.LabelField(typeRect, "String", EditorStyles.boldLabel);
                    SerializedProperty stringValueProp = property.FindPropertyRelative("m_stringValue");
                    EditorGUI.PropertyField(valueRect, stringValueProp, GUIContent.none);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
            EditorGUI.EndProperty();
            EditorGUI.indentLevel = prevIndentLevel;
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            SerializedProperty dataKeyProp = property.FindPropertyRelative("m_dataKey");
            CharacterDataKey   dataKey     = (CharacterDataKey)dataKeyProp.objectReferenceValue;
            float dataKeyPropHeight        = EditorGUI.GetPropertyHeight(dataKeyProp);
            Rect  dataKeyRect = new Rect(position.x, position.y, position.width / 2 - 20, dataKeyPropHeight);

            EditorGUI.PropertyField(dataKeyRect, dataKeyProp, GUIContent.none);

            Rect equalSignRect = new Rect(position.xMax / 2, position.y, 20, dataKeyPropHeight);

            EditorGUI.LabelField(equalSignRect, "=");

            if (dataKey != null)
            {
                switch (dataKey.GetKeyType())
                {
                case DataKeyType.INTEGER:
                {
                    Rect defaultValueRect = new Rect(position.xMax / 2 + 20, position.y, position.xMax / 2 - 20, dataKeyPropHeight);
                    SerializedProperty defaultIntValueProp = property.FindPropertyRelative("m_defaultIntValue");
                    EditorGUI.PropertyField(defaultValueRect, defaultIntValueProp, GUIContent.none);
                    SerializedProperty intEventProp = property.FindPropertyRelative("m_OnIntEvents");
                    float intEventPropHeight        = EditorGUI.GetPropertyHeight(intEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, intEventPropHeight);
                    EditorGUI.PropertyField(eventRect, intEventProp);
                    break;
                }

                case DataKeyType.FLOAT:
                {
                    Rect defaultValueRect = new Rect(position.xMax / 2 + 20, position.y, position.xMax / 2 - 20, dataKeyPropHeight);
                    SerializedProperty defaultFloatValueProp = property.FindPropertyRelative("m_defaultFloatValue");
                    EditorGUI.PropertyField(defaultValueRect, defaultFloatValueProp, GUIContent.none);
                    SerializedProperty floatEventProp = property.FindPropertyRelative("m_OnFloatEvents");
                    float floatEventPropHeight        = EditorGUI.GetPropertyHeight(floatEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, floatEventPropHeight);
                    EditorGUI.PropertyField(eventRect, floatEventProp);
                    break;
                }

                case DataKeyType.BOOLEAN:
                {
                    Rect defaultValueRect = new Rect(position.xMax / 2 + 20, position.y, dataKeyPropHeight, dataKeyPropHeight);
                    SerializedProperty defaultBoolValueProp = property.FindPropertyRelative("m_defaultBoolValue");
                    EditorGUI.PropertyField(defaultValueRect, defaultBoolValueProp, GUIContent.none);
                    SerializedProperty boolEventProp = property.FindPropertyRelative("m_OnBoolEvents");
                    float boolEventPropHeight        = EditorGUI.GetPropertyHeight(boolEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, boolEventPropHeight);
                    EditorGUI.PropertyField(eventRect, boolEventProp);
                    break;
                }

                case DataKeyType.STRING:
                {
                    Rect defaultValueRect = new Rect(position.xMax / 2 + 20, position.y, position.xMax / 2 - 20, dataKeyPropHeight);
                    SerializedProperty defaultStringValueProp = property.FindPropertyRelative("m_defaultStringValue");
                    EditorGUI.PropertyField(defaultValueRect, defaultStringValueProp, GUIContent.none);
                    SerializedProperty stringEventProp = property.FindPropertyRelative("m_OnStringEvents");
                    float stringEventPropHeight        = EditorGUI.GetPropertyHeight(stringEventProp);
                    Rect  eventRect = new Rect(position.x, position.y + dataKeyPropHeight + 2, position.width, stringEventPropHeight);
                    EditorGUI.PropertyField(eventRect, stringEventProp);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
            else
            {
                using (new EditorGUI.DisabledScope(true))
                {
                    Rect defaultValueRect = new Rect(position.xMax / 2 + 20, position.y, position.xMax / 2 - 20, dataKeyPropHeight);
                    EditorGUI.TextField(defaultValueRect, "");
                }
            }

            EditorGUI.EndProperty();
        }