- Home /
Question by
electricsauce · Oct 24, 2012 at 10:56 PM ·
editortransform
transform input field in editor window
How do I generate a transform input field in an editor window? This is just the helloworld example plus the input that I can't get to work:
public class WallBuilder : EditorWindow
{
string myString = "Hello World";
Object block;
int blocksWide;
int blocksTall;
bool groupEnabled;
bool myBool = true;
float myFloat = 1.23f;
// Add menu named "My Window" to the Window menu
[MenuItem ("WallBuilder/WallBuilder")]
static void Init ()
{
// Get existing open window or if none, make a new one:
WallBuilder window = (WallBuilder)EditorWindow.GetWindow (typeof(WallBuilder));
}
void OnGUI ()
{
GUILayout.Label ("Base Settings", EditorStyles.boldLabel);
myString = EditorGUILayout.TextField ("Text Field", myString);
groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
myBool = EditorGUILayout.Toggle ("Toggle", myBool);
myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
EditorGUILayout.EndToggleGroup ();
//block = EditorGUILayout.ObjectField(block, Object);
}
}
Comment
Best Answer
Answer by aeroson · Aug 18, 2013 at 12:59 PM
block = EditorGUILayout.ObjectField("Object", block, typeof(Object));
Or if you want something else than object
public Transform root;
void OnGUI() {
root = EditorGUILayout.ObjectField("root", root, typeof(Transform), true) as Transform;
}
http://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.ObjectField.html
Your answer
Follow this Question
Related Questions
Can't move GameObject in Scene view with Unity Components attached 2021.2.2f 0 Answers
OnSceneGUI has odd behaviour with multiple objects selected 1 Answer
uGUI WorldSpace elements part of GameObjects 0 Answers
How to create custom editor component to set z-position from dropdown list of values 2 Answers
Scale the standard Transform Handle 2 Answers