public GameObject ShowEffect(string name, Transform parent) { if (parent == null || UsedEffect == null || UsedEffect.Length == 0) { return(null); } GameObject orgGo = FindExistGO(name, parent, 0); if (orgGo != null) { return(orgGo); } for (int idx = 0; idx < UsedEffect.Length; idx++) { stUIEffect ef = UsedEffect[idx]; if (ef.aliasName == name && parent == ef.parent) { if (insts[idx] != null) { GameObject go = insts[idx]; go.SetActive(true); if (ef.autoOrder) { SetAutoOrder(go, ef.autoOrderDiff); } return(go); } else { GameObject effectGo = CacheResPoolMgr.Instance.LoadUIEffect(ef.assetName); if (effectGo != null) { MountSound(effectGo, ef.soundIdx); effectGo.name = name; effectGo.transform.SetParent(ef.parent); effectGo.transform.localPosition = ef.pos; effectGo.transform.localScale = Vector3.one; insts[idx] = effectGo; if (ef.autoOrder) { SetAutoOrder(effectGo, ef.autoOrderDiff); } return(effectGo); } else { ShowEffectAsync(name, parent, 0); } } } } return(null); }
public void ShowEffectAsync(string name, Transform parent, int SortingOrder) { if (parent == null || FindExistGO(name, parent, SortingOrder) != null) { return; } if (UsedEffect == null || UsedEffect.Length == 0) { return; } for (int idx = 0; idx < UsedEffect.Length; idx++) { stUIEffect ef = UsedEffect[idx]; if (ef.aliasName == name && parent == ef.parent) { if (insts[idx] != null) { GameObject go = insts[idx]; go.SetActive(true); if (SortingOrder > 0) { EffectUtility.Instance.SetEffectSortingOrder(go, SortingOrder); } else if (ef.autoOrder) { SetAutoOrder(go, ef.autoOrderDiff); } } else { CacheResPoolMgr.Instance.LoadUIEffectAsync(ef.assetName, (GameObject effectGo) => { if (effectGo != null) { MountSound(effectGo, ef.soundIdx); effectGo.name = name; effectGo.transform.SetParent(ef.parent); effectGo.transform.localPosition = ef.pos; effectGo.transform.localScale = Vector3.one; if (SortingOrder > 0) { EffectUtility.Instance.SetEffectSortingOrder(effectGo, SortingOrder); } else if (ef.autoOrder) { SetAutoOrder(effectGo, ef.autoOrderDiff); } } }); } } } }
/// <summary> /// 创建一个特效,但是不显示【在界面刚打开的使用进行使用】 /// </summary> /// <param name="name">特效名字</param> /// <param name="parent"></param> /// <param name="SortingOrder"></param> /// <returns></returns> public GameObject CreateEffect(string name, Transform parent, int SortingOrder) { if (UsedEffect == null || UsedEffect.Length == 0) { return(null); } for (int idx = 0; idx < UsedEffect.Length; idx++) { stUIEffect ef = UsedEffect[idx]; if (ef.aliasName == name && parent == ef.parent) { if (insts[idx] != null) { GameObject go = insts[idx]; if (SortingOrder > 0) { EffectUtility.Instance.SetEffectSortingOrder(go, SortingOrder); } else if (ef.autoOrder) { SetAutoOrder(go, ef.autoOrderDiff); } return(go); } GameObject effectGo = CacheResPoolMgr.Instance.LoadUIEffect(ef.assetName); if (effectGo != null) { MountSound(effectGo, ef.soundIdx); effectGo.name = name; effectGo.transform.SetParent(ef.parent); effectGo.transform.localPosition = ef.pos; effectGo.transform.localScale = Vector3.one; insts[idx] = effectGo; if (SortingOrder > 0) { EffectUtility.Instance.SetEffectSortingOrder(effectGo, SortingOrder); } if (ef.autoOrder) { SetAutoOrder(effectGo, ef.autoOrderDiff); } effectGo.SetActive(false); return(effectGo); } } } return(null); }