public void OnAwake() { Canvas = Instantiate <Canvas>(null); verticalLayout = Instantiate <VerticalLayoutGroup>(Canvas); verticalLayout.RectTransform.Size = new Point(Screen.Width, Screen.Height); verticalLayout.RectTransform.Alignment = Alignment.TopLeft; verticalLayout.RectTransform.Pivot = new Point(1f, 1f); verticalLayout.RectTransform.Padding = new Padding(10f, 10f); verticalLayout.Spacing = 5; // Create UI. var header = CreateText((element) => { element.Text.Content = "Entity Spawner"; element.Text.Height = 24; element.RectTransform.Height = 40; }); gameObjectInfo = CreateText(); controlsInfo = CreateText(); controlsInfo.Text.Content = "Left-click to destroy an Entity"; entityInfoElement = CreateText((element) => { element.Text.Color = Color.Yellow; }); // Assign text elements to vertical layout so they get displayed in rows. verticalLayout.Add(header); verticalLayout.Add(gameObjectInfo); verticalLayout.Add(controlsInfo); verticalLayout.Add(entityInfoElement); }
public TextElement AddInfo(string label, Action <TextElement> onCreate = null) { var instance = AddText(_verticalLayout); instance.Text.Content = label; _verticalLayout.Add(instance); if (onCreate != null) { onCreate(instance); } return(instance); }
public void OnAwake() { ActiveChanged += LevelUI_ActiveChanged; _verticalLayout = Instantiate <VerticalLayoutGroup>(Parent); _verticalLayout.RectTransform.Size = new Point(600f, Screen.Height); _verticalLayout.RectTransform.Alignment = Alignment.TopLeft; _verticalLayout.RectTransform.Pivot = new Point(1f, 1f); _verticalLayout.RectTransform.Padding = new Padding(10f, 10f); _verticalLayout.Spacing = 5; // Create UI. _header = AddText(_verticalLayout, (element) => { element.Text.Content = "Header"; element.Text.Height = 32; element.RectTransform.Height = 40; }); // Assign text elements to vertical layout so they get displayed in rows. _verticalLayout.Add(_header); _footer = Instantiate <TextElement>(Parent); _footer.Text.Content = ""; _footer.Text.Height = 32; _footer.RectTransform.Alignment = Alignment.Bottom; _footer.Text.Alignment = Alignment.Center; _footer.RectTransform.Padding = new Padding(0f, -40f); }