From c7e2d8f773baa3955f17402b842eb43329c5f3a0 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Apr 2021 21:06:10 +0800 Subject: +UI_Effect --- .../Test/UIEffect/Program/Editor/UIShadowEditor.cs | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Assets/Test/UIEffect/Program/Editor/UIShadowEditor.cs (limited to 'Assets/Test/UIEffect/Program/Editor/UIShadowEditor.cs') diff --git a/Assets/Test/UIEffect/Program/Editor/UIShadowEditor.cs b/Assets/Test/UIEffect/Program/Editor/UIShadowEditor.cs new file mode 100644 index 0000000..64f01d6 --- /dev/null +++ b/Assets/Test/UIEffect/Program/Editor/UIShadowEditor.cs @@ -0,0 +1,62 @@ +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace Coffee.UIEffects.Editors +{ + /// + /// UIShadow editor. + /// + [CustomEditor(typeof(UIShadow))] + [CanEditMultipleObjects] + public class UIShadowEditor : Editor + { + UIEffect uiEffect; + SerializedProperty _spStyle; + SerializedProperty _spEffectDistance; + SerializedProperty _spEffectColor; + SerializedProperty _spUseGraphicAlpha; + SerializedProperty _spBlurFactor; + + void OnEnable() + { + uiEffect = (target as UIShadow).GetComponent(); + _spStyle = serializedObject.FindProperty("m_Style"); + _spEffectDistance = serializedObject.FindProperty("m_EffectDistance"); + _spEffectColor = serializedObject.FindProperty("m_EffectColor"); + _spUseGraphicAlpha = serializedObject.FindProperty("m_UseGraphicAlpha"); + _spBlurFactor = serializedObject.FindProperty("m_BlurFactor"); + } + + /// + /// Implement this function to make a custom inspector. + /// + public override void OnInspectorGUI() + { + serializedObject.Update(); + + //================ + // Shadow setting. + //================ + EditorGUILayout.PropertyField(_spStyle); + + // When shadow is enable, show parameters. + if (_spStyle.intValue != (int) ShadowStyle.None) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(_spEffectDistance); + EditorGUILayout.PropertyField(_spEffectColor); + EditorGUILayout.PropertyField(_spUseGraphicAlpha); + + if (uiEffect && uiEffect.blurMode != BlurMode.None) + { + EditorGUILayout.PropertyField(_spBlurFactor); + } + + EditorGUI.indentLevel--; + } + + serializedObject.ApplyModifiedProperties(); + } + } +} -- cgit v1.1-26-g67d0