using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// you need to add the UnityEditor
using UnityEditor;
public class EditorWindowTest : EditorWindow {
// massage to show
private const string help_nameobj = "Enter the name of object to observe!";
// zero point for vector position
private Vector3 location = Vector3.zero;
// var name for my object
private string observedName = "";
// add menu Tool - Test_Editor
[MenuItem("Tools/Test_Editor")]
// Use this for initialization
public static void CreateMyEditorCode()
{
// create editor window
EditorWindow.GetWindow<EditorWindowTest>();
}
public void OnGUI()
{
// this part will use a
observedName = EditorGUILayout.TextField("Name", observedName);
// find object
GameObject foundObject = GameObject.Find(observedName);
// if foundObject get location
if (foundObject)
{
foundObject.transform.position = EditorGUILayout.Vector3Field("Location", foundObject.transform.position);
} else {
// show a message
EditorGUILayout.HelpBox(help_nameobj, MessageType.Info);
}
// use location into window editor
location = EditorGUILayout.Vector3Field("Location", location);
// test the button
if (GUILayout.Button("Show debug log text"))
{
// show into debug the text: Worked
Debug.Log("Worked!");
}
}
}