SelectCameraHandler.cs 590 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

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

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