Skip to content

Instantly share code, notes, and snippets.

@karl-
Last active June 29, 2017 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karl-/7f9f731daf49b73087cca36940fa743e to your computer and use it in GitHub Desktop.
Save karl-/7f9f731daf49b73087cca36940fa743e to your computer and use it in GitHub Desktop.
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