Last active
June 4, 2019 22:28
-
-
Save pr00thmatic/62fb2bba885b44f4786b4410478ebe7a to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
using UnityEditor.SceneManagement; | |
[CustomEditor(typeof(asdf))] | |
public class AsdfEditor : Editor { | |
asdf Target { get => (asdf) target; } | |
// https://docs.unity3d.com/ScriptReference/EditorGUILayout.html | |
// https://docs.unity3d.com/ScriptReference/GUILayout.html | |
public override void OnInspectorGUI () { | |
DrawDefaultInspector(); | |
if (GUI.changed && !Application.isPlaying) { | |
EditorUtility.SetDirty(Target); | |
EditorSceneManager.MarkSceneDirty(Target.gameObject.scene); | |
} | |
} | |
// https://docs.unity3d.com/ScriptReference/Gizmos.html | |
// https://docs.unity3d.com/ScriptReference/Handles.html | |
// https://docs.unity3d.com/ScriptReference/IMGUI.Controls.BoxBoundsHandle.html | |
public static void DrawGizmos (asdf customTarget) { | |
Handles.matrix = customTarget.transform.localToWorldMatrix; | |
} | |
void OnSceneGUI () { | |
DrawGizmos(Target); | |
if (GUI.changed && !Application.isPlaying) { | |
EditorUtility.SetDirty(Target); | |
EditorSceneManager.MarkSceneDirty(Target.gameObject.scene); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment