//------------------------------------------------------------ // Game Framework // Copyright © 2013-2021 Jiang Yin. All rights reserved. // Homepage: https://gameframework.cn/ // Feedback: mailto:ellan@gameframework.cn //------------------------------------------------------------ using UnityEngine; using UnityEngine.UI; using UnityGameFramework.Runtime; namespace MetaClient { /// /// uGUI 界面组辅助器。 /// public class UGuiGroupHelper : UIGroupHelperBase { public const int DepthFactor = 10000; private int m_Depth = 0; private Canvas m_CachedCanvas = null; /// /// 设置界面组深度。 /// /// 界面组深度。 public override void SetDepth(int depth) { m_Depth = depth; m_CachedCanvas.overrideSorting = true; m_CachedCanvas.sortingOrder = DepthFactor * depth; } private void Awake() { m_CachedCanvas = gameObject.GetOrAddComponent(); gameObject.GetOrAddComponent(); } private void Start() { m_CachedCanvas.overrideSorting = true; m_CachedCanvas.sortingOrder = DepthFactor * m_Depth; RectTransform transform = GetComponent(); transform.anchorMin = Vector2.zero; transform.anchorMax = Vector2.one; transform.anchoredPosition = Vector2.zero; transform.sizeDelta = Vector2.zero; } } }