/// <summary> /// 从场景中找到已经存在的元素 /// </summary> protected void UpdateElementPool() { List <string> elementKeys = new List <string>(); for (int i = 0; i < itemList.Count; i++) { var elementName = itemList[i]; if (!elementKeys.Contains(elementName)) { elementKeys.Add(elementName); var elements = elementCtrl.GetElements <T>(elementName, false); if (elements != null) { foreach (var item in elements) { if (elementPool.Contains(item)) { if (onUpdateElement != null) { onUpdateElement.Invoke(item); } } else { elementPool.ScureAdd(item); } } } else { Debug.Log("have no element name:" + elementName); } } } }
/// <summary> /// 尝试创建一个元素 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="elementName"></param> /// <returns></returns> public T TryCreateElement <T>(string elementName, Transform parent, bool clearAble = true) where T : ISupportElement { T element = default(T); var prefab = runTimeElementPrefabs.Find(x => x.Name == elementName); if (prefab != null) { var e = CreateElement(prefab, parent); //e.Name = prefab.Name; if (e is T) { element = (T)e; element.IsRuntimeCreated = true; if (clearAble) { rutimeCreatedList.ScureAdd(element); } } else { Debug.LogError(e + "is not an " + typeof(T).FullName); } } else { Debug.LogError("prefab not exist:" + elementName); } return(element); }
/// <summary> /// 注册可点击元素 /// </summary> /// <param name="arg0"></param> protected void OnRegistElement(ISupportElement arg0) { if (arg0 is ActionItem) { var element = arg0 as ActionItem; elementPool.ScureAdd(element); } }
/// <summary> /// 元素动态注册 /// </summary> /// <param name="arg0"></param> protected override void OnRegistElement(ISupportElement arg0) { if (arg0.IsRuntimeCreated) { if (hoders.Find(x => x.elementName == arg0.Name) != null) { supportPool.ScureAdd(arg0); if (Started && !Completed) { arg0.StepActive(); TryComplete(); } } } }
/// <summary> /// 注册 /// </summary> /// <param name="arg0"></param> protected override void OnRegistElement(ISupportElement arg0) { if (arg0 is LinkItem) { if (linkItems.Contains(arg0.Name)) { var linkItem = arg0 as LinkItem; if (!linkPool.Contains(linkItem)) { linkPool.ScureAdd(linkItem); if (Started) { linkItem.StepActive(); } } } } }
/// <summary> /// 注册可点击元素 /// </summary> /// <param name="arg0"></param> protected void OnRegistElement(ISupportElement arg0) { if (SupportType(arg0.GetType()) && itemList.Contains(arg0.Name)) { if (!elementPool.Contains(arg0)) { elementPool.ScureAdd(arg0); } } }
protected void OnRegistElement(ISupportElement arg0) { if (arg0.GetType() == type && arg0 is ActionItem && arg0.Name == elementName) { var element = arg0 as ActionItem; if (!elementPool.Contains(element)) { elementPool.ScureAdd(element); } } }
/// <summary> /// 外部添加Element /// </summary> public void RegistElement(params ISupportElement[] items) { foreach (var item in items) { if (!elementList.Contains(item)) { elementList.ScureAdd(item); if (onRegistElememt != null) { onRegistElememt.Invoke(item); } } } }
internal void RegistRunTimeElements(IList <RunTimePrefabItem> elements) { foreach (var item in elements) { if (item == null && item.prefab) { continue; } var element = item.prefab.GetComponent <ISupportElement>(); if (element != null && !runTimeElementPrefabs.Contains(element)) { runTimeElementPrefabs.ScureAdd(element); } } }
/// <summary> /// 外部添加Element /// </summary> public void RegistElement(params ISupportElement[] items) { foreach (var item in items) { if (!elementList.Contains(item)) { elementList.ScureAdd(item); if (onRegistElememt != null) { onRegistElememt.Invoke(item); } if (log) { Debug.Log("regist:" + item.Name); } } } }
/// <summary> /// 注册 /// </summary> /// <param name="arg0"></param> protected override void OnRegistElement(ISupportElement arg0) { if (arg0 is PlaceElement) { if (arg0.Name == Name) { var placeItem = arg0 as PlaceElement; if (!elementPool.Contains(placeItem)) { elementPool.ScureAdd(placeItem); if (Started && !Completed) { placeItem.StepActive(); } } } } }