Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[NEED SOLUTION] select object via editor script

Discussion in 'Scripting' started by brokenglass, May 28, 2010.

  1. brokenglass

    brokenglass

    Joined:
    May 14, 2010
    Posts:
    10
    Hi, im desperate for solution. I have made my own window using editor scripts, i have made the button, but I cant work out what code selects an object in scene view, enabling me to transform it using the handles.
    I think command I need is : SetObjectEnabled. but i dont know how to use it... :(

    Here is my code :

    Code (csharp):
    1.  
    2. class SelectorWindow extends EditorWindow {
    3. var myString = "Enter search terms...";
    4. var groupEnabled = false;
    5. var myBool = true;
    6. var myFloat = 1.23;
    7. var selected: GameObject;
    8.     @MenuItem ("Window/Selector")
    9.     static function ShowWindow () {
    10.         EditorWindow.GetWindow (SelectorWindow);
    11.     }
    12.  
    13.     function OnGUI () {
    14.         // The actual window code goes here
    15.         EditorGUILayout.Separator();
    16.         myString = EditorGUILayout.TextField ("Search", myString);
    17.         EditorGUILayout.Separator();
    18.         EditorGUILayout.BeginHorizontal ();
    19.         GUILayout.Label ("Select :", EditorStyles.boldLabel);
    20.         if (GUI.Button (Rect (10,60,100,25), "FPS Controller")) {
    21.             Debug.Log ("You clicked the button!");
    22.         }
    23.         if (GUI.Button (Rect (120,60,100,25), "table")) {
    24.             Debug.Log ("You clicked the button!");
    25.             selected = GameObject.Find("table");
    26.             // need help here please I think
    27.             Debug.Log(selected);
    28.             }
    29.         EditorGUILayout.EndHorizontal ();
    30.     }
    31. }
     
  2. brokenglass

    brokenglass

    Joined:
    May 14, 2010
    Posts:
    10
    Hi, any advice anyone please ? Im still experimenting, but cant work this out.
     
  3. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    You're looking for the Selection class.