public static MagicUIImageControl Create() { GameObject go = new GameObject(); MagicUIImageControl result = go.AddComponent <MagicUIImageControl>(); return(result); }
public static MagicUIControl CreateFromMarkup(string id, JSONObject markup, IMagicUIPanel page) { DebugManager.Log("...{0}: {1}", id, markup); MagicUIControl.ControlType type = markup.GetControlType(); MagicUIControl control = null; switch (type) { case ControlType.Label: control = MagicUILabelControl.Create(); break; case ControlType.Image: control = MagicUIImageControl.Create(); break; case ControlType.Button: control = MagicUIButton.Create(); break; case ControlType.Container: control = MagicUIContainer.Create(); break; case ControlType.Rectangle: control = MagicUIRectangle.Create(); break; case ControlType.Checkbox: control = MagicUICheckbox.Create(); break; case ControlType.TextBox: control = MagicUITextBox.Create(); break; case ControlType.Slider: control = MagicUISlider.Create(); break; default: break; } if (control != null) { control.name = id; control.setContainer(page); control.initialize(markup); control.setExtents(control.calculateExtents(markup.GetRect(), markup.GetAnchors())); int z = markup.GetIntSafely("zOrder", 0); control.setZOrder(z * 10); int link = markup.GetIntSafely("link", int.MinValue); if (link >= -1) { control.setLink(link); } if (control is IMagicUIPanel) { ((IMagicUIPanel)control).Populate(markup["contents"]["children"].list); } control.register(); } return(null); }