using UnityEditor; using UnityEngine; using TriInspector.Editors; using UnityEngine.UIElements; namespace R0bbie.Timeline { /// /// Editor class to update the GameObject name based on the shortName of the step and child position /// [CustomEditor(typeof(Step),true)] public class StepEditor : TriEditor { private TriEditorCore _core; /// /// Unity OnEnable function - called here when object is selected to be viewed in inspector /// void OnEnable() { Rename(); // Re-implement base TriEditor.OnEnable logic (not overridable sadly as its private) _core = new TriEditorCore(this); } /// /// Unity OnDisable function - called here when object selection in inspector view is cleared /// void OnDisable() { Rename(); // Re-implement base TriEditor.OnDisable logic _core.Dispose(); } /// /// Rename the Step GameObject to reflect latest settings /// void Rename() { // If the object has been destroyed avoid changing the name if (!target) return; // Get target as Step Step step = target as Step; if (!step) return; step.UpdateStepName(); } /// /// Function from base TriEditor class which frustratingly we have to re-implement here due to accessibility issues in the base class /// /// public override VisualElement CreateInspectorGUI() { return _core.CreateVisualElement(); } } }