Ejemplo n.º 1
0
 public static void UnregisterGraphic(params Graphic[] toUnregister)
 {
     for (int i = 0; i < toUnregister.Length; i++)
     {
         GraphicRegistry.UnregisterGraphicForCanvas(toUnregister[i].canvas, toUnregister[i]);
     }
 }
Ejemplo n.º 2
0
 protected override void OnCanvasGroupChanged()
 {
     base.OnCanvasGroupChanged();
     if (!Application.isPlaying)
     {
         return;
     }
     if (_useRaycast)
     {
         var block = GetComponentInParent <CanvasGroup>().blocksRaycasts;
         raycastTarget = block;
         if (!block)
         {
             _unregistered = true;
             GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
         }
         else
         {
             if (_unregistered)
             {
                 GraphicRegistry.RegisterGraphicForCanvas(canvas, this);
             }
         }
     }
 }
Ejemplo n.º 3
0
 protected override void OnCanvasHierarchyChanged()
 {
     base.OnCanvasHierarchyChanged();
     if (!raycastTarget)
     {
         GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
     }
 }
Ejemplo n.º 4
0
 protected override void OnTransformParentChanged()
 {
     base.OnTransformParentChanged();
     if (!raycastTarget)
     {
         GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
     }
 }
Ejemplo n.º 5
0
 protected override void OnEnable()
 {
     base.OnEnable();
     if (!raycastTarget)
     {
         GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
     }
 }
Ejemplo n.º 6
0
    protected override void OnEnable()
    {
        base.OnEnable();
        if (!Application.isPlaying)
        {
            return;
        }

        if (!_useRaycast)
        {
            GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
        }
    }
Ejemplo n.º 7
0
    protected override void OnTransformParentChanged()
    {
        base.OnTransformParentChanged();
        if (!Application.isPlaying)
        {
            return;
        }

        if (!_useRaycast)
        {
            GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
        }
    }
Ejemplo n.º 8
0
        /// <summary>
        /// 优化 GraphicRaycaster.Raycast 避免CPU周期浪费
        /// </summary>
        public void OptimizeFrameGraphic()
        {
            for (int i = 0; i < this.m_frameCanvases.Length; ++i)
            {
                Canvas canvasInFrame = this.m_frameCanvases[i];

                IList <Graphic> canvasGraphics = GraphicRegistry.GetGraphicsForCanvas(canvasInFrame);

                for (int j = 0; j < canvasGraphics.Count; ++j)
                {
                    Graphic graphic = canvasGraphics[j];
                    if (!graphic.raycastTarget)
                    {
                        GraphicRegistry.UnregisterGraphicForCanvas(canvasInFrame, graphic);
                    }
                }
            }
        }
Ejemplo n.º 9
0
    public static int UnregisterGraphicForCanvas_s(IntPtr l)
    {
        int result;

        try
        {
            Canvas c;
            LuaObject.checkType <Canvas>(l, 1, out c);
            Graphic graphic;
            LuaObject.checkType <Graphic>(l, 2, out graphic);
            GraphicRegistry.UnregisterGraphicForCanvas(c, graphic);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Ejemplo n.º 10
0
        public void OnLeaveAnimationFinish()
        {
            IsShowed       = false;
            OnLeaveWorking = false;
            leaveCoroutine = null;
            if (_allGraphics != null)
            {
                for (int i = 0; i < _allGraphics.Length; i++)
                {
                    GraphicRegistry.UnregisterGraphicForCanvas(_allGraphics[i].canvas, _allGraphics[i]);
                }
            }
            //先 SetParent 就好除了被託管的
            if (DisableGameObjectOnComplete)
            {
                SetActive(false);
            }

            if (needPool == false)
            {
                return;
            }

            if (runtimePool != null)
            {
                runtimePool.QueueViewElementToRecovery(this);
                OnBeforeRecoveryToPool?.Invoke();
                OnBeforeRecoveryToPool = null;
                if (runtimeOverride != null)
                {
                    runtimeOverride.ResetToDefaultValues();
                }
            }
            else if (DestroyIfNoPool)
            {
                // if there is no runtimePool instance, destroy the viewelement.
                Destroy(gameObject);
            }
        }
 // Use this for initialization
 void Start()
 {
     GraphicRegistry.UnregisterGraphicForCanvas(StateManager.state.gui.canvas, GetComponent <Graphic> ());
 }
Ejemplo n.º 12
0
        public IEnumerator OnShowRunner(bool manual)
        {
            IsShowed = true;
            if (lifeCyclesObjects != null)
            {
                foreach (var item in lifeCyclesObjects.ToArray())
                {
                    try
                    {
                        item.OnBeforeShow();
                    }
                    catch (Exception ex) { ViewSystemLog.LogError(ex.ToString(), this); }
                }
            }

            SetActive(true);

            if (selfViewElementGroup != null)
            {
                if (selfViewElementGroup.OnlyManualMode && manual == false)
                {
                    if (gameObject.activeSelf)
                    {
                        SetActive(false);
                    }
                    goto END;
                }
                selfViewElementGroup.OnShowChild();
            }

            if (transition == TransitionType.Animator)
            {
                animator.Play(AnimationStateName_In);

                if (transition == TransitionType.Animator && hasLoopBool)
                {
                    animator.SetBool(ButtonAnimationBoolKey, true);
                }
            }
            else if (transition == TransitionType.CanvasGroupAlpha)
            {
                canvasGroup.alpha = 0;
                if (canvasGroupCoroutine != null)
                {
                    viewController.StopMicroCoroutine(canvasGroupCoroutine);
                }
                // canvasGroupCoroutine = viewController.StartMicroCoroutine(EaseMethods.EaseValue(
                //     canvasGroup.alpha,
                //     1,
                //     canvasInTime,
                //     EaseMethods.GetEase(canvasInEase),
                //     (v) =>
                //     {
                //         canvasGroup.alpha = v;
                //     },
                //     () =>
                //     {
                //         canvasGroupCoroutine = null;
                //     }
                //  ));
                canvasGroupCoroutine = viewController.StartMicroCoroutine(
                    EaseUtility.To(
                        canvasGroup.alpha,
                        1,
                        canvasInTime,
                        canvasInEase,
                        (v) =>
                {
                    canvasGroup.alpha = v;
                },
                        () =>
                {
                    canvasGroupCoroutine = null;
                }
                        )
                    );
            }
            else if (transition == TransitionType.Custom)
            {
                OnShowHandle.Invoke(null);
            }

END:
            if (lifeCyclesObjects != null)
            {
                foreach (var item in lifeCyclesObjects.ToArray())
                {
                    try
                    {
                        item.OnStartShow();
                    }
                    catch (Exception ex) { ViewSystemLog.LogError(ex.ToString(), this); }
                }
            }
            if (_allGraphics != null)
            {
                for (int i = 0; i < _allGraphics.Length; i++)
                {
                    if (_allGraphics[i].raycastTarget == false)
                    {
                        GraphicRegistry.UnregisterGraphicForCanvas(_allGraphics[i].canvas, _allGraphics[i]);
                    }
                }
            }
            showCoroutine = null;
            yield break;
        }
Ejemplo n.º 13
0
 public void DisableRayCast()
 {
     _useRaycast   = false;
     raycastTarget = false;
     GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
 }