1 using System;
2 using
UnityEngine;
3 using
UnityEngine.UI;
4
5 public
class CameraSwitch : MonoBehaviour
6 {
7     
public GameObject[] objects;
8     
public Text text;
9
10     
private int m_CurrentActiveObject;
11
12
13     
private void OnEnable()
14     {
15         text.text = objects[m_CurrentActiveObject].name;
16     }
17
18
19     
public void NextCamera()
20     {
21         
int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;
22
23         
for (int i = 0; i < objects.Length; i++)
24         {
25             objects[i].SetActive(i == nextactiveobject);
26         }
27
28         m_CurrentActiveObject = nextactiveobject;
29         text.text = objects[m_CurrentActiveObject].name;
30     }
31 }


Gõ tìm kiếm nhanh...