Untitled

mail@pastecode.io avatar
unknown
csharp
3 years ago
1.2 kB
4
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IntroRoomNPCAnimatorActivator : MonoBehaviour
{
    public roomIntroBase[] roomsIntroBase;

    [ContextMenu("DisableAllAnimators")]
    public void DisableAllAnimators()
    {
        foreach(roomIntroBase room in roomsIntroBase)
        {
            foreach (Animator animator in room.npcAnimators)
            {
                animator.enabled = false;
            }
        }
    }

    public void DisableAnimatorsInRoom(int roomIndex)
    {
        roomIntroBase room = roomsIntroBase[roomIndex];
        foreach(Animator animator in room.npcAnimators)
        {
            animator.enabled = false;
        }
    }

    public void EnableAnimatorsInRoom(int roomIndex)
    {
        roomIntroBase room = roomsIntroBase[roomIndex];
        foreach (Animator animator in room.npcAnimators)
        {
            animator.enabled = true;
        }
    }
    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.T))
        {
            DisableAllAnimators();
        }
    }
}

[System.Serializable]
public class roomIntroBase
{
    public int roomIndex;
    public Animator[] npcAnimators;

}