コード例 #1
0
        protected override void OnValidate()
        {
            base.OnValidate();
            Set(m_IsOn, false);
            PlayEffect(toggleTransition == ToggleTransition.None);
#if UNITY_2018_3_OR_NEWER
            if (!Application.isPlaying)
#else
            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
#endif
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #2
0
        private static void MarkLayoutRootForRebuild(RectTransform controller)
        {
            if (controller == null)
            {
                return;
            }

            var rebuilder = s_Rebuilders.Get();

            rebuilder.Initialize(controller);
            if (!CanvasUpdateRegistry.TryRegisterCanvasElementForLayoutRebuild(rebuilder))
            {
                s_Rebuilders.Release(rebuilder);
            }
        }
コード例 #3
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (m_HorizontalScrollbar)
            {
                m_HorizontalScrollbar.onValueChanged.AddListener(SetHorizontalNormalizedPosition);
            }
            if (m_VerticalScrollbar)
            {
                m_VerticalScrollbar.onValueChanged.AddListener(SetVerticalNormalizedPosition);
            }

            CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
        }
コード例 #4
0
        protected override void OnDestroy()
        {
#if UNITY_EDITOR
            GraphicRebuildTracker.UnTrackGraphic(this);
#endif
            GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
            CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this);
            if (m_CachedMesh)
            {
                Destroy(m_CachedMesh);
            }
            m_CachedMesh = null;

            base.OnDestroy();
        }
コード例 #5
0
        private static void MarkLayoutRootForRebuild(RectTransform controller)
        {
            if ((UnityEngine.Object)controller == (UnityEngine.Object)null)
            {
                return;
            }
            LayoutRebuilder element = LayoutRebuilder.s_Rebuilders.Get();

            element.Initialize(controller);
            if (CanvasUpdateRegistry.TryRegisterCanvasElementForLayoutRebuild((ICanvasElement)element))
            {
                return;
            }
            LayoutRebuilder.s_Rebuilders.Release(element);
        }
コード例 #6
0
ファイル: Graphic.cs プロジェクト: sneakquie/UnityDecompiled
 protected override void OnRectTransformDimensionsChange()
 {
     if (base.gameObject.activeInHierarchy)
     {
         if (CanvasUpdateRegistry.IsRebuildingLayout())
         {
             this.SetVerticesDirty();
         }
         else
         {
             this.SetVerticesDirty();
             this.SetLayoutDirty();
         }
     }
 }
コード例 #7
0
ファイル: Graphic.cs プロジェクト: gdzzzyyy/UGUIlok
        public virtual void SetMaterialDirty()
        {
            if (!IsActive())
            {
                return;
            }

            m_MaterialDirty = true;
            CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);

            if (m_OnDirtyMaterialCallback != null)
            {
                m_OnDirtyMaterialCallback();
            }
        }
コード例 #8
0
        /// <summary>
        /// Clear references.
        /// </summary>
        protected override void OnDisable()
        {
#if UNITY_EDITOR
            GraphicRebuildTracker.UnTrackGraphic(this);
#endif
            GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
            CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this);

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

            LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
            base.OnDisable();
        }
コード例 #9
0
 protected override void OnRectTransformDimensionsChange()
 {
     if (gameObject.activeInHierarchy)
     {
         // prevent double dirtying...
         if (CanvasUpdateRegistry.IsRebuildingLayout())
         {
             SetVerticesDirty();
         }
         else
         {
             SetVerticesDirty();
             SetLayoutDirty();
         }
     }
 }
コード例 #10
0
ファイル: Scrollbar.cs プロジェクト: NetherDrk/Eternal-Empire
 protected override void OnValidate()
 {
     base.OnValidate();
     this.m_Size = Mathf.Clamp01(this.m_Size);
     if (this.IsActive())
     {
         this.UpdateCachedReferences();
         this.Set(this.m_Value, false);
         this.UpdateVisuals();
     }
     if (PrefabUtility.GetPrefabType((UnityEngine.Object) this) == PrefabType.Prefab || Application.isPlaying)
     {
         return;
     }
     CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild((ICanvasElement)this);
 }
コード例 #11
0
        protected override void OnDisable()
        {
            CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this);

            if (m_HorizontalScrollbar)
            {
                m_HorizontalScrollbar.onValueChanged.RemoveListener(SetHorizontalNormalizedPosition);
            }
            if (m_VerticalScrollbar)
            {
                m_VerticalScrollbar.onValueChanged.RemoveListener(SetVerticalNormalizedPosition);
            }

            m_HasRebuiltLayout = false;
            base.OnDisable();
        }
コード例 #12
0
        protected override void OnValidate()
        {
            base.OnValidate();
            Set(m_IsOn, false);
            PlayEffect(toggleTransition == ToggleTransition.None);

#pragma warning disable CS0618 // Type or member is obsolete
            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
#pragma warning restore CS0618 // Type or member is obsolete
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #13
0
ファイル: LayoutGroup.cs プロジェクト: Vin129/Unity_UGUI
        protected void SetDirty()
        {
            if (!IsActive())
            {
                return;
            }

            if (!CanvasUpdateRegistry.IsRebuildingLayout())
            {
                LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
            }
            else
            {
                StartCoroutine(DelayedSetDirty(rectTransform));
            }
        }
コード例 #14
0
ファイル: Graphic.cs プロジェクト: jiahaodev/UGUI
        /// <summary>
        /// Mark the vertices as dirty and needing rebuilt.
        /// </summary>
        /// <remarks>
        /// Send a OnDirtyVertsCallback notification if any elements are registered. See RegisterDirtyVerticesCallback
        /// </remarks>
        public virtual void SetVerticesDirty()
        {
            if (!IsActive())
            {
                return;
            }

            m_VertsDirty = true;
            //加入待渲染队列
            CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);

            if (m_OnDirtyVertsCallback != null)
            {
                m_OnDirtyVertsCallback();
            }
        }
コード例 #15
0
        protected override void OnValidate()
        {
            base.OnValidate();

            size = size;

            UpdateCachedReferences();
            Set(m_Value, false);
            // Update rects since other things might affect them even if value didn't change.
            UpdateVisuals();
            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);

            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #16
0
 protected override void OnDisable()
 {
     CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this);
     if (this.m_HorizontalScrollbar)
     {
         this.m_HorizontalScrollbar.onValueChanged.RemoveListener(new UnityAction <float>(this.SetHorizontalNormalizedPosition));
     }
     if (this.m_VerticalScrollbar)
     {
         this.m_VerticalScrollbar.onValueChanged.RemoveListener(new UnityAction <float>(this.SetVerticalNormalizedPosition));
     }
     this.m_HasRebuiltLayout = false;
     this.m_Tracker.Clear();
     this.m_Velocity = Vector2.zero;
     LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform);
     base.OnDisable();
 }
コード例 #17
0
ファイル: Scrollbar.cs プロジェクト: zzrx79/UnityDecompiled
        protected override void OnValidate()
        {
            base.OnValidate();
            this.m_Size = Mathf.Clamp01(this.m_Size);
            if (this.IsActive())
            {
                this.UpdateCachedReferences();
                this.Set(this.m_Value, false);
                this.UpdateVisuals();
            }
            PrefabType prefabType = PrefabUtility.GetPrefabType(this);

            if (prefabType != PrefabType.Prefab && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #18
0
        protected override void OnValidate()
        {
            base.OnValidate();
            Set(m_IsOn, false);
            if (!IsActive())
            {
                return;
            }
            PlayEffect(toggleTransition == Ease.None);

            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);

            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #19
0
ファイル: Text.cs プロジェクト: twenty0ne/UnityDecompiled
 /// <summary>
 /// <para>Called by the [FontUpdateTracker] when the texture associated with a font is modified.</para>
 /// </summary>
 public void FontTextureChanged()
 {
     if ((this != null) && !this.m_DisableFontTextureRebuiltCallback)
     {
         this.cachedTextGenerator.Invalidate();
         if (this.IsActive())
         {
             if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
             {
                 this.UpdateGeometry();
             }
             else
             {
                 this.SetAllDirty();
             }
         }
     }
 }
コード例 #20
0
ファイル: BoxSlider.cs プロジェクト: senyaa1/CuiBuilder
        protected override void OnValidate()
        {
            base.OnValidate();

            if (wholeNumbers)
            {
                m_MinValue = Mathf.Round(m_MinValue);
                m_MaxValue = Mathf.Round(m_MaxValue);
            }
            UpdateCachedReferences();

            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);

            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #21
0
ファイル: Text.cs プロジェクト: Hengle/JellyTerain
 public void FontTextureChanged()
 {
     if (!this || m_DisableFontTextureRebuiltCallback)
     {
         return;
     }
     cachedTextGenerator.Invalidate();
     if (IsActive())
     {
         if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
         {
             UpdateGeometry();
         }
         else
         {
             SetAllDirty();
         }
     }
 }
コード例 #22
0
ファイル: Slider.cs プロジェクト: randomize/VimConfig
 protected override void OnValidate()
 {
     base.OnValidate();
     if (this.wholeNumbers)
     {
         this.m_MinValue = Mathf.Round(this.m_MinValue);
         this.m_MaxValue = Mathf.Round(this.m_MaxValue);
     }
     if (this.IsActive())
     {
         this.UpdateCachedReferences();
         this.Set(this.m_Value, false);
         this.UpdateVisuals();
     }
     if ((PrefabUtility.GetPrefabType(this) != PrefabType.Prefab) && !Application.isPlaying)
     {
         CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
     }
 }
コード例 #23
0
        protected override void OnValidate()
        {
            base.OnValidate();

            m_Size = Mathf.Clamp01(m_Size);

            //This can be invoked before OnEnabled is called. So we shouldn't be accessing other objects, before OnEnable is called.
            if (IsActive())
            {
                UpdateCachedReferences();
                Set(m_Value, false);
                // Update rects since other things might affect them even if value didn't change.
                UpdateVisuals();
            }

            if (!UnityEditor.PrefabUtility.IsPartOfPrefabAsset(this) && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #24
0
        protected override void OnDisable()
        {
            CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this);

            if (m_HorizontalScrollbar)
            {
                m_HorizontalScrollbar.onValueChanged.RemoveListener(SetHorizontalNormalizedPosition);
            }
            if (m_VerticalScrollbar)
            {
                m_VerticalScrollbar.onValueChanged.RemoveListener(SetVerticalNormalizedPosition);
            }

            m_Dragging         = false;
            m_Scrolling        = false;
            m_HasRebuiltLayout = false;
            m_Tracker.Clear();
            m_Velocity = Vector2.zero;
            LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
            base.OnDisable();
        }
コード例 #25
0
        /// <summary>
        /// 标记根节点重新布局
        /// </summary>
        /// <param name="controller"></param>
        private static void MarkLayoutRootForRebuild(RectTransform controller)
        {
            if (controller == null)
            {
                return;
            }

            var rebuilder = s_Rebuilders.Get();

            rebuilder.Initialize(controller);
            //如果注册rebuild队列中已经包含了这个gameobject,就直接进行释放回收
            //不包含的话,就注册进去,暂时不回收
            // 19/5 2020 Image 源码学习
            //这里注册的到rebuild队列的对象类型为继承自ICanvasElement的LayoutRebuilder
            //主要是受s_rebuilders的影响,这样在CanvasUpdateRegistry中进行layoutRebuid的时候调用的就是LayoutRebuilder重写的rebuild方法了
            //TryRegisterCanvasElementForLayoutRebuild这个方法使用了多态的概念
            if (!CanvasUpdateRegistry.TryRegisterCanvasElementForLayoutRebuild(rebuilder))
            {
                s_Rebuilders.Release(rebuilder);
            }
        }
コード例 #26
0
        protected override void OnValidate()
        {
            base.OnValidate();

            if (wholeNumbers)
            {
                m_MinValue = Mathf.Round(m_MinValue);
                m_MaxValue = Mathf.Round(m_MaxValue);
            }
            UpdateCachedReferences();
            SetX(m_ValueX, false);
            SetY(m_ValueY, false);
            // Update rects since other things might affect them even if value didn't change.
            UpdateVisuals();

            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);

            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #27
0
 protected virtual void OnDisable()
 {
     if (Application.isQuitting != null)
     {
         return;
     }
     CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild((ICanvasElement)this);
     if (Object.op_Implicit((Object)this.m_HorizontalScrollbar))
     {
         // ISSUE: method pointer
         ((UnityEvent <float>) this.m_HorizontalScrollbar.get_onValueChanged()).RemoveListener(new UnityAction <float>((object)this, __methodptr(SetHorizontalNormalizedPosition)));
     }
     if (Object.op_Implicit((Object)this.m_VerticalScrollbar))
     {
         // ISSUE: method pointer
         ((UnityEvent <float>) this.m_VerticalScrollbar.get_onValueChanged()).RemoveListener(new UnityAction <float>((object)this, __methodptr(SetVerticalNormalizedPosition)));
     }
     this.m_HasRebuiltLayout = false;
     ((DrivenRectTransformTracker) ref this.m_Tracker).Clear();
     LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform);
     base.OnDisable();
 }
コード例 #28
0
        protected override void OnValidate()
        {
            base.OnValidate();

            if (wholeNumbers)
            {
                m_MinValue = Mathf.Round(m_MinValue);
                m_MaxValue = Mathf.Round(m_MaxValue);
            }

            //Onvalidate is called before OnEnabled. We need to make sure not to touch any other objects before OnEnable is run.
            if (IsActive())
            {
                UpdateCachedReferences();
                Set(m_Value, false);
                // Update rects since other things might affect them even if value didn't change.
                UpdateVisuals();
            }

            if (Application.isPlaying)
            {
                return;
            }

#if UNITY_2018_3_OR_NEWER
            var prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(this);
            if (prefabType == UnityEditor.PrefabAssetType.Regular)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
#else
            var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
            if (prefabType != UnityEditor.PrefabType.Prefab)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
#endif
        }
コード例 #29
0
        protected override void OnValidate()
        {
            base.OnValidate();

            if (wholeNumbers)
            {
                m_MinValue = Mathf.Round(m_MinValue);
                m_MaxValue = Mathf.Round(m_MaxValue);
            }

            //Onvalidate is called before OnEnabled. We need to make sure not to touch any other objects before OnEnable is run.
            if (IsActive())
            {
                UpdateCachedReferences();
                // Update rects in next update since other things might affect them even if value didn't change.
                m_DelayedUpdateVisuals = true;
            }

            if (!UnityEditor.PrefabUtility.IsPartOfPrefabAsset(this) && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
コード例 #30
0
 // Token: 0x06002971 RID: 10609 RVA: 0x00459518 File Offset: 0x00457718
 protected override void OnEnable()
 {
     base.OnEnable();
     if (this.m_HorizontalScrollbar)
     {
         this.m_HorizontalScrollbar.onValueChanged.AddListener(new UnityAction <float>(this.SetHorizontalNormalizedPosition));
     }
     if (this.m_VerticalScrollbar)
     {
         this.m_VerticalScrollbar.onValueChanged.AddListener(new UnityAction <float>(this.SetVerticalNormalizedPosition));
     }
     CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
     if (this.bPageMoving)
     {
         this.setCurrentIndex(this.NowPageIndex, true);
         if (this.m_PageMoveHandler != null)
         {
             this.m_PageMoveHandler.EndPageMove();
         }
         this.MoveEndX    = -1f;
         this.bPageMoving = false;
     }
 }