using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BF { [System.Serializable] public struct TimelineEventItem { public string eventName; public uint eventHash; public double eventTime; } [ExecuteInEditMode] [DisallowMultipleComponent] public class TimelineHelper : MonoBehaviour { public List prefabList = new List(); public double duration; [SerializeField, Delayed] public List timelineEventList = new List(); public GameObject GetGameObjectByName(string name) { int count = prefabList.Count; for (int i = 0; i < count; i++) { if (prefabList[i].name == name) { return prefabList[i].gameObject; } } return null; } public int GetListCount() { return prefabList.Count; } public int GetObjectTypeByIndex(int index) { if (index >= 0 && index < prefabList.Count) { return prefabList[index].objectType; } return 0; } public uint GetHashNameByIndex(int index) { if (index >= 0 && index < prefabList.Count) { return prefabList[index].hashName; } return 0; } public GameObject GetGameObjectByIndex(int index) { if (index >= 0 && index < prefabList.Count) { return prefabList[index].gameObject; } else if (index < 0) { return this.gameObject; } return null; } public int GetRootPrefabIndex() { int index = -1; for (int i = 0; i < prefabList.Count; i++) { if (prefabList[i].gameObject == this.gameObject) { index = i; break; } } return index; } public int GetEventListCount() { return timelineEventList.Count; } public uint GetEventHashNameByIndex(int index) { if (index >= 0 && index < timelineEventList.Count) { return timelineEventList[index].eventHash; } return 0; } public double GetEventTimeByIndex(int index) { if (index >= 0 && index < timelineEventList.Count) { return timelineEventList[index].eventTime; } return 0; } void OnDestroy() { prefabList.Clear(); prefabList = null; } } }