Forum rules - please read before posting.

Auto-Switch Background Image for 2.5D Camera

A script that, when a camera is selected, automatically switches the background without having to press the "Set Active" button, handy if you have a lot of cameras.

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using AC;

[InitializeOnLoad]
public static class Auto25DBackgroundOnSelect
{
    static Auto25DBackgroundOnSelect()
    {
        Selection.selectionChanged += OnSelectionChanged;
    }

    static void OnSelectionChanged()
    {
        if (Application.isPlaying) return;

        GameObject go = Selection.activeGameObject;
        if (go == null) return;

        GameCamera25D cam = go.GetComponent<GameCamera25D>();
        if (cam == null || cam.backgroundImage == null) return;

        cam.SetActiveBackground();
        EditorApplication.QueuePlayerLoopUpdate();
        SceneView.RepaintAll();
    }
}
#endif
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.