Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Last active June 4, 2019 22:28
Show Gist options
  • Save pr00thmatic/62fb2bba885b44f4786b4410478ebe7a to your computer and use it in GitHub Desktop.
Save pr00thmatic/62fb2bba885b44f4786b4410478ebe7a to your computer and use it in GitHub Desktop.
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