diff options
author | chai <chaifix@163.com> | 2021-04-07 21:33:14 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-04-07 21:33:14 +0800 |
commit | c47b92e92cf33ae8bf2f38929e137294397e4735 (patch) | |
tree | c67ae3419eaf15e84f1679186e107f598de33978 /Assets/Scripts/Editor/UIShadowEditor.cs |
Diffstat (limited to 'Assets/Scripts/Editor/UIShadowEditor.cs')
-rw-r--r-- | Assets/Scripts/Editor/UIShadowEditor.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Assets/Scripts/Editor/UIShadowEditor.cs b/Assets/Scripts/Editor/UIShadowEditor.cs new file mode 100644 index 0000000..64f01d6 --- /dev/null +++ b/Assets/Scripts/Editor/UIShadowEditor.cs @@ -0,0 +1,62 @@ +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace Coffee.UIEffects.Editors +{ + /// <summary> + /// UIShadow editor. + /// </summary> + [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<UIEffect>(); + _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"); + } + + /// <summary> + /// Implement this function to make a custom inspector. + /// </summary> + 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(); + } + } +} |