UICanvas
Code examples to perform various interactions with the UICanvas
Is Master Canvas
Check if a target UICanvas is the Master Canvas. An UICanvas is considered as the Master Canvas if its canvas name is set to ‘MasterCanvas’ and if it has been registered (an recognized) by the system as such.
using Doozy.Engine.UI; using UnityEngine; public class ExampleClass : MonoBehaviour { public UICanvas MyCanvas; private void Start() { bool isMasterCanvas = MyCanvas.IsMasterCanvas; Debug.Log("The target UICanvas " + (isMasterCanvas ? "is" : "is not") + " the Master Canvas."); } }
Get Master Canvas
Get a reference to the UICanvas that is considered and used as the ‘MasterCanvas’. If no such UICanvas exists, one will be automatically created by default.
using Doozy.Engine.UI; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { UICanvas masterCanvas = UICanvas.GetMasterCanvas(); } }
Create UICanvas
Create a new UICanvas with a given canvas name and get a reference to it.
using Doozy.Engine.UI; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { UICanvas canvas = UICanvas.CreateUICanvas("MyNewCanvas"); } }
Get UICanvas
Get a reference to an UICanvas that has been registered in the UICanvas Database, that has the given canvas name. Note that if no UICanvas is found, it will return a null reference.
using Doozy.Engine.UI; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { UICanvas canvas = UICanvas.GetUICanvas("MyCanvas"); } }