//------------------------------------------------------------ // Game Framework // Copyright © 2013-2021 Jiang Yin. All rights reserved. // Homepage: https://gameframework.cn/ // Feedback: mailto:ellan@gameframework.cn //------------------------------------------------------------ using System; using UnityEngine; using UnityEngine.UI; namespace UnityGameFramework.Runtime { /// /// 默认界面组辅助器。 /// public class DsUIGroupHelper : UIGroupHelperBase { private Canvas _canvas; private CanvasScaler _canvasScale; private void Awake() { _canvas = this.gameObject.AddComponent(); _canvas.renderMode = RenderMode.ScreenSpaceCamera; _canvas.worldCamera = GameObject.FindWithTag("UiCamera").GetComponent(); _canvasScale = this.gameObject.AddComponent(); _canvasScale.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; _canvasScale.referenceResolution = new Vector2(1920, 1080); RectTransform rect = this.gameObject.GetOrAddComponent(); rect.anchoredPosition = new Vector2(0, 0); gameObject.AddComponent(); } private void Start() { if (this.gameObject.name.Equals("UI Group - Pop")) { GameObject obj=new GameObject("MoveItemContent"); obj.AddComponent().sizeDelta = new Vector2(1920, 1080); obj.transform.SetParent(this.transform); obj.transform.localPosition=Vector3.zero; obj.tag = "MoveItemContent"; } } /// /// 设置界面组深度。 /// /// 界面组深度。 public override void SetDepth(int depth) { _canvas.sortingOrder = depth; } } }