Last active
November 5, 2015 01:09
-
-
Save Naphier/3f8fbd682a77d7cbb8ec to your computer and use it in GitHub Desktop.
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
using UnityEngine; | |
using UnityEditor; | |
// This custom Inspector just shows the default inspector and | |
// then, at the correct time, destroys the component if it has | |
// been flagged for destruction. | |
[CustomEditor(typeof(ShowLocalAxis))] | |
public class ShowLocalAxisInspector : Editor | |
{ | |
public override void OnInspectorGUI() | |
{ | |
// Draw the standard inspector. | |
base.DrawDefaultInspector(); | |
// Get the reference to the ShowLocalAxis component in the inspector. | |
ShowLocalAxis showRotated = (ShowLocalAxis)target; | |
// If the CustomTransforInspector class has set the ShowRotated component to be destroyed | |
// then if the inspector's event state is Repaint it is save to actually destroy the component. | |
if (showRotated.destroyWhenSafe && Event.current.type == EventType.Repaint) | |
{ | |
DestroyImmediate(showRotated); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment