public static GameObject CreateEventTriggerItem(EventTrigger EventTrigger, EventTrigger._EVENTTRIGGER eCategory, string ItemName) { Transform transform = EventTrigger.gameObject.transform.FindChild(eCategory.ToString()); if (transform == null) { transform = new GameObject(eCategory.ToString()) { transform = { parent = EventTrigger.gameObject.transform } }.transform; } GameObject gameObject = new GameObject(ItemName); gameObject.SetActive(true); gameObject.transform.parent = transform.transform; gameObject.transform.localPosition = new Vector3(0f, 0f, 0f); gameObject.AddComponent(eCategory.ToString()); if (ItemName != null) { gameObject.AddComponent(ItemName); } return(gameObject); }
public GameObject GetItem(EventTrigger._EVENTTRIGGER Category, string name) { List <GameObject> list = this.GetList(Category); if (list == null) { return(null); } foreach (GameObject current in list) { if (name.Equals(current.name)) { return(current); } } Transform transform = base.gameObject.transform.FindChild(Category.ToString()); if (transform != null) { Transform transform2 = transform.FindChild(name); if (transform2 != null) { return(transform2.gameObject); } } return(null); }