static int ToInit(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UITweenFade obj = (UITweenFade)ToLua.CheckObject(L, 1, typeof(UITweenFade)); obj.ToInit(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Play(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UITweenFade obj = (UITweenFade)ToLua.CheckObject(L, 1, typeof(UITweenFade)); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.Play(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int get_to(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UITweenFade obj = (UITweenFade)o; float ret = obj.to; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index to on a nil value" : e.Message)); } }
static int set_to(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UITweenFade obj = (UITweenFade)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.to = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index to on a nil value" : e.Message)); } }
public Transform Pop() { UITween tween; // 如果队列,当前是满的状态,则加速队列末尾消失速度。Lua层将数据插入缓冲队列 if (_Queue.Count == objPool.Length) { tween = _Queue[0].transform.GetChild(0).GetChild(0).GetComponent <UITween>(); // 如果已在收缩中直接返回,否则收缩 if (tween.isPlaying) { return(null); } StopCoroutine(_QueueDelay[tween.transform]); tween.Play(true); return(null); } GameObject obj = objPool[0]; // 找一个闲置的 for (int i = 0; i < objPool.Length; i++) { // 如果是空的,则实例化一个,然后返回 if (objPool[i] == null) { objPool[i] = GameObject.Instantiate(objPool[0]); obj = objPool[i]; obj.transform.SetParent(objPool[0].transform.parent); obj.transform.localScale = Vector3.one; obj.GetComponent <RectTransform>().offsetMax = objPool[0].GetComponent <RectTransform>().offsetMax; obj.GetComponent <RectTransform>().offsetMin = objPool[0].GetComponent <RectTransform>().offsetMin; break; } // 找一个隐藏的 if (objPool[i].gameObject.activeSelf == false) { obj = objPool[i]; break; } } obj.gameObject.SetActive(true); // 还原 obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; obj.GetComponent <CanvasGroup>().alpha = 1; // 播放展开动画 tween = obj.transform.GetChild(0).GetComponent <UITween>(); tween.Play(true); // 设定收缩时间,回调,并播放 tween = obj.transform.GetChild(0).GetChild(0).GetComponent <UITween>(); tween.ToInit(); tween.onFinish = OnFinish; _QueueDelay.Add(tween.transform, StartCoroutine(DelayShrink(tween))); // 其他现存窗口播放位移动画 for (int i = 0; i < _Queue.Count; i++) { UITweenLocalPosition tweenPos = _Queue[i].GetComponent <UITweenLocalPosition>(); tweenPos.from = _Queue[i].localPosition; tweenPos.to = new Vector3(0, space * (_Queue.Count - i), 0); tweenPos.ToInit(); tweenPos.Play(true); UITweenFade tweenFade = _Queue[i].GetComponent <UITweenFade>(); tweenFade.from = _Queue[i].GetComponent <CanvasGroup>().alpha; tweenFade.to = 0.75f + (1f - (float)(_Queue.Count - i) / (float)(objPool.Length - 1)) * 0.25f; tweenFade.ToInit(); tweenFade.Play(true); UITweenScale tweenScale = _Queue[i].GetComponent <UITweenScale>(); tweenScale.from = _Queue[i].transform.localScale; tweenScale.to = (0.75f + (1f - (float)(_Queue.Count - i) / (float)(objPool.Length - 1)) * 0.25f) * Vector3.one; tweenScale.ToInit(); tweenScale.Play(true); } // 返回最内层 _Queue.Add(obj.transform); return(obj.transform.GetChild(0).GetChild(0)); }