Inheritance: MonoBehaviour
Ejemplo n.º 1
0
 public MenuItem(Texture2D normalState, Texture2D selectedState, OnSelectEvent onSelectEvent)
 {
     this.normalState   = normalState;
     this.selectedState = selectedState;
     this.onSelectEvent = onSelectEvent;
     isSelected         = false;
 }
    //
    #region 释放
    //add by chenfei 20150824
    void OnDestroy()
    {
        int iIndex = mFreeTrans.Count;

        mFreeTrans.InsertRange(mFreeTrans.Count, mDataToTrans.Values);
        for (int i = iIndex; i < mFreeTrans.Count; i++)
        {
            Transform trans = mFreeTrans[i];
            if (trans != null)
            {
                DestroyImmediate(trans.gameObject);
            }
        }
        mFreeTrans.Clear();
        mDataToTrans.Clear();

        if (null != mDataSource)
        {
            mDataSource.Clear();
        }

        mgridItem = null;

        mSelectItem = null;

        mfnOnChangeRow = null;

        fnonClickSubItem = null;

        SelectItem = null;
    }
Ejemplo n.º 3
0
 public override void OnSelect(BaseEventData eventData)
 {
     base.OnSelect(eventData);
     OnSelectEvent?.Invoke(eventData);
     if (scrollRect != null)
     {
         // FIXME This is for automatically scrolling the scroll view up and down, need to make sure it's working as intended.
         // TODO Adding left and right scrolling might also be nice.
         float         contentHeight  = scrollRect.content.rect.height;
         float         viewportHeight = scrollRect.viewport.rect.height;
         float         centerLineY    = eventData.selectedObject.transform.localPosition.y;
         RectTransform rectTransform  = eventData.selectedObject.GetComponent <RectTransform>();
         float         rectHeight     = rectTransform.rect.height;
         float         lowerBound     = centerLineY - (rectHeight * 1.0f);
         float         upperBound     = centerLineY + (rectHeight * 1.0f);
         float         lowerVisible   = (contentHeight - viewportHeight) * scrollRect.normalizedPosition.y - contentHeight;
         float         upperVisible   = lowerVisible + viewportHeight;
         float         desiredBoundY;
         if (upperBound > upperVisible)
         {
             desiredBoundY = upperBound - viewportHeight + (rectHeight * 1.0f);
         }
         else if (lowerBound < lowerVisible)
         {
             desiredBoundY = lowerBound - (rectHeight * 1.0f);
         }
         else
         {
             return;
         }
         float normalizedDesiredY = (desiredBoundY + contentHeight) / (contentHeight - viewportHeight);
         scrollRect.normalizedPosition = new Vector2(0.0f, Mathf.Clamp01(normalizedDesiredY));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 入口(构造函数)
        /// </summary>
        public CustomBar(OnSelectEvent onSelect = null)
        {
            this.m_onSelectEvent = onSelect;
            List <Setting_CustomBarCellData> settingList = UserSetting.Instance.GetCustomBarCellList();
            int count = settingList.Count;

            if (count > 0)
            {
                //恢复上次保存的状态
                for (int i = 0; i < count; i++)
                {
                    AddElement(settingList[i]);
                }
            }
            else
            {
                //默认创建一个页签
                AddElement();
            }
            ShowEditButton(true);

            int curSelectIndex = UserSetting.Instance.curSelectTabIndex < m_cellList.Count ? UserSetting.Instance.curSelectTabIndex : 0;

            m_cellList[curSelectIndex].UI_Button.Select();
            if (m_onSelectEvent != null)
            {
                m_onSelectEvent.Invoke(curSelectIndex);
            }
            UserSetting.Instance.curSelectTabIndex = curSelectIndex;
        }
Ejemplo n.º 5
0
 public void OnSelect()
 {
     if (displayed != null && selectable)
     {
         if (Selected)
         {
             Deselect();
         }
         else
         {
             selected = true;
             OnSelectEvent?.Invoke(this);
             selectionBorder?.SetActive(true);
         }
     }
 }
Ejemplo n.º 6
0
 public void SelectedAnswer()
 {
     OnSelectEvent?.Invoke(IsCorrect);
 }
Ejemplo n.º 7
0
 public PopupItem(string text, OnSelectEvent onSelect, LoadLevelPopup parent)
 {
     this.text     = text;
     this.onSelect = onSelect;
     this.parent   = parent;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// On select.
 /// </summary>
 /// <param name="eventData">Pointer event data.</param>
 public void OnSelect(BaseEventData eventData)
 {
     OnSelectEvent?.Invoke(eventData);
 }