public void CreateBaseUI() { GameObject b = mUI.CreateElement(mUI.Canvas, "uiBase"); b.transform.SetAsFirstSibling(); mUI.SetRectFillParent(b); mUI.AddImage(b, mUI.PrimaryBackground); GameObject vl = mUI.CreateElement(b, "vertLayout"); mUI.SetRectFillParent(vl); mUI.AddVerticalLayout(vl); GameObject sp1 = mUI.CreateElement(vl, "spacer"); mUI.AddLayout(sp1, -1, 10, 1.0f, -1); mGlobalTabs = mUI.CreateTabView(vl); mPrimaryContent = mUI.CreateElement(vl, "primaryWindow"); mUI.AddLayout(mPrimaryContent, -1, -1, 1.0f, 1.0f); mUI.AddImage(mPrimaryContent, mUI.WindowBackground); mUI.AddVerticalLayout(mPrimaryContent); mPrimaryContent.GetComponent <VerticalLayoutGroup>().padding = new RectOffset(4, 4, 4, 4); mPrimaryContent.GetComponent <VerticalLayoutGroup>().spacing = 4; }
public override void Init(CUIManager Context) { base.Init(Context); CToolkitUI ui = CGame.ToolkitUI; _base = ui.CreateElement(CGame.UIManager.mMenuLayer, "mainMenuBase"); _base.AddComponent <Image>().color = new Color(0.2f, 0.2f, 0.2f, 1.0f); ui.SetRectFillParent(_base); logo = ui.CreateElement(_base, "logo"); Image logoImage = logo.AddComponent <Image>(); logoImage.sprite = CGame.PrimaryResources.Sprites[1]; //logoImage.SetNativeSize(); logoImage.preserveAspect = true; logoImage.color = new Color(1.0f, 1.0f, 1.0f); //logo.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0); logo.GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 0.0f); logo.GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 1.0f); logo.GetComponent <RectTransform>().pivot = new Vector2(0.5f, 0.5f); logo.GetComponent <RectTransform>().sizeDelta = new Vector2(256, 256); logo.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); _splashBase = ui.CreateElement(CGame.UIManager.mMenuLayer, "splashBase"); _splashBase.AddComponent <Image>().color = new Color(0.2f, 0.2f, 0.2f, 0.0f); ui.SetRectFillParent(_splashBase); CGame.UIManager.PlayMusic(0); }
public CContextMenu(CToolkitUI Toolkit, CGameUIStyle Style, GameObject Root) { _ui = Toolkit; _style = Style; _root = _ui.CreateElement(Root, "contextMenuRoot"); _ui.AddImage(_root, new Color(0, 0, 0, 0.0f)); _ui.SetRectFillParent(_root); _root.AddComponent <CUIContextMenuOverlay>(); _contextMenu = _ui.CreateElement(_root, "contextMenu"); _ui.AddImage(_contextMenu, _style.TooltipBackground); _ui.SetTransform(_contextMenu, 0, 0, 128, 256); _ui.AddVerticalLayout(_contextMenu, new RectOffset(3, 3, 3, 3), 3); _contextMenu.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0); _contextMenu.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0); ContentSizeFitter fitter = _contextMenu.AddComponent <ContentSizeFitter>(); fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; Hide(); }
public CUIManager(CToolkitUI Toolkit, CGameUIStyle Style) { _ui = Toolkit; _style = Style; _uiRes = CGame.UIResources; mPoseRT = new RenderTexture(512, 512, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); mPoseRT.antiAliasing = 8; gameUI = _ui.CreateElement(_ui.Canvas, "gameUI"); _ui.SetRectFillParent(gameUI); gameUI.transform.SetAsFirstSibling(); underlayLayer = _ui.CreateElement(gameUI, "underlayLayer"); _ui.SetRectFillParent(underlayLayer); CanvasGroup cgroup = underlayLayer.AddComponent <CanvasGroup>(); cgroup.blocksRaycasts = false; primaryLayer = _ui.CreateElement(gameUI, "primaryLayer"); mPrimaryLayerGroup = primaryLayer.AddComponent <CanvasGroup>(); mPrimaryLayerGroup.alpha = 1.0f; _ui.SetRectFillParent(primaryLayer); overlayLayer = _ui.CreateElement(gameUI, "overlayLayer"); _ui.SetRectFillParent(overlayLayer); cgroup = overlayLayer.AddComponent <CanvasGroup>(); cgroup.blocksRaycasts = false; cutsceneLayer = _ui.CreateElement(gameUI, "cutsceneLayer"); _ui.SetRectFillParent(cutsceneLayer); GameObject letterBox = _ui.CreateElement(cutsceneLayer); _ui.SetAnchors(letterBox, new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 1)); _ui.AddImage(letterBox, _style.ThemeColorC); _ui.SetTransform(letterBox, 0, 0, 0, 54); letterBox = _ui.CreateElement(cutsceneLayer); _ui.SetAnchors(letterBox, new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 0)); _ui.AddImage(letterBox, _style.ThemeColorC); _ui.SetTransform(letterBox, 0, 0, 0, 54); mCutsceneLayerGroup = cutsceneLayer.AddComponent <CanvasGroup>(); mCutsceneLayerGroup.alpha = 0.0f; mCutsceneLayerGroup.blocksRaycasts = false; /* * fadeOverLayer = _ui.CreateElement(gameUI, "fadeOverLayer"); * _ui.SetRectFillParent(fadeOverLayer); * _ui.AddImage(fadeOverLayer, Color.black); */ contextMenuLayer = _ui.CreateElement(gameUI, "contextMenuLayer"); _ui.SetRectFillParent(contextMenuLayer); mMenuLayer = _ui.CreateElement(gameUI, "menuLayer"); _ui.SetRectFillParent(mMenuLayer); GameObject productText = _ui.CreateTextElement(overlayLayer, CGame.PRODUCT_NAME + " (" + CGame.VERSION_MAJOR + "." + CGame.VERSION_MINOR + ") " + CGame.VERSION_NAME, "productText", CToolkitUI.ETextStyle.TS_HEADING); _ui.SetAnchors(productText, new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 1)); _ui.SetTransform(productText, 5, 0, -10, 20); productText.GetComponent <Text>().alignment = TextAnchor.MiddleRight; mContextMenu = new CContextMenu(Toolkit, Style, contextMenuLayer); mTooltip = new CTooltip(Toolkit, Style, overlayLayer); SetupForGameSession(); }