/// /// MIT License - Copyright(c) 2019 Ugo Belfiore /// using System.Collections; using System.Collections.Generic; using System.Reflection; using UnityEditor; using UnityEngine; using static UnityEditor.EditorGUILayout; /// /// Custom Transform editor. /// namespace ExtUnityComponents { [CustomEditor(typeof(Transform))] [CanEditMultipleObjects] public class CustomTransformEditor : DecoratorComponentsEditor { /// /// here call the constructor of the DecoratorComponentsEditor class, /// by telling it who we are (a Transform Inspector) /// public CustomTransformEditor() : base(BUILT_IN_EDITOR_COMPONENTS.TransformInspector) { } /// /// This function is called at each OnInspectorGUI /// protected override void OnCustomInspectorGUI() { DisplayResetTransform(); } /// /// display reset transform buttons /// private void DisplayResetTransform() { using (HorizontalScope horizontalScope = new HorizontalScope(EditorStyles.helpBox)) { GUILayout.Label("Reset datas:"); if (GUILayout.Button("Reset")) { ApplyResetTransform(); } } } // /// when we click on reset, reset every target to there /// default state /// private void ApplyResetTransform() { for (int i = 0; i < base.ConcretTargets.Length; i++) { Undo.RecordObject(base.ConcretTargets[i], "position transform"); Transform current = (Transform)base.ConcretTargets[i]; current.localPosition = Vector3.zero; current.localRotation = Quaternion.identity; current.localScale = Vector3.one; } } } }