Final commit
This commit is contained in:
40
Assets/Standard Assets/Utility/SimpleActivatorMenu.cs
Normal file
40
Assets/Standard Assets/Utility/SimpleActivatorMenu.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#pragma warning disable 618
|
||||
namespace UnityStandardAssets.Utility
|
||||
{
|
||||
public class SimpleActivatorMenu : MonoBehaviour
|
||||
{
|
||||
// An incredibly simple menu which, when given references
|
||||
// to gameobjects in the scene
|
||||
public Text camSwitchButton;
|
||||
public GameObject[] objects;
|
||||
|
||||
|
||||
private int m_CurrentActiveObject;
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// active object starts from first in array
|
||||
m_CurrentActiveObject = 0;
|
||||
camSwitchButton.text = objects[m_CurrentActiveObject].name;
|
||||
}
|
||||
|
||||
|
||||
public void NextCamera()
|
||||
{
|
||||
int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;
|
||||
|
||||
for (int i = 0; i < objects.Length; i++)
|
||||
{
|
||||
objects[i].SetActive(i == nextactiveobject);
|
||||
}
|
||||
|
||||
m_CurrentActiveObject = nextactiveobject;
|
||||
camSwitchButton.text = objects[m_CurrentActiveObject].name;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user