コード例 #1
0
        public virtual void SetVisable(bool visible)
        {
            if (!visible && m_Visable)
            {
                Vector3 setPos = new Vector3(gameObject.transform.localPosition.x, quadScreenHeight, gameObject.transform.localPosition.z);
                posY = gameObject.transform.localPosition.y;
                gameObject.transform.localPosition = setPos;
                m_Visable = !m_Visable;

                BlankClickDestroy blk = gameObject.GetComponent <BlankClickDestroy>();
                if (blk != null)
                {
                    blk.SetButtonClickable(visible);
                }
            }
            if (visible && !m_Visable)
            {
                Vector3 setPos = new Vector3(gameObject.transform.localPosition.x, posY, gameObject.transform.localPosition.z);
                gameObject.transform.localPosition = setPos;
                m_Visable = !m_Visable;

                BlankClickDestroy blk = gameObject.GetComponent <BlankClickDestroy>();
                if (blk != null)
                {
                    blk.SetButtonClickable(visible);
                }
            }
        }
コード例 #2
0
        protected override void InitUI()
        {
            base.InitUI();
            hasInitUi = true;

            if (GetComponent <CanvasGroup>() == null)
            {
                cg = gameObject.AddComponent <CanvasGroup>();  //添加这个属性控制透明度
            }
            InitButtonEvent();

            parentCanvas     = GetComponentInParent <Canvas>();
            parentCanvasName = parentCanvas.name;

            //就算是不点击空白处消失,也要把空白处补上。省的点击事件透传到底层面板去
            BlankClickDestroy blankAutoDestroy = gameObject.GetComponent <BlankClickDestroy>();

            if (blankAutoDestroy == null)
            {
                blankAutoDestroy = gameObject.AddComponent <BlankClickDestroy>();
            }

            if (clickBlankAutoClose)
            {
                blankAutoDestroy.onBlankClick.AddListener(this.Dispose);
            }
        }