protected override void OnRectTransformDimensionsChange() { if (gameObject.activeInHierarchy) { // prevent double dirtying... if (CanvasUpdateRegistry.IsRebuildingLayout()) { SetVerticesDirty(); } else { SetVerticesDirty(); SetLayoutDirty(); } } }
/// <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(); }
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; m_Tracker.Clear(); m_Velocity = Vector2.zero; LayoutRebuilder.MarkLayoutForRebuild(rectTransform); base.OnDisable(); }
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(); } var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this); if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying) { CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this); } }