Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active November 29, 2015 20:01
Show Gist options
  • Save tsubaki/772524faef62621a7c89 to your computer and use it in GitHub Desktop.
Save tsubaki/772524faef62621a7c89 to your computer and use it in GitHub Desktop.
ハッシュ値からオブジェクトへPINGする
using UnityEngine;
using System.Collections;
using UnityEditor;
public class PingTargetWindow : EditorWindow{
static EditorWindow window;
[MenuItem("Window/Ping")]
static void Init()
{
if( window == null )
window = EditorWindow.CreateInstance<PingTargetWindow> ();
window.Show ();
}
static void Stop()
{
EditorApplication.isPaused = true;
}
string input = string.Empty;
int cacheHash = -1;
void OnGUI()
{
UnityEditor.EditorGUI.BeginChangeCheck ();
input = EditorGUILayout.TextField ("instanceID", input);
if (EditorGUI.EndChangeCheck ()) {
int hash;
if (int.TryParse (input, out hash)) {
EditorGUIUtility.PingObject (hash);
cacheHash = hash;
}
}
EditorGUI.BeginDisabledGroup (cacheHash == -1);
if (GUILayout.Button ("PING")) {
EditorGUIUtility.PingObject (cacheHash);
}
EditorGUI.EndDisabledGroup ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment