Skip to content

Commit b43ce82

Browse files
committed
Add CustomSelectableEditor in the examples
1 parent b87f4b3 commit b43ce82

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed

Assets/Examples/Editor/UI.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using Toolbox.Editor;
2+
using Toolbox.Editor.Drawers;
3+
using UnityEditor;
4+
using UnityEditor.UI;
5+
6+
[CustomEditor(typeof(CustomSelectable))]
7+
public class CustomSelectableEditor : SelectableEditor, IToolboxEditor
8+
{
9+
private static readonly string[] selectableProperties = new string[]
10+
{
11+
"m_Script",
12+
"m_Interactable",
13+
"m_TargetGraphic",
14+
"m_Transition",
15+
"m_Colors",
16+
"m_SpriteState",
17+
"m_AnimationTriggers",
18+
"m_Navigation"
19+
};
20+
21+
protected override void OnEnable()
22+
{
23+
base.OnEnable();
24+
foreach (var property in selectableProperties)
25+
{
26+
IgnoreProperty(property);
27+
}
28+
}
29+
30+
public sealed override void OnInspectorGUI()
31+
{
32+
base.OnInspectorGUI();
33+
ToolboxEditorHandler.HandleToolboxEditor(this);
34+
}
35+
36+
public void DrawCustomInspector()
37+
{
38+
Drawer.DrawEditor(serializedObject);
39+
}
40+
41+
public void IgnoreProperty(SerializedProperty property)
42+
{
43+
Drawer.IgnoreProperty(property);
44+
}
45+
46+
public void IgnoreProperty(string propertyPath)
47+
{
48+
Drawer.IgnoreProperty(propertyPath);
49+
}
50+
51+
Editor IToolboxEditor.ContextEditor => this;
52+
public IToolboxEditorDrawer Drawer { get; } = new ToolboxEditorDrawer();
53+
}

Assets/Examples/Editor/UI/CustomSelectableEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Examples/Scripts/UI.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
4+
public class CustomSelectable : Selectable
5+
{
6+
private interface ICustomLogic
7+
{ }
8+
9+
[SerializeReference]
10+
private ICustomLogic customLogic;
11+
}

Assets/Examples/Scripts/UI/CustomSelectable.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)