Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/jackmawer/JacksWorld. An abandoned mini-project that I created while learning to use Unity with networking.
Something went wrong. Try again.
1.0 kB · 38 lines
C#
at master
123456789101112131415161718192021222324252627282930313233343536373839using System;using UnityEngine;
namespace UnityStandardAssets.Utility{ public class SimpleActivatorMenu : MonoBehaviour { // An incredibly simple menu which, when given references // to gameobjects in the scene public GUIText 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; } }}