| | |
| | | // [ Date ]: Tuesday, August 15, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEditor; |
| | | using UnityEngine; |
| | | |
| | | |
| | | [CustomEditor(typeof(ToggleEx), true), CanEditMultipleObjects] |
| | | public class ToggleExEditor : UnityEditor.UI.ToggleEditor |
| | | { |
| | | SerializedProperty clickAudioProp; |
| | | SerializedProperty activatesProp; |
| | | SerializedProperty deactivatesProp; |
| | | |
| | | protected override void OnEnable() |
| | | { |
| | | base.OnEnable(); |
| | | clickAudioProp = serializedObject.FindProperty("m_Audio"); |
| | | activatesProp = serializedObject.FindProperty("activates"); |
| | | deactivatesProp = serializedObject.FindProperty("deactivates"); |
| | | } |
| | | |
| | | public override void OnInspectorGUI() |
| | | { |
| | | base.OnInspectorGUI(); |
| | | |
| | | serializedObject.Update(); |
| | | |
| | | EditorGUILayout.Space(); |
| | | ToggleEx toggle = target as ToggleEx; |
| | | toggle.clickAudio = EditorGUILayout.IntField("音效", toggle.clickAudio); |
| | | EditorGUILayout.PropertyField(clickAudioProp, new GUIContent("音效")); |
| | | |
| | | EditorGUILayout.Space(); |
| | | EditorGUILayout.PropertyField(activatesProp, new GUIContent("激活对象")); |
| | | EditorGUILayout.PropertyField(deactivatesProp, new GUIContent("禁用对象")); |
| | | |
| | | serializedObject.ApplyModifiedProperties(); |
| | | } |
| | | |
| | | } |