1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Utility
5 {
6     
public class SimpleActivatorMenu : MonoBehaviour
7     {
8         
// An incredibly simple menu which, when given references
9         
// to gameobjects in the scene
10         
public GUIText camSwitchButton;
11         
public GameObject[] objects;
12
13
14         
private int m_CurrentActiveObject;
15
16
17         
private void OnEnable()
18         {
19             
// active object starts from first in array
20             m_CurrentActiveObject =
0;
21             camSwitchButton.text = objects[m_CurrentActiveObject].name;
22         }
23
24
25         
public void NextCamera()
26         {
27             
int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;
28
29             
for (int i = 0; i < objects.Length; i++)
30             {
31                 objects[i].SetActive(i == nextactiveobject);
32             }
33
34             m_CurrentActiveObject = nextactiveobject;
35             camSwitchButton.text = objects[m_CurrentActiveObject].name;
36         }
37     }
38 }


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