コード例 #1
0
ファイル: Main.cs プロジェクト: Lauchmelder23/CrosshairMod
        // This gets called on every GUI Update (Can be multiple tiems per Frame)
        void OnGUI()
        {
            // Check for Key presses
            if (Event.current.Equals(Event.KeyboardEvent(MENU_OPEN_KEY.ToString())))
            {
                // Toggle Crosshair GUI
                Interface.Toggle();
            }

            if (Event.current.Equals(Event.KeyboardEvent(CH_TOGGLE_KEY.ToString())))
            {
                // Toggle Crosshair
                Crosshair.Toggle();
            }

            //Render GUI
            Interface.Render();
            //Render Crosshair
            Crosshair.Render();
        }
コード例 #2
0
        // Initializes all Buttons, gives them their function etc
        public static void Init()
        {
            // Set dimension to 0.25 of the screen width/height
            m_dimension = new Vector2(Screen.width / 4, Screen.height / 4);
            // Center the interface
            m_position = new Vector2((Screen.width - m_dimension.x) / 2, (Screen.height - m_dimension.y) / 2);


            // Create Crosshair Visibilty Button
            AddButton(20, 20, 200, 30,
                      (Crosshair.Enabled() ? "Hide Crosshair" : "Show Crosshair"), "Toggle", (object sender, EventArgs e) => { Crosshair.Toggle(); },
                      (object sender, EventArgs e) => { GUIButton btn = (GUIButton)sender; btn.label = (Crosshair.Enabled() ? "Hide Crosshair" : "Show Crosshair"); });

            // Create Crosshair Size +/- Buttons
            AddButton(20, 60, 30, 30,
                      "-", "sizedown", (object sender, EventArgs e) => { Crosshair.ChangeSize(-1); });
            AddButton(190, 60, 30, 30,
                      "+", "sizeup", (object sender, EventArgs e) => { Crosshair.ChangeSize(+1); });

            // Create Crosshair Thickness +/- Buttons
            AddButton(20, 100, 30, 30,
                      "-", "thickdown", (object sender, EventArgs e) => { Crosshair.ChangeThickness(-1); });
            AddButton(190, 100, 30, 30,
                      "+", "thickup", (object sender, EventArgs e) => { Crosshair.ChangeThickness(+1); });

            rSliderValue = Settings.GetValue("crosshairColorRed");
            gSliderValue = Settings.GetValue("crosshairColorGreen");
            bSliderValue = Settings.GetValue("crosshairColorBlue");
            aSliderValue = Settings.GetValue("crosshairColorAlpha");

            // Create RGBA Sliders
            AddSlider(m_dimension.x / 2 + 60, 30, 200, 10, 0, 255, rSliderValue, "red");
            AddSlider(m_dimension.x / 2 + 60, 70, 200, 30, 0, 255, gSliderValue, "green");
            AddSlider(m_dimension.x / 2 + 60, 110, 200, 30, 0, 255, bSliderValue, "blue");
            AddSlider(m_dimension.x / 2 + 60, 150, 200, 30, 0, 255, aSliderValue, "alpha");
        }