SelectCameraHandler.cs 612 Bytes
Newer Older
1
2
3
4
5
6
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class SelectCameraHandler : MonoBehaviour, IPointerClickHandler
{
Sebastian Höffner's avatar
Sebastian Höffner committed
7
8
    private Transform mainCamera;
    public Transform thisCamera;
9
10


Sebastian Höffner's avatar
Sebastian Höffner committed
11
12
13
14
15
16
    void Start()
    {
        mainCamera = GameObject.Find($"Main Camera").transform;
        thisCamera = GameObject.Find($"Cameras/{name}").transform;
    }

17
18
    public void OnPointerClick(PointerEventData pointerEventData)
    {
Sebastian Höffner's avatar
Sebastian Höffner committed
19
20
        Debug.Log($"[SelectCameraHandler] Selecting Camera {name.Split(' ')[1]}");
        mainCamera.SetParent(thisCamera, false);
21
    }
22
}