public override void OnPointerClick(PointerEventData eventData) { base.OnPointerClick(eventData); if (!interactable || uiMod == null) { return; } if (clickInterval != 0) { _ClickEnableTime = System.DateTime.Now.Second + clickInterval; _ClickInterval = StartCoroutine(ClickInterval()); interactable = false; } //LogUtil.GetInstance().WriteGame( "UIEVENT.CLICK["+uiMod.uiName+"]" + controlID ); object[] param = { UIEVENT.CLICK, controlID, this }; uiMod.OnEvent(param); if (audioID == 0) { eye.audioManager.Play(101); } else { eye.audioManager.Play(audioID); } }
// Update is called once per frame void Update() { Vector2 touchpos = Vector2.zero; #if UNITY_STANDALONE || UNITY_EDITOR if (Input.GetMouseButtonUp(0)) { touchpos = Input.mousePosition; if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, canvas.worldCamera, out touchpos)) { //rectTransform.anchoredPosition = pos; } object[] param = { UIEVENT.CLICKPOS, controlID, touchpos }; uiMod.OnEvent(param); } #else if (Input.touchCount == 1) { if (Input.GetTouch(0).phase == TouchPhase.Ended) { touchpos = Input.GetTouch(0).position; object[] param = { UIEVENT.CLICKPOS, controlID, touchpos }; uiMod.OnEvent(param); } } #endif //object[] param = { obj, touchpos, unit_index }; //LuaFun.worldMapOnClick.Call( param ); }
/// <summary> /// 拖拽结束 /// </summary> ///<param name="eventData"> public void OnEndDrag(PointerEventData eventData) { isDrag = false; var tempPos = srect.horizontalNormalizedPosition; //获取拖动的值 var index = 0; float offset = Mathf.Abs(listPageValue[index] - tempPos); //拖动的绝对值 for (int i = 0; i < listPageValue.Count; i++) { float temp = Mathf.Abs(tempPos - listPageValue[i]); if (temp < offset) { index = i; offset = temp; } } targetPos = listPageValue[index]; nowindex = index; if (OnPageChanged != null) { OnPageChanged(Convert.ToInt32(nowindex)); } object[] param = { UIEVENT.SCROLLPAGE, controlID, Convert.ToInt32(nowindex) }; uiMod.OnEvent(param); }
private void OnValueChange(float currValue) { if (uiMod == null) { return; } uiMod.OnEvent(UIEVENT.UISCROLLBAR_ONVALUECHANGE, controlID, currValue); }
private void OnValueChange(Vector2 delta) { if (uiMod == null || !dragEventOn) { return; } uiMod.OnEvent(UIEVENT.UISCROLLVIEW_ONVALUECHANGE, controlID, delta); }
public override void OnSubmit(BaseEventData eventData) { base.OnSubmit(eventData); if (uiMod == null) { return; } uiMod.OnEvent(UIEVENT.UIINPUT_SUBMIT, controlID, text); }
// 计时结束 protected virtual void OnTimeEnd() { if (overText != String.Empty) { text = overText; } if (this.uiMod != null) { object[] param = { UIEVENT.TIMECOUNTEND, controlID, 0 }; uiMod.OnEvent(param); } }
private void OnValueChange(bool value) { if (uiMod == null) { return; } if (_lastValue == value) { return; } _lastValue = value; uiMod.OnEvent(UIEVENT.UITOGGLE_ONVALUECHANGE, controlID, value); }
public override void OnPointerDown(PointerEventData eventData) { base.OnPointerDown(eventData); if (!CanDrag(eventData) || uiMod == null) { return; } uiMod.OnEvent(UIEVENT.UISLIDER_PRESS, controlID, 0); // 播放按钮音效 if (audioId > 0) { AudioMgr.Inst.Play(audioId, uiMod.resUtility.moduleName); } }
public override void OnPointerDown(PointerEventData eventData) { base.OnPointerDown(eventData); if (!CanDrag(eventData) || uiMod == null) { return; } uiMod.OnEvent(UIEVENT.UISLIDER_PRESS, controlID, 0); // 播放按钮音效 if (audioId > 0) { AudioManager.instance.Play(audioId); } }
public override void OnPointerClick(PointerEventData eventData) { base.OnPointerClick(eventData); if (!IsInteractable() || uiMod == null) { return; } uiMod.OnEvent(UIEVENT.UIBUTTON_CLICK, controlID, 0); // 播放按钮音效 if (audioId > 0) { AudioManager.instance.Play(audioId); } }
public override void OnPointerClick(PointerEventData eventData) { base.OnPointerClick(eventData); if (!IsInteractable() || uiMod == null) { return; } uiMod.OnEvent(UIEVENT.UIBUTTON_CLICK, controlID, 0); // 播放按钮音效 if (audioId > 0) { AudioMgr.Inst.Play(audioId, uiMod.resUtility.moduleName); } }
public void OnBeginDrag(PointerEventData eventData) { Vector3 delta = new Vector3(eventData.delta.x, eventData.delta.y, 0); if (Mathf.Abs(eventData.delta.y) > Mathf.Abs(eventData.delta.x)) { m_IsSideslip = false; uiScrollRect.OnBeginDrag(eventData); } else { m_IsSideslip = true; object[] param = { UIEVENT.DRAGSENSOR, controlID, delta }; uiMod.OnEvent(param); } }
protected void ValueChanged(bool isOn) { if (uiMod == null) { return; } object[] param = { UIEVENT.TOGGLEVALUECHANGE, controlID, isOn }; uiMod.OnEvent(param); }
protected void ValueChanged(float value) { if (uiMod == null) { return; } object[] param = { UIEVENT.SLIDERVALUECHANGE, controlID, this.value }; uiMod.OnEvent(param); }
// 正向结束为0,逆向为1 protected void OnFinished() { if (onFinish != null) { onFinish(gameObject, _Forward ? 0 : 1); } if (uiMod != null) { object[] param = { UIEVENT.TWEENFINISH, controlID, _Forward ? 0 : 1 }; uiMod.OnEvent(param); } }
public void OnBeginDrag(PointerEventData eventData) { if (sourceIcon != null) { dragIcon.sprite = sourceIcon.sprite; dragIcon.SetNativeSize(); dragIcon.transform.localScale = Vector3.one * scale; if (hideSourceOnDragging) { sourceIcon.enabled = false; } } if (uiMod != null) { object[] param = { UIEVENT.UIDRAG, controlID, 0 }; uiMod.OnEvent(param); } dragIcon.gameObject.SetActive(true); }
void ScrollCellIndex(int idx) { //string name = "Cell " + idx.ToString (); //gameObject.name = name; if (uiMod == null) { return; } object[] param = { UIEVENT.SCROLLINDEXCALLBACK, controlID, idx }; uiMod.OnEvent(param); }
private void Countup() { if (mIsStart == false) { return; } m_Total = m_Total + 1; ShowText(m_Total); if (uiMod != null) { object[] param = { UIEVENT.TIMECOUNTCHANGED, controlID, m_Total }; uiMod.OnEvent(param); } }
static int OnEvent(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UIMod obj = (UIMod)ToLua.CheckObject(L, 1, typeof(UIMod)); object[] arg0 = ToLua.CheckObjectArray(L, 2); obj.OnEvent(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// 收缩完毕 void OnFinish(GameObject obj, int value) { Transform trans = obj.transform.parent.parent; // 删除 _Queue.Remove(trans); _QueueDelay.Remove(obj.transform); trans.gameObject.SetActive(false); if (uiMod != null) { object[] param = { UIEVENT.PUSHEVENT, controlID, 0 }; uiMod.OnEvent(param); } }
static int OnEvent(IntPtr L) { try { ToLua.CheckArgsCount(L, 4); UIMod obj = (UIMod)ToLua.CheckObject <UIMod>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); object arg2 = ToLua.ToVarObject(L, 4); obj.OnEvent(arg0, arg1, arg2); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void OnPointerClick(PointerEventData eventData) { if (uiMod == null) { return; } Vector2 localPos; RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out localPos); for (int i = _eventList.Count - 1; i >= 0; i--) { EventInfo e = _eventList[i]; if (e.rect.Contains(localPos)) { uiMod.OnEvent(UIEVENT.UIRICHREXT_CLICK, e.controlID, e.parameter); break; } } }
public override void OnBeginDrag(PointerEventData eventData) { base.OnBeginDrag(eventData); object[] param = { UIEVENT.SCROLLDRAG, controlID, 0 }; uiMod.OnEvent(param); }
/// <summary> /// 值修改 /// </summary> /// <param name="v"></param> public virtual void ValueChange(string v) { object[] param = { UIEVENT.INPUTVALUECHANGED, controlID, this.text }; uiMod.OnEvent(param); }
public virtual void OnDrag(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) { return; } Vector2 vector; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(viewPort, eventData.position, eventData.pressEventCamera, out vector)) { return; } Vector2 vector2 = vector - _PointerStartLocalCursor; switch (moveType) { case MovementType.Horizon: if (!_Dragging) { _DragAmount += vector2.x; if (Math.Abs(_DragAmount) >= dragThreshold) { _Dragging = true; _PointerStartLocalCursor = vector; BeginDrag(); //_ContentStartAngle = _CurrAxisAngle; if (uiMod) { object[] param = { UIEVENT.SCROLLDRAG, controlID, 0 }; uiMod.OnEvent(param); } } else { return; } } Drag(vector2.x * dragSpeed * (dragInverse ? -1 : 1)); break; case MovementType.Vertical: if (!_Dragging) { _DragAmount += vector2.y; if (Math.Abs(_DragAmount) >= dragThreshold) { _Dragging = true; _PointerStartLocalCursor = vector; BeginDrag(); //_ContentStartAngle = _CurrAxisAngle; if (uiMod) { object[] param = { UIEVENT.SCROLLDRAG, controlID, 0 }; uiMod.OnEvent(param); } } else { return; } } Drag(vector2.y * dragSpeed * (dragInverse ? -1 : 1)); break; } if (enableDragginEvent && uiMod) { object[] param = { UIEVENT.SCROLLDRAG, controlID, 1 }; uiMod.OnEvent(param); } }
//更新 private void Update() { if (!_started) { return; } // 当前剩余时间 int time = 0; bool finish = false; // +还是- if (_forward) { time = GetTimeStamp() - _startTimeStamp + _timeStampOffset; if (time >= _endTimeStamp - _startTimeStamp) { finish = true; time = _endTimeStamp - _startTimeStamp; } } else { time = _endTimeStamp - GetTimeStamp() - _timeStampOffset; if (time <= 0) { time = 0; finish = true; } } // 换算,并显示文本 int hour = (int)((float)time / 60 / 60); int minute = (int)((float)time / 60 % 60); int second = (int)((float)time % 60); // 有格式化文本 if (_textID != null) { this.text = Localization.Get(_textID, hour, minute, second); } // 没有 else { this.text = string.Format("{0:d2}:{1:d2}:{2:d2}", hour, minute, second); } // 结束 if (finish) { _started = false; if (_finishTextID != null) { this.text = Localization.Get(_finishTextID); } if (uiMod) { uiMod.OnEvent(UIEVENT.UITIMER_TIMERUNOUT, controlID, 0); } } }