SelectMainCamera

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Description)
m (Removed tabs)
Line 17: Line 17:
 
public class SelectMainCamera : ScriptableObject
 
public class SelectMainCamera : ScriptableObject
 
{
 
{
[MenuItem ("Custom/Select Main Camera ^c")]
+
    [MenuItem ("Custom/Select Main Camera ^c")]
static void Select()
+
    static void Select()
{
+
    {
if (Camera.main != null)
+
        if (Camera.main != null)
Selection.activeObject = Camera.main.gameObject;
+
            Selection.activeObject = Camera.main.gameObject;
}
+
    }
 
}
 
}
 
</csharp>
 
</csharp>

Revision as of 22:23, 11 July 2006

Author: Jonathan Czeck (aarku)

Description

This editor script sets the current selection to your main camera. More technically, it sets the current selection to the first object it finds in your scene that has the tag "MainCamera" on it. This is usually the object titled "Main Camera" that is in your scene by default.

Usage

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

C# - SelectMainCamera.cs

<csharp>using UnityEngine; using UnityEditor;

public class SelectMainCamera : ScriptableObject {

   [MenuItem ("Custom/Select Main Camera ^c")]
   static void Select()
   {
       if (Camera.main != null)
           Selection.activeObject = Camera.main.gameObject;
   }

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox