SetLayerOfSelection

From Unify Community Wiki
Revision as of 03:23, 1 July 2006 by Aarku (Talk | contribs)

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

Author: Jonathan Czeck (aarku)

Contents

Description

This editor pops up a wizard window that will allow you to enter what number you would like to set your selection's layer to.

Usage

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

Known Limitations

Unity does not provide a way currently to get a useful string from a layer name. Therefore, you will have to enter the number in manually rather than select from a popup of choices.

C# - SetLayerOfSelection.cs

<csharp>using UnityEngine; using UnityEditor;

public class SetLayerOfSelection : ScriptableWizard {

   public int layer;
   
   [MenuItem ("Custom/Set Layer of Selection %l")]
   static void DoSet()
   {
       ScriptableWizard.DisplayWizard("Set Layer of Selection", typeof(SetLayerOfSelection), "Set");
       
   }
   
   void OnWizardUpdate()
   {
       helpString = "Set the layer of the objects in the selection to...";
   }
   
   void OnWizardCreate()
   {
       Object[] objs = Selection.GetFiltered(typeof(GameObject), SelectionMode.ExcludePrefab | SelectionMode.Editable);
       
       foreach (GameObject go in objs)
       {
           go.layer = layer;
       }
   }   

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox