FANDOM


This script provides an Editor window that allows you to quickly switch between all the different 2.5D GameCameras in your scene while working.

To use it, paste the script below into a C# file named CameraSelectorEditor.cs, and place the file in a subdirectory named "Editor" in your Assets folder.

The new Editor window will then be available from the top toolbar, under Adventure Creator -> 2.5D Camera selector

CameraSelectorEditor.cs:

using UnityEngine;
using UnityEditor;
using AC;

public class CameraSelectorEditor : EditorWindow
{

    private static GameCamera25D[] gameCamera25Ds;

    [MenuItem ("Adventure Creator/2.5D Camera selector", false, 40)]
    public static void Init ()
    {
        CameraSelectorEditor window = (CameraSelectorEditor) EditorWindow.GetWindow (typeof (CameraSelectorEditor));
        UnityVersionHandler.SetWindowTitle (window, "2.5D camera selector");
        window.position = new Rect (300, 200, 450, 270);
    }

    private void OnGUI ()
    {
        if (Application.isPlaying) return;

        if (gameCamera25Ds == null || GUILayout.Button ("Refresh"))
        {
            gameCamera25Ds = Object.FindObjectsOfType <GameCamera25D>();
        }
        EditorGUILayout.Space ();

        foreach (GameCamera25D gameCamera25D in gameCamera25Ds)
        {
            EditorGUILayout.BeginHorizontal ();
            GUILayout.Label (gameCamera25D.gameObject.name);

            if (GUILayout.Button ("Make active", GUILayout.Width (150f)))
            {
                gameCamera25D.SetActiveBackground ();
            }

            EditorGUILayout.EndHorizontal ();
        }
    }

}
Community content is available under CC-BY-SA unless otherwise noted.