SelectMainCamera

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Description)
m (Text replace - "</csharp>" to "</syntaxhighlight>")
 
(2 intermediate revisions by 2 users not shown)
Line 12: Line 12:
  
 
==C# - SelectMainCamera.cs==
 
==C# - SelectMainCamera.cs==
<csharp>using UnityEngine;
+
<syntaxhighlight lang="csharp">using UnityEngine;
 
using UnityEditor;
 
using UnityEditor;
  
 
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>
+
</syntaxhighlight>

Latest revision as of 20:45, 10 January 2012

Author: Jonathan Czeck (aarku)

[edit] 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.

[edit] Usage

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

[edit] C# - SelectMainCamera.cs

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;
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox