Menu Items - Component Context | Editor Scripting | C# | Unity Game Engine


MenuItems_ComponentContext_Editor.cs
using UnityEngine;
using UnityEditor;

public class MenuItems_ComponentContext_Editor
{
    [MenuItem("CONTEXT/Camera/Set Orthographic")]
    public static void SetOrthographic()
    {
        Camera cam = Selection.activeGameObject.GetComponent<Camera>();
        cam.orthographic = true;
    }

    [MenuItem("CONTEXT/Camera/Set Perspective")]
    public static void SetPerspective(MenuCommand cmd)
    {
        Camera cam = cmd.context as Camera;
        cam.orthographic = false;
    }
}