-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspector Changes, HGButton inspector
>Extended Inspector has been split into ScriptableObjectInspector and ComponentInspector. extended inspector still has the shorthand methods alongside having the main brains for getting and setting inspector settings >SOInspector is used for ScriptableObject related inspectors. its used to draw the toggle setting on the Editor Header >Component inspector is used for Component related inspectors, it's used to draw the toggle setting on the GUI itself.
- Loading branch information
Showing
13 changed files
with
686 additions
and
82 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
RoR2EditorKit/Assets/RoR2EditorKit/Editor/Core/Inspectors/ComponentInspector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using UnityEditor; | ||
|
||
namespace RoR2EditorKit.Core.Inspectors | ||
{ | ||
/// <summary> | ||
/// Inherit from this class to make your own Component Inspectors. | ||
/// </summary> | ||
public abstract class ComponentInspector : ExtendedInspector | ||
{ | ||
public override void OnInspectorGUI() | ||
{ | ||
EditorGUILayout.BeginVertical("box"); | ||
InspectorEnabled = CreateEnableInsepctorToggle(target.GetType().Name); | ||
EditorGUILayout.EndVertical(); | ||
base.OnInspectorGUI(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
RoR2EditorKit/Assets/RoR2EditorKit/Editor/Core/Inspectors/ComponentInspector.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
RoR2EditorKit/Assets/RoR2EditorKit/Editor/Core/Inspectors/ExtendedInspector.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
RoR2EditorKit/Assets/RoR2EditorKit/Editor/Core/Inspectors/ScriptableObjectInspector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEditor; | ||
|
||
namespace RoR2EditorKit.Core.Inspectors | ||
{ | ||
/// <summary> | ||
/// Inherit from this class to make your own Scriptable Object Inspectors. | ||
/// </summary> | ||
public abstract class ScriptableObjectInspector : ExtendedInspector | ||
{ | ||
private void OnEnable() | ||
{ | ||
InspectorEnabled = InspectorSetting.isEnabled; | ||
finishedDefaultHeaderGUI += DrawEnableToggle; | ||
} | ||
private void OnDisable() => finishedDefaultHeaderGUI -= DrawEnableToggle; | ||
|
||
private void DrawEnableToggle(Editor obj) | ||
{ | ||
if (obj is ScriptableObjectInspector soInspector) | ||
{ | ||
InspectorEnabled = CreateEnableInsepctorToggle(soInspector.target.GetType().Name); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
RoR2EditorKit/Assets/RoR2EditorKit/Editor/Core/Inspectors/ScriptableObjectInspector.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
RoR2EditorKit/Assets/RoR2EditorKit/Editor/ScriptsForRoR2/Inspectors/HGButtonCustomEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using RoR2.UI; | ||
using RoR2EditorKit.Core; | ||
using RoR2EditorKit.Core.Inspectors; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using UnityEditor.UI; | ||
using RoR2EditorKit.Settings; | ||
|
||
namespace RoR2EditorKit.RoR2.Inspectors | ||
{ | ||
[CustomEditor(typeof(HGButton))] | ||
public class HGButtonCustomEditor : ButtonEditor | ||
{ | ||
public EnabledAndDisabledInspectorsSettings.InspectorSetting InspectorSetting | ||
{ | ||
get | ||
{ | ||
if (_inspectorSetting == null) | ||
{ | ||
var setting = ExtendedInspector.Settings.InspectorSettings.GetOrCreateInspectorSetting(GetType()); | ||
_inspectorSetting = setting; | ||
} | ||
return _inspectorSetting; | ||
} | ||
set | ||
{ | ||
if (_inspectorSetting != value) | ||
{ | ||
var index = ExtendedInspector.Settings.InspectorSettings.EnabledInspectors.IndexOf(_inspectorSetting); | ||
ExtendedInspector.Settings.InspectorSettings.EnabledInspectors[index] = value; | ||
} | ||
_inspectorSetting = value; | ||
} | ||
} | ||
|
||
private EnabledAndDisabledInspectorsSettings.InspectorSetting _inspectorSetting; | ||
|
||
public bool InspectorEnabled { get => InspectorSetting.isEnabled; set => InspectorSetting.isEnabled = value; } | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
EditorGUILayout.BeginVertical("box"); | ||
InspectorEnabled = EditorGUILayout.ToggleLeft($"Enable {ObjectNames.NicifyVariableName(target.GetType().Name)} Inspector", InspectorEnabled); | ||
EditorGUILayout.EndVertical(); | ||
if (!InspectorEnabled) | ||
{ | ||
base.OnInspectorGUI(); | ||
} | ||
else | ||
{ | ||
DrawCustomInspector(); | ||
} | ||
} | ||
|
||
private void DrawCustomInspector() | ||
{ | ||
EditorGUILayout.BeginVertical("box"); | ||
Header("Button Settings"); | ||
base.OnInspectorGUI(); | ||
DrawField("onFindSelectableLeft"); | ||
DrawField("onFindSelectableRight"); | ||
DrawField("onSelect"); | ||
DrawField("onDeselect"); | ||
EditorGUILayout.EndVertical(); | ||
|
||
EditorGUILayout.BeginVertical("box"); | ||
Header("Control Options"); | ||
DrawField("allowAllEventSystems"); | ||
DrawField("submitOnPointerUp"); | ||
DrawField("disablePointerClick"); | ||
DrawField("disableGamepadClick"); | ||
EditorGUILayout.EndVertical(); | ||
|
||
EditorGUILayout.BeginVertical("box"); | ||
Header("Visual Properties"); | ||
DrawField("imageOnInteractable"); | ||
DrawField("showImageOnHover"); | ||
DrawField("imageOnHover"); | ||
DrawField("updateTextOnHover"); | ||
DrawField("hoverLanguageTextMeshController"); | ||
DrawField("hoverToken"); | ||
EditorGUILayout.EndVertical(); | ||
|
||
EditorGUILayout.BeginVertical("box"); | ||
Header("Misc Options"); | ||
DrawField("requiredTopLayer"); | ||
DrawField("defaultFallbackButton"); | ||
DrawField("uiClickSoundOverride"); | ||
EditorGUILayout.EndVertical(); | ||
} | ||
|
||
private void Header(string label) => EditorGUILayout.LabelField(new GUIContent(label), EditorStyles.boldLabel); | ||
private void Header(string label, string tooltip) => EditorGUILayout.LabelField(new GUIContent(label, tooltip), EditorStyles.boldLabel); | ||
private void DrawField(SerializedProperty prop) => EditorGUILayout.PropertyField(prop, true); | ||
private void DrawField(string prop) => EditorGUILayout.PropertyField(serializedObject.FindProperty(prop), true); | ||
private void DrawField(SerializedProperty prop, string propName) => EditorGUILayout.PropertyField(prop.FindPropertyRelative(propName), true); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...torKit/Assets/RoR2EditorKit/Editor/ScriptsForRoR2/Inspectors/HGButtonCustomEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.