///
/// MIT License - Copyright(c) 2019 Ugo Belfiore
///
using UnityEditor;
using UnityEngine;
///
/// Custom Transform editor.
///
namespace ExtUnityComponents
{
[CustomEditor(typeof(Transform))]
[CanEditMultipleObjects]
public class TransformEditor : DecoratorComponentsEditor
{
private LockChildren _lockChildren = new LockChildren(); //ref to script
private TransformHiddedTools _transformHiddedTools;
///
/// here call the constructor of the CustomWrapperEditor class,
/// by telling it who we are (a Transform Inspector)
///
public TransformEditor()
: base(BUILT_IN_EDITOR_COMPONENTS.TransformInspector)
{
}
///
/// need to clean when quitting
///
protected override void OnCustomDisable()
{
_lockChildren.CustomDisable();
}
///
/// this function is called on the first OnSceneGUI
///
///
protected override void InitOnFirstOnSceneGUI(SceneView sceneview)
{
_lockChildren.InitOnFirstOnSceneGUI();
}
protected override void CustomOnSceneGUI(SceneView sceneview)
{
_lockChildren.CustomOnSceneGUI();
}
///
/// init the targets inspected and store them.
/// This is called at the first OnInspectorGUI()
/// Not in the constructor ! we don't have targets information in the constructor
///
protected override void InitOnFirstInspectorGUI()
{
_transformHiddedTools = ConcretTarget.GetOrAddComponent();
_lockChildren.Init((Transform)ConcretTarget, this);
}
///
/// This function is called at each OnInspectorGUI
///
protected override void OnCustomInspectorGUI()
{
if (targets.Length < 2)
{
_lockChildren.CustomOnInspectorGUI();
}
}
///
/// this function is called at each EditorUpdate() when we need it
///
protected override void OnEditorUpdate()
{
_lockChildren.OnEditorUpdate();
}
}
}