Files
beyond/Assets/ThirdParty/Invector-3rdPersonController/Basic Locomotion/Scripts/Generic/vEnableRandomObject.cs
2024-11-20 15:21:28 +01:00

26 lines
606 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class vEnableRandomObject : MonoBehaviour
{
public GameObject[] objects;
public bool enableOnStart;
// Start is called before the first frame update
protected void Awake()
{
if (enableOnStart)
EnableObject();
}
public virtual void EnableObject()
{
int indexToEnable = Random.Range(0, objects.Length *10) & objects.Length - 1;
for (int i=0;i<objects.Length;i++)
{
objects[i].SetActive(i == indexToEnable);
}
}
}