public override void InitEvent() { if (m_goCancelBtn != null) { UGUIClickHandler.Get(m_goCancelBtn).onPointerClick += OnCancelBtn; } }
/// <summary> /// 开启或关闭某一项的响应 /// </summary> /// <param name="index"></param> public void Enable(int index, bool isEnable = true) { if (index >= m_items.Count || index < 0) { return; } var toggle = m_items[index].GetComponent <Toggle>(); if (toggle == null) { return; } toggle.isOn = isEnable; toggle.enabled = isEnable; if (isEnable) { UGUIClickHandler.Get(toggle.gameObject).onPointerClick += OnItemClick; } else { UGUIClickHandler.Get(toggle.gameObject).RemoveAllHandler(); } }
public override void InitEvent() { UGUIClickHandler.Get(m_tranLeft).onPointerClick += OnLeftClick; UGUIClickHandler.Get(m_tranRight).onPointerClick += OnRightClick; UGUIClickHandler.Get(m_tranCancel).onPointerClick += OnCancelClick; UGUIClickHandler.Get(m_tranCenter).onPointerClick += OnCenterClick; UGUIClickHandler.Get(mask).onPointerClick += OnMaskClick; }
public void AddClickEvent(UIEventListener.VoidDelegate action) { _clickHandler = action; foreach (var itemRender in _renders) { UGUIClickHandler.Get(itemRender.Value.gameObject).onPointerClick = OnPointerClick; } }
public override void InitEvent() { UGUIClickHandler.Get(m_tranLeft).onPointerClick += OnLeftBtnClick; UGUIClickHandler.Get(m_tranCancel).onPointerClick += OnCancelClick; UGUIClickHandler.Get(m_tranRight).onPointerClick += OnRightBtnClick; UGUIClickHandler.Get(m_tranCenter).onPointerClick += OnCenterBtnClick; UGUIClickHandler.Get(mask).onPointerClick += OnMaskClick; UGUIClickHandler.Get(m_tran.Find("background").gameObject).onPointerClick += OnMaskClick; }
public override void InitEvent() { //这里初始化事件 UGUIClickHandler.Get(commonAttack).onPointerClick += delegate { onClickCommonAttackBtn(); }; UGUIClickHandler.Get(skill_1).onPointerClick += delegate { onClickSkill_1Btn(); }; UGUIClickHandler.Get(skill_2).onPointerClick += delegate { onClickSkill_2Btn(); }; onAtkFinished = this.onAttackFinished; onSkl_1Finished = this.onSkill_1Finished; }
/// <summary> /// 开启或关闭某一项的响应 /// </summary> /// <param name="index"></param> public void Enable(int index, bool isEnable = true) { if (index < m_items.Count) { var toggle = m_items[index].GetComponent <Toggle>(); if (toggle) { toggle.isOn = isEnable; toggle.enabled = isEnable; if (isEnable) { UGUIClickHandler.Get(toggle.gameObject, m_itemClickSound).onPointerClick += OnItemClick; } else { UGUIClickHandler.Get(toggle.gameObject, m_itemClickSound).RemoveAllHandler(); } } } }
void Awake() { cachedTransform = transform; //开始UI获取; image_Equipcr = cachedTransform.Find("image_Equipcr").GetComponent <Image>(); Image_skill1cr = cachedTransform.Find("image_Equipcr/Image_skill1cr").GetComponent <Image>(); Scr_EquipStarcr = cachedTransform.Find("image_Equipcr/Scr_EquipStarcr").GetComponent <ScrollRect>(); glayout_EquipStarcr = cachedTransform.Find("image_Equipcr/Scr_EquipStarcr/glayout_EquipStarcr").GetComponent <GridLayoutGroup>(); image_Selectedcr = cachedTransform.Find("image_Equipcr/image_Selectedcr").GetComponent <Image>(); image_EquipLineLinecr = cachedTransform.Find("image_EquipLineLinecr").GetComponent <Image>(); image_EquipLineTopcr = cachedTransform.Find("image_EquipLineTopcr").GetComponent <Image>(); image_EquipLineBottomcr = cachedTransform.Find("image_EquipLineBottomcr").GetComponent <Image>(); //结束UI获取; isUIinit = true; star = glayout_EquipStarcr.gameObject.AddMissingComponent <UIDataGrid>(); star.InitDataGrid("prefab/UI/Equip/ItemeEquipStarcr", "ItemeEquipStarcr", star.gameObject, null, Direction.none); UGUIClickHandler.Get(Image_skill1cr.gameObject).onPointerClick = OnClickJO; }
// Use this for initialization void Start() { btn = transform.Find("Button").gameObject; rectTrans = btn.GetRectTransform(); UGUIClickHandler.Get(btn).onPointerClick += delegate { Debug.Log("on button..."); }; // float rate = (float)Screen.width / (float)Screen.currentResolution.width; // Vector2 screenPos = rectTrans.anchoredPosition * rate; // Vector2 size = rectTrans.sizeDelta * rate * 1.2f; // // // Vector3 pos = rectTrans.position; // pos = uicam.WorldToScreenPoint(pos); // // rect = new Rect(pos.x - size.x / 2, pos.y - size.y / 2 , size.x , size.y ); // // //EasyTouch.AddReservedGuiArea(rect); // EasyTouch.AddReservedArea(rect); // Debug.Log(rect + "dpi : " + pos); // Debug.Log("width: " + Screen.width + "height: " + Screen.height + "currentResolution : " + Screen.currentResolution.height }
public UGUIClickHandler AddBackBtnListen(GameObject goBackBtn) { m_backBtnClickHandler = UGUIClickHandler.Get(goBackBtn); return(m_backBtnClickHandler); }
/// <summary> /// 更新视图 /// </summary> public void UpdateView() { if (useLoopItems) { m_startIndex = Mathf.Max(0, Mathf.Min(m_startIndex / ConstraintCount, DataUnitCount - m_viewItemCount - CacheUnitCount)) * ConstraintCount; var frontSpace = m_startIndex / ConstraintCount * m_itemSpace; var behindSpace = Mathf.Max(0, m_itemSpace * (DataUnitCount - CacheUnitCount) - frontSpace - (m_itemSpace * m_viewItemCount)); if (m_isVertical) { m_LayoutGroup.padding = new RectOffset(m_oldPadding.left, m_oldPadding.right, frontSpace, behindSpace); } else { m_LayoutGroup.padding = new RectOffset(frontSpace, behindSpace, m_oldPadding.top, m_oldPadding.bottom); } } else { m_startIndex = 0; } if (m_goItemRender == null || m_itemRenderType == null || m_content == null) { return; } int itemLength = useLoopItems ? m_viewItemCount * ConstraintCount + CacheCount : maxLength; itemLength = Mathf.Min(itemLength, maxLength); for (int i = itemLength; i < m_items.Count; i++) { Destroy(m_items[i].gameObject); m_items[i] = null; } for (int i = m_items.Count - 1; i >= 0; i--) { if (m_items[i] == null) { m_items.RemoveAt(i); } } for (int i = 0; i < itemLength; i++) { var index = m_startIndex + i; if (index >= maxLength || index < 0) { continue; } if (i < m_items.Count) { m_items[i].SetData(index); if (useClickEvent || autoSelectFirst) { SetToggle(i, m_selectedData == index); } } else { var go = Instantiate(m_goItemRender) as GameObject; go.name = m_goItemRender.name + i; go.transform.SetParent(m_content, false); go.SetActive(true); var script = go.AddComponent(m_itemRenderType) as ItemRender; if (!go.activeInHierarchy) { script.Awake(); } script.SetData(index); script.m_owner = this; script.gameObj = go; if (useClickEvent) { UGUIClickHandler.Get(go, m_itemClickSound).onPointerClick += OnItemClick; } if (m_toggleGroup != null) { var toggle = go.GetComponent <Toggle>(); if (toggle != null) { toggle.group = m_toggleGroup; //使用循环模式的话不能用渐变效果,否则视觉上会出现破绽 if (useLoopItems) { toggle.toggleTransition = Toggle.ToggleTransition.None; } } } m_items.Add(script); } } }
public override void OnDestroy() { UGUIClickHandler.Get(startBtn).RemoveAllHandler(); Resources.UnloadUnusedAssets(); }
public override void InitEvent() { //这里初始化事件 UGUIClickHandler.Get(startBtn).onPointerClick += delegate { onClickStartBtn(); }; }
private void UpdateItems() { var itemLength = useLoopItems ? m_viewItemCount * ConstraintCount + CacheCount : m_data.Length; itemLength = Mathf.Min(itemLength, m_data.Length); for (var i = itemLength; i < m_items.Count; i++) { Destroy(m_items[i].gameObject); m_items[i] = null; } for (int i = m_items.Count - 1; i >= 0; i--) { if (m_items[i] == null) { m_items.RemoveAt(i); } } for (int i = 0; i < itemLength; i++) { var index = m_startIndex + i; if (index >= m_data.Length || index < 0) { continue; } if (i < m_items.Count) { m_items[i].SetData(m_data[index]); if (useClickEvent || autoSelectFirst) { SetToggle(i, m_selectedData == m_data[index]); } } else { var go = Instantiate(m_goItemRender) as GameObject; go.name = m_goItemRender.name; go.transform.SetParent(m_content, false); go.SetActive(true); var script = go.AddComponent(m_itemRenderType) as ItemRender; if (!go.activeInHierarchy) { script.Awake(); } script.SetData(m_data[index]); script.m_owner = this; if (useClickEvent) { UGUIClickHandler.Get(go).onPointerClick += OnItemClick; } if (m_toggleGroup != null) { var toggle = go.GetComponent <Toggle>(); if (toggle != null) { toggle.group = m_toggleGroup; //使用循环模式的话不能用渐变效果,否则视觉上会出现破绽 if (useLoopItems) { toggle.toggleTransition = Toggle.ToggleTransition.None; } } } m_items.Add(script); } } }