Last active
June 29, 2017 18:03
-
-
Save karl-/7f9f731daf49b73087cca36940fa743e 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
public class DrawHandle : ScriptableObject | |
{ | |
[SerializeField] Vector3 m_Position = Vector3.zero; | |
[MenuItem("Tools/Draw Handle")] | |
static void Init() | |
{ | |
DrawHandle[] existing = Resources.FindObjectsOfTypeAll<DrawHandle>(); | |
for(int i = 0; i < existing.Length; i++) | |
Object.DestroyImmediate(existing[i]); | |
// If it was open, close it. Otherwise init. | |
if(existing.Length > 0) | |
return; | |
ScriptableObject.CreateInstance<DrawHandle>(); | |
} | |
void OnEnable() | |
{ | |
SceneView.onSceneGUIDelegate += OnSceneGUI; | |
} | |
void OnDisable() | |
{ | |
SceneView.onSceneGUIDelegate -= OnSceneGUI; | |
} | |
void OnSceneGUI(SceneView view) | |
{ | |
m_Position = Handles.PositionHandle(m_Position, Quaternion.identity); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment