SelectAllOfType

From Unify Community Wiki
Revision as of 23:27, 15 February 2007 by Aarku (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Author: Jonathan Czeck (aarku)

Description

This editor script sets the current selection to be the specified class name, e.g. Transform or MyScript.

Usage

Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the Custom menu after it is compiled.

C# - SelectAllLights.cs

<csharp>using UnityEngine; using UnityEditor; using System.Collections;

public class SelectAllOfType : ScriptableWizard {

   public string className = "ExampleScript";
   
   [MenuItem ("Custom/Select/Select All of Type...")]
   public static void SelectAllOfTypeMenuIem()
   {
       ScriptableWizard.DisplayWizard("Select All of Type...", typeof(SelectAllOfType), "Select", "");
   }
   
   void OnWizardCreate()
   {
       Object[] objs = FindObjectsOfType(typeof(GameObject));
       ArrayList newSelectionBuilder = new ArrayList();
       
       foreach (GameObject go in objs)
       {
           Component comp = go.GetComponent(className);
           if (comp)
               newSelectionBuilder.Add(go);
       }
       
       GameObject[] newSelection = new GameObject[newSelectionBuilder.Count];
       
       for (int i=0; i < newSelectionBuilder.Count; i++)
           newSelection[i] = newSelectionBuilder[i] as GameObject;
       
       Selection.objects = newSelection;
   }

}</csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox