You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/Gameplay/RandomChildrenSwitcher.cs

27 lines
648 B
C#

3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using D2D.Utilities;
using D2D.Utils;
using UnityEngine;
namespace D2D
{
public class RandomChildrenSwitcher : MonoBehaviour
{
public GameObject ActiveGameObject { get; private set; }
private void Start()
{
var models = new List<GameObject>();
foreach (Transform child in transform)
{
models.Add(child.gameObject);
child.gameObject.Off();
}
ActiveGameObject = models.GetRandomElement();
ActiveGameObject.On();
}
}
}