void OnGUI()
    {
        if (hidden)
        {
            return;
        }

        Matrix4x4 oldMatrix = GUI.matrix;

        /*
         * if (AdminSettings.Instance.displayType == AdminScreen.DisplayType.PARABOLIC)
         * {
         *  GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 4992f, Screen.height / 1080f, 1f));
         *  GUI.BeginGroup(new Rect(3072, 0, 1920, 1080));
         * }
         * else
         * {
         *  GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 5760f, Screen.height / 1080f, 1f));
         *  GUI.BeginGroup(new Rect(3840, 0, 1920, 1080));
         * }
         */
        OnGUIScaler.ScaleUI();
        GUI.BeginGroup(new Rect((Screen.width / (Screen.height / 1080f)) - 1920f, 0, 1920, 1080));

        //GUILayout.BeginArea(new Rect(0, 0, 1920f, 1080f));

        GUI.DrawTexture(fullScreen, background);

        GUI.DrawTexture(logoRect, logos);

        GUI.Label(titleLabel, "VEHICLE & SCENE SELECT", isAdditional || isInfractions ? textOff : textOn);
        if (Event.current.type == EventType.MouseDown && titleLabel.Contains(Event.current.mousePosition))
        {
            hitAdditional  = false;
            hitInfractions = false;
        }


        GUI.Label(additionalControlsLabel, "ADDITIONAL CONTROLS", isAdditional ? textOn : textOff);
        if (Event.current.type == EventType.MouseDown && additionalControlsLabel.Contains(Event.current.mousePosition))
        {
            hitAdditional  = true;
            hitInfractions = false;
        }

        GUI.Label(infractionsLabel, "INFRACTIONS", isInfractions ? textOn : textOff);
        if (Event.current.type == EventType.MouseDown && infractionsLabel.Contains(Event.current.mousePosition))
        {
            hitAdditional  = false;
            hitInfractions = true;
        }

        if (isAdditional)
        {
            additionalCat.Render();
            GUI.EndGroup();
        }
        else if (isInfractions)
        {
            infractionsCat.Render();
            GUI.EndGroup();
        }
        else
        {
            GUI.color = currentVehicleColor;
            GUI.Label(selectVehicleLabel, "SELECT VEHICLE", textOn);


            foreach (var car in cars)
            {
                if (carSelect.currentChoice != car.selectIndex)
                {
                    GUI.color = currentVehicleColor;
                }
                else
                {
                    GUI.color = Color.white;
                }

                GUI.DrawTexture(car.position, car.texture);

                GUI.Label(car.textPosition, car.name, thumbText);


                if (carSelect.enabled && carSelect.CanSelect() && car.position.Contains(Event.current.mousePosition))
                {
                    GUI.DrawTexture(car.position, rolloverTex, ScaleMode.StretchToFill, true);
                    if (Event.current.type == EventType.MouseDown)
                    {
                        carSelect.Trigger(car.selectIndex);
                    }
                }


                if (carSelect.enabled && carSelect.hasSelected() && carSelect.currentChoice == car.selectIndex)
                {
                    GUI.DrawTexture(car.checkPosition, checkTex);
                }
                else if (environmentSelect.enabled && carSelect.currentChoice == car.selectIndex)
                {
                    if (car.position.Contains(Event.current.mousePosition))
                    {
                        GUI.DrawTexture(car.checkPosition, cancelTex);
                        if (Event.current.type == EventType.MouseDown)
                        {
                            environmentSelect.Back();
                        }
                    }
                    else
                    {
                        GUI.DrawTexture(car.checkPosition, checkTex);
                    }
                }

                GUI.color = Color.white;
            }

            GUI.color = currentEnvColor;


            GUI.Label(selectSceneLabel, "SELECT SCENE", textOn);

            foreach (var env in environments)
            {
                GUI.DrawTexture(env.position, env.texture);
                GUI.Label(env.textPosition, env.name, thumbText);
                if (environmentSelect.enabled == true && environmentSelect.CanSelect() && env.position.Contains(Event.current.mousePosition))
                {
                    GUI.DrawTexture(env.position, rolloverTex, ScaleMode.StretchToFill, true);
                    if (Event.current.type == EventType.MouseDown)
                    {
                        environmentSelect.Trigger(env.selectIndex);
                    }
                }

                if (environmentSelect.enabled == true && !environmentSelect.CanSelect())
                {
                    GUI.DrawTexture(env.checkPosition, checkTex);
                }
            }

            GUI.EndGroup();
            GUI.color  = Color.white;
            GUI.matrix = oldMatrix;
        }
    }
    void OnGUI()
    {
        if (hidden)
        {
            return;
        }

        Matrix4x4 oldMatrix = GUI.matrix;

        /*
         * if (AdminSettings.Instance.displayType == AdminScreen.DisplayType.PARABOLIC)
         * {
         *  GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 4992f, Screen.height / 1080f, 1f));
         *  GUI.BeginGroup(new Rect(3072, 0, 1920, 1080));
         * }
         * else
         * {
         *  GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 5760f, Screen.height / 1080f, 1f));
         *  GUI.BeginGroup(new Rect(3840, 0, 1920, 1080));
         * }
         */
        OnGUIScaler.ScaleUI();

        GUI.DrawTexture(background.location, background.tex);


        for (int i = 0; i < categories.Length; i++)
        {
            if (i != 4 || AppController.Instance.appSettings.showConfigurator)
            {
                GUI.Label(categories[i].location, categories[i].text, i == currentCategory ? categoryOnStyle : categoryOffStyle);
                if (Event.current.type == EventType.mouseDown && categories[i].location.Contains(Event.current.mousePosition))
                {
                    tempCategory = i;
                }
            }
        }

        var current = adminCategories[currentCategory];

        if (!string.IsNullOrEmpty(current.subcat0))
        {
            GUI.Label(subcat0Rect, current.subcat0, subCatStyle);
        }
        if (!string.IsNullOrEmpty(current.subcat1))
        {
            GUI.Label(subcat1Rect, current.subcat1, subCatStyle);
        }
        if (!string.IsNullOrEmpty(current.subcat2))
        {
            GUI.Label(subcat2Rect, current.subcat2, subCatStyle);
        }
        if (!string.IsNullOrEmpty(current.subcat3))
        {
            GUI.Label(subcat3Rect, current.subcat3, subCatStyle);
        }


        current.Render();

        GUI.EndGroup();

        GUI.matrix = oldMatrix;
    }
예제 #3
0
    void OnGUI()
    {
        if (hidden)
            return;

        //Matrix4x4 oldMatrix = GUI.matrix;
        //GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 1920f, Screen.height / 1080f, 1f));
        //GUILayout.BeginArea(new Rect(0, 0, 1920, 1080));

        GUI.depth = -2;

        Matrix4x4 oldMatrix = GUI.matrix;

        /*
        if(AdminSettings.Instance.displayType == DisplayType.PARABOLIC)
        {
            GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 6912f, Screen.height / 1080f, 1f));
            GUILayout.BeginArea(new Rect(4992, 120, 1920, 1080));
        }
        else
        {
            GUI.matrix = Matrix4x4.Scale(new Vector3(Screen.width / 7680f, Screen.height / 1080f, 1f));
            GUILayout.BeginArea(new Rect(5760, 120, 1920, 1080));
        }
        */
        OnGUIScaler.ScaleUI();
        
        
        GUILayout.BeginVertical();
        GUILayout.Label("Global Controls", topTitle, GUILayout.ExpandWidth(true), GUILayout.Height(80f));
        GUILayout.BeginHorizontal(GUILayout.Height(460));
        
        //Audio
        GUILayout.BeginVertical(GUILayout.Width(colWidth));
        GUILayout.Label("Audio", title);
        DrawSlider("Music", 0, 1, SetMusicVol, ref AdminSettings.Instance.musicVol);
        DrawSlider("Foley", 0, 1, SetFoleyVol, ref AdminSettings.Instance.foleyVol);
        DrawSlider("Vehicle", 0, 1, SetVehicleVol, ref AdminSettings.Instance.vehicleVol);
        GUILayout.EndVertical();

        //Display
        GUILayout.BeginVertical(GUILayout.Width(colWidth));
        GUILayout.Label("Display Configurations", title);
        DisplayType oldDisplay = AdminSettings.Instance.displayType;
        AdminSettings.Instance.displayType = (DisplayType)GUILayout.SelectionGrid((int)AdminSettings.Instance.displayType, new string[] { "Parabolic projection", "24\" configuration" }, 1, button);
        if(oldDisplay != AdminSettings.Instance.displayType)
            SetDisplay();
        GUILayout.EndVertical();

        //Calibrate Camera
        GUILayout.BeginVertical(GUILayout.Width(colWidth));
        GUILayout.Label("Calibrate Camera", title);
        DrawSlider("Motion Blur", 0f, 100f, null, ref AdminSettings.Instance.motionBlur);
        DrawSlider("Field Of View", 1f, 175f, SetFoV, ref AdminSettings.Instance.fov);
        DrawSlider("Far Clip Plane", 50f, 12000f, SetFarClip, ref AdminSettings.Instance.camFarClip);
        GUILayout.EndVertical();

        //Dynamic
        GUILayout.BeginVertical(GUILayout.Width(colWidth));
        GUILayout.Label("Extra Settings", title);
        if(cachedDynamicObjects != null)
        {
            foreach(var r in cachedDynamicObjects)
            {
                DrawSliderDynamic(r.label, r.min, r.max, r.setter, r.getter());
            }
        }
        GUILayout.EndVertical();


        GUILayout.EndHorizontal();
        GUILayout.Label("Scene Controls", topTitle, GUILayout.ExpandWidth(true), GUILayout.Height(80f));
        GUILayout.BeginHorizontal(GUILayout.Height(460));

        if(driveScene)
        {
            //weather
            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            GUILayout.Label("Adjust Lighting and Weather", title);


            bool oldVal = AdminSettings.Instance.fog;
            AdminSettings.Instance.fog = DrawToggle("Enable Fog", AdminSettings.Instance.fog);
            if(oldVal != AdminSettings.Instance.fog)
            {
                RenderSettings.fog = AdminSettings.Instance.fog;
            }

/*            int old = AdminSettings.Instance.weather;
            AdminSettings.Instance.weather = GUILayout.Toolbar(AdminSettings.Instance.weather,
                new string[] { 
                    "Clear",
                    "Storm",
                    "Overcast",
                    "Fog"
                }, smallButton);

            if(old != AdminSettings.Instance.weather)
            {
                var newWeather = AdminSettings.Instance.GetWeather();
                weather.currentWeather = newWeather;
                weather.ChangeWeather(newWeather);
            }*/

            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            GUILayout.Label("Lighting", title);

            bool oldLights = headlights;
            headlights = DrawToggle("Enable Headlights", headlights);
            if(oldLights != headlights)
            {
                TrackController.Instance.car.GetComponent<CarHeadlights>().SetHeadlights(headlights);
            }
            DrawSlider("Headlight Range", 0f, 200f, SetHeadlights, ref AdminSettings.Instance.headlights);
            GUILayout.EndHorizontal();

            //Obstacles
            GUILayout.BeginVertical(GUILayout.Width(colWidth / 2));
            GUILayout.Label("Obstacles", title);
            DrawButton("Obstacle 1", TrackController.Instance.TriggerObstacle1);
            DrawButton("Obstacle 2", TrackController.Instance.TriggerObstacle2);
            DrawButton("Obstacle 3", TrackController.Instance.TriggerObstacle3);
            DrawButton("Obstacle 4", TrackController.Instance.TriggerObstacle4);
            GUILayout.EndVertical();

            //Waypoints
            GUILayout.BeginVertical(GUILayout.Width(colWidth / 2));
            GUILayout.Label("Waypoints", title);
            DrawButton("Waypoint 1", TrackController.Instance.RepositionWaypoint1);
            DrawButton("Waypoint 2", TrackController.Instance.RepositionWaypoint2);
            DrawButton("Waypoint 3", TrackController.Instance.RepositionWaypoint3);
            DrawButton("Waypoint 4", TrackController.Instance.RepositionWaypoint4);
            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width(colWidth / 2));
            GUILayout.Label("Traffic", title);
            bool oldTraf = traffic;
            traffic = DrawToggle("Enable Traffic", traffic);
            if(oldTraf != traffic && trafSpawner != null)
            {
                trafSpawner.SetTraffic(traffic);
            }
            GUILayout.EndVertical();

            //end scene
            GUILayout.BeginVertical(GUILayout.Width(colWidth / 2));
            GUILayout.Label("End Scene", title);
            DrawButton("End Scene", () => { showingConfirmEnd = true; });
            GUILayout.EndVertical();

            //confirm
            if(showingConfirmEnd)
            {
                GUILayout.BeginVertical(GUILayout.Width(colWidth / 2));
                GUILayout.Label("Are You Sure?", title);
                DrawButton("YES", () =>
                {
                    showingConfirmEnd = false;
                    TrackController.Instance.ConfirmEndScene();
                });
                DrawButton("NO", () => { showingConfirmEnd = false; });
                GUILayout.EndVertical();
            }
        }
        else
        {
            /*GUILayout.BeginVertical(GUILayout.Width(colWidth));
            GUILayout.Label("Vechicle Select", title);
            DrawButton("Vehicle 1", () => SelectCar(1));
            DrawButton("Vehicle 2", () => SelectCar(1));
            DrawButton("Vehicle 3", () => SelectCar(1));
            DrawButton("Vehicle 4", () => SelectCar(1));
            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            GUILayout.Label("Environment Select", title);
            DrawButton("Scenic", () => SelectEnv(1));
            DrawButton("Urban", () => SelectEnv(2));
            DrawButton("Coastal", () => SelectEnv(3));
            DrawButton("Change Vehicle", () => SelectEnv(0));
            GUILayout.EndVertical();*/

        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndArea();
        GUI.matrix = oldMatrix;

    }