public Tween GetTweenById(GameObject target, int id) { if (target == null) { Debug.LogError("error, target is null"); return(null); } if (!dicOfObjTweens.ContainsKey(target)) { Debug.LogWarning("error, dicOfTweens not contain target"); return(null); } var tweenComps = dicOfObjTweens[target]; TweenComp tweenComp = null; for (int i = tweenComps.Count - 1; i >= 0; i--) { tweenComp = tweenComps[i]; if (tweenComp.GetTween().GetId() == id) { return(tweenComp.GetTween()); } } Debug.LogWarning("target does not have the tween of id:" + id); return(null); }
/// <summary> /// remove tween by id from target /// </summary> /// <param name="target"></param> /// <param name="id"></param> public bool RemoveTweenById(GameObject target, int id) { if (target == null) { Debug.LogError("error, target is null"); return(false); } if (!dicOfObjTweens.ContainsKey(target)) { Debug.LogWarning("error, dicOfTweens not contain target"); return(false); } var tweenComps = dicOfObjTweens[target]; TweenComp tweenComp = null; for (int i = tweenComps.Count - 1; i >= 0; i--) { tweenComp = tweenComps[i]; if (tweenComp.GetTween().GetId() == id) { tweenComps.Remove(tweenComp); GameObject.Destroy(tweenComp); this.curCount--; if (tweenComps.Count == 0) { dicOfObjTweens.Remove(target); } return(true); } } Debug.LogWarning("target does not have the tween of id:" + id); return(false); }
bool addTweenComp(GameObject target, TweenComp tweenComp) { if (!dicOfObjTweens.ContainsKey(target)) { dicOfObjTweens[target] = new List <TweenComp>(); } var tweenComps = dicOfObjTweens[target]; for (int i = 0; i < tweenComps.Count; i++) { if (tweenComps[i].GetTween() == tweenComp.GetTween()) { Debug.LogError("dicOfTweens have the same tween, can not add"); return(false); } } tweenComps.Add(tweenComp); return(true); }