protected override void OnClick() { if (clickTiming == false) { clickTiming = true; UILoopManager.SetTimeout(OnClickTimeOut, clickGap); if (isEnabled == false) { return; } base.OnClick(); if (_clickFun != null) { _clickFun(gameObject); } if (relateChild) { GetChildBtns(); foreach (Component child in childBtn) { if (child != this) { (child as CButton).OnClick(); } } } } }
private void OnMoveUp(CItemRender item, TweenAlpha tween) { if (tween != null) { UnityEngine.Object.DestroyImmediate(tween); } item.GetComponent <UIWidget>().alpha = 1; item.go.SetActive(false); firstMoveItemIndex = _allItem.IndexOf(item); if (_allItem.Count > firstMoveItemIndex + 1) { CItemRender firstItem = _allItem[firstMoveItemIndex + 1]; float offY = item.y - firstItem.y; for (int n = firstMoveItemIndex, len = _allItem.Count; n < len; n++) { CItemRender tempItem = _allItem[n]; //tempItem.SetParent(firstItem.tran); iTween.Stop(tempItem.go); Hashtable hash = iTween.Hash("y", tempItem.y + offY, "time", 0.5f, "islocal", true); iTween.MoveTo(tempItem.go, hash); } //Hashtable hash = iTween.Hash("y", item.y, "time", 0.5f, "islocal", true); //iTween.MoveTo(firstItem.go, hash); } doneKey = UILoopManager.SetTimeout(OnDown, 0.6f); }
private void OnFadeOut(CItemRender item) { UILoopManager.ClearTimeout(doneKey); var tween = TweenAlpha.Begin(item.go, fadeTime, 0f); listAlpha.Add(tween); deplayKeyList.Add(UILoopManager.SetTimeout <CItemRender, TweenAlpha>(OnMoveUp, fadeTime, item, tween)); }
private void OnSliceOut(CItemRender item) { UILoopManager.ClearTimeout(doneKey); Hashtable hash = iTween.Hash("x", width, "time", fadeTime, "islocal", true); iTween.MoveTo(item.go, hash); deplayKeyList.Add(UILoopManager.SetTimeout <CItemRender, TweenAlpha>(OnMoveUp, fadeTime, item, null)); }
private void OnMove() { value += rollSpeed; if ((value >= targetValue && rollSpeed > 0) || (value <= targetValue && rollSpeed < 0)) { value = targetValue; UILoopManager.RemoveFromFrame(this); } }
public static void Init(Transform root) { if (isInited == false) { isInited = true; tipType = -1; _container = root.Find("Container"); _recycle = root.Find("Recycle"); //alertObj.localPosition = Vector3.zero; offset = new Vector2(25, -25); UILoopManager.AddToFrame(loopKey, OnEnterFrame); } }
private void RetrieveRender(CItemRender item) { //item = _allItem[_allItem.Count - 1]; _allItem.Remove(item); _itemPool.Add(item); //item.SetParent(Recycle); //item.tran.localPosition = Vector3.zero; //item.SetActive(false); if (delayKey == -1) { delayKey = UILoopManager.SetTimeout(DelayRetrieveRender, 0.01f); } }
private CItemRender GetOneRender() { CItemRender item; if (_itemPool.Count > 0) { item = _itemPool[_itemPool.Count - 1]; _itemPool.RemoveAt(_itemPool.Count - 1); } else { item = (CItemRender)Activator.CreateInstance(_itemRender); UIEventListener listener = UIEventListener.Get(item.go); listener.onHover = OnItemHover; listener.onPress = OnItemPress; } item.SetParent(Content.transform); if (delayKey2 == -1) { delayKey2 = UILoopManager.SetTimeout(DelayRetrieveRender2, 0.01f); } return(item); }
private void StopMove() { delList.Clear(); if (_allItem != null) { for (int n = 0, len = _allItem.Count; n < len; n++) { CItemRender tempItem = _allItem[n]; //tempItem.SetParent(firstItem.tran); iTween.Stop(tempItem.go); } } if (_itemPool != null) { for (int n = 0, len = _itemPool.Count; n < len; n++) { CItemRender tempItem = _itemPool[n]; //tempItem.SetParent(firstItem.tran); iTween.Stop(tempItem.go); } } for (int i = 0, len = listAlpha.Count; i < len; i++) { if (listAlpha[i]) { UnityEngine.Object.DestroyImmediate(listAlpha[i]); } } for (int r = 0, len = listAlpha.Count; r < len; r++) { UILoopManager.ClearTimeout(deplayKeyList[r]); } listAlpha.Clear(); deplayKeyList.Clear(); UILoopManager.ClearTimeout(doneKey); }
public void SetDataProvider <T>(IEnumerable <T> value) { if (_itemRender == null) { Debug.LogError("set itemRender first!"); return; } if (_itemPool == null) { _itemPool = new List <CItemRender>(); } if (_allItem == null) { _allItem = new List <CItemRender>(); } SetData <T>(value); //_dataProvider = (value ?? new List<T>()) as List<object>; bool isEnough = _allItem.Count >= _dataProvider.Count; int n = Mathf.Abs(_allItem.Count - _dataProvider.Count); CItemRender item; while (n > 0) { if (isEnough == true) { item = _allItem[_allItem.Count - 1]; _itemPool.Add(item); _allItem.RemoveAt(_allItem.Count - 1); item.SetParent(recycle); item.tran.localPosition = Vector3.zero; item.SetActive(false); } else { if (_itemPool.Count > 0) { item = _itemPool[0]; _itemPool.RemoveAt(0); item.SetActive(true); } else { item = (CItemRender)Activator.CreateInstance(_itemRender); } item.SetParent(transform); _allItem.Add(item); } n--; } ResetItems(); lastDataProvider = value; if (_allItem.Count > 0) { if (alwaysMove || _allItem.Count * itemWidth > (content.baseClipRegion.z)) { UILoopManager.AddToFrame(this, OnLoop); } else { UILoopManager.RemoveFromFrame(this); } } else { UILoopManager.RemoveFromFrame(this); } }
void Update() { UILoopManager.FrameLoop(); }
public void RollTo(float target, int time = 20) { targetValue = target; rollSpeed = (target - value) / time; UILoopManager.AddToFrame(this, OnMove); }