public override void Initialize() { base.Initialize(); if (_configuration.MainCanvas) { var canvas = _factoryService.Instantiate(_configuration.MainCanvas); _mainCanvas = canvas.GetComponent <RectTransform>(); _uiScreenBlocker = _factoryService.Instantiate(_configuration.UIScreenBlocker, _mainCanvas.transform); UnityEngine.Object.DontDestroyOnLoad(_mainCanvas); var canvasElem = canvas.GetComponent <Canvas>(); if (canvasElem.renderMode == RenderMode.ScreenSpaceCamera) { canvasElem.worldCamera = Camera.main; } _renderPriorityCanvas.Add(UIType.Dialog, canvas.dialogContainer); _renderPriorityCanvas.Add(UIType.Panel, canvas.panelContainer); _renderPriorityCanvas.Add(UIType.Widget, canvas.widgetContainer); } }
public void CreateMainCanvas(UICanvas canvas) { _mainCanvas = canvas.GetComponent <RectTransform>(); _uiScreenBlocker = _factoryService.Instantiate(_configuration.UIScreenBlocker, _mainCanvas.transform); MainCanvas = canvas.GetComponent <Canvas>(); if (MainCanvas.renderMode == RenderMode.ScreenSpaceCamera) { MainCanvas.worldCamera = Camera.main; } _renderPriorityCanvas.Clear(); _renderPriorityCanvas.Add(UIType.Dialog, canvas.DialogContainer); _renderPriorityCanvas.Add(UIType.Panel, canvas.PanelContainer); _renderPriorityCanvas.Add(UIType.Widget, canvas.WidgetContainer); }