public CanvasPanel AddPanel(string name, Texture2D tex, Vector2 pos, Vector2 sz, Rect bgSubSection)
        {
            CanvasPanel panel = new CanvasPanel(canvas, tex, position + pos, sz, bgSubSection);

            panels.Add(name, panel);

            return(panel);
        }
Exemple #2
0
        public static void BuildMenu(GameObject canvas)
        {
            Texture2D panelImg     = GUIController.Instance.images["Panel_BG"];
            float     toggleHeight = 30;

            float x = Screen.width / 2.0f - panelImg.width / 2.0f - 30.0f;
            float y = 200.0f + 35f;

            if (!GameObject.Find("EventSystem"))
            {
                GameObject eventSystemObj = new GameObject("EventSystem");

                EventSystem eventSystem = eventSystemObj.AddComponent <EventSystem>();
                eventSystem.sendNavigationEvents = true;
                eventSystem.pixelDragThreshold   = 10;

                eventSystemObj.AddComponent <StandaloneInputModule>();

                Object.DontDestroyOnLoad(eventSystemObj);
            }

            Panel = new CanvasPanel(
                canvas,
                panelImg,
                new Vector2(x, y),
                Vector2.zero,
                new Rect(0, 0, panelImg.width, panelImg.height)
                );

            Panel.AddText(
                "Options Text",
                "Options",
                new Vector2(x, y),
                new Vector2(panelImg.width, 60),
                GUIController.Instance.trajanNormal,
                24,
                FontStyle.Bold,
                TextAnchor.MiddleCenter
                );
            y += 70;

            _pvpToggle = Panel.AddToggle(
                "Toggle PvP",
                GUIController.Instance.images["Toggle_BG"],
                GUIController.Instance.images["Checkmark"],
                new Vector2(x, y),
                new Vector2(panelImg.width, 20),
                new Vector2(-60, 0),
                new Rect(0, 0, 150, 20),
                TogglePvP,
                GUIController.Instance.trajanNormal,
                "Enable PvP",
                16
                );
            y += toggleHeight;

            _pvpToggle = Panel.AddToggle(
                "Toggle Teams",
                GUIController.Instance.images["Toggle_BG"],
                GUIController.Instance.images["Checkmark"],
                new Vector2(x, y),
                new Vector2(panelImg.width, 20),
                new Vector2(-60, 0),
                new Rect(0, 0, 150, 20),
                ToggleTeams,
                GUIController.Instance.trajanNormal,
                "Enable Teams",
                16
                );
            y += toggleHeight;

            Panel.AddToggle(
                "Toggle Spectator",
                GUIController.Instance.images["Toggle_BG"],
                GUIController.Instance.images["Checkmark"],
                new Vector2(x, y),
                new Vector2(panelImg.width, 20),
                new Vector2(-60, 0),
                new Rect(0, 0, 150, 20),
                ToggleSpectator,
                GUIController.Instance.trajanNormal,
                "Spectator Mode",
                16
                );
            y += toggleHeight;

            Panel.AddToggle(
                "Toggle Custom Knight",
                GUIController.Instance.images["Toggle_BG"],
                GUIController.Instance.images["Checkmark"],
                new Vector2(x, y),
                new Vector2(panelImg.width, 20),
                new Vector2(-60, 0),
                new Rect(0, 0, 150, 20),
                ToggleCustomKnight,
                GUIController.Instance.trajanNormal,
                "Custom Knight Integration",
                16
                );
            y += toggleHeight;

            Panel.SetActive(false, true);

            On.HeroController.Pause   += OnPause;
            On.HeroController.UnPause += OnUnPause;
            UnityEngine.SceneManagement.SceneManager.activeSceneChanged += OnSceneChange;
        }