예제 #1
0
 // Use this for initialization
 void Start()
 {
     car         = GameObject.Find("Car");
     lc          = car.GetComponent <LapCounter>();
     tmpLapCount = lc.laps;
     cam         = GameObject.FindGameObjectWithTag("CameraFollow").GetComponent <Camera>();
 }
예제 #2
0
    public void TestPassiveResetForNetworkDelay2()
    {
        LapCounter lc = new LapCounter(2, cLapWaypointCount);

        for (int i = 0; i <= cLapWaypointCount / 2; i++)
        {
            var k = i;
            if (i == cLapWaypointCount)
            {
                k = i - cLapWaypointCount;
            }

            lc.UpdateWayPointLocal(k);
        }

        Assert.AreEqual(0, lc.CurrentLap);

        //继续同步remote一段时间,但本地模拟碰撞等情况,导致不更新路点
        lc.UpdateWayPointRemote(0, lc.CurrentWaypointIndex - 2);
        lc.UpdateWayPointRemote(0, lc.CurrentWaypointIndex);
        lc.UpdateWayPointRemote(0, lc.CurrentWaypointIndex + 3);
        lc.UpdateWayPointRemote(0, lc.CurrentWaypointIndex + 10);
        lc.UpdateWayPointRemote(0, cLapWaypointCount - 5);
        lc.UpdateWayPointRemote(0, cLapWaypointCount - 3);

        //lc.UpdateWayPointRemote(1, 1);

        //一段时间后被动reset,直接跳跃式更新路点
        lc.UpdateWayPointLocal(2);
        Assert.AreEqual(1, lc.CurrentLap);
    }
예제 #3
0
    public void TestNormalIncreaseDecreaseLap()
    {
        LapCounter lc = new LapCounter(2, cLapWaypointCount);


        for (int i = 0; i <= cLapWaypointCount; i++)
        {
            var k = i;
            if (i == cLapWaypointCount)
            {
                k = i - cLapWaypointCount;
            }

            lc.UpdateWayPointLocal(k);

            if (i < cLapWaypointCount)
            {
                Assert.AreEqual(0, lc.CurrentLap);
            }
            else
            {
                Assert.AreEqual(1, lc.CurrentLap);
            }
        }

        lc.UpdateWayPointLocal(cLapWaypointCount - 5);

        Assert.AreEqual(0, lc.CurrentLap);
    }
예제 #4
0
    public void TestNetKartReconnect()
    {
        LapCounter lc = new LapCounter(3, cLapWaypointCount);


        for (int i = 0; i <= cLapWaypointCount; i++)
        {
            var k = i;
            if (i == cLapWaypointCount)
            {
                k = i - cLapWaypointCount;
            }

            lc.UpdateWayPointLocal(k);
        }

        lc.Reset(2, 8);

        Assert.AreEqual(2, lc.CurrentLap);

        lc.UpdateWayPointLocal(10);

        Assert.AreEqual(2, lc.CurrentLap);
        Assert.AreEqual(10, lc.CurrentWaypointIndex);
    }
예제 #5
0
    void Start()
    {
        GameObject tmpObj = GameObject.Find("P" + transform.GetComponent <CarController> ().playerNumber + "_Target");          // you need to have a gameObject named "P1_Target" "P2_Target" "P3_Target" "P4_Target" on your scene

        if (tmpObj)
        {
            target = tmpObj.transform;                                                                                                                                                                  // access the target that follow the car
        }
        tmpObj = GameObject.Find("Track_Path");
        if (tmpObj)
        {
            Track = tmpObj.GetComponent <UnityStandardAssets.Utility.WaypointCircuit>();                                                                // access the track (car path)
        }
        if (Track != null && Track.waypointList.items.Length > 0)
        {
            pathExist = true;
        }

        tmpObj = GameObject.Find("StartLine_lapCounter");
        if (tmpObj)
        {
            sLapCounter = tmpObj.GetComponent <LapCounter> ();                                                                                                                          // access the track (car path)
        }
        carPathFollow = GetComponent <CarPathFollow> ();
    }
예제 #6
0
    void OnTriggerEnter(Collider other)
    {
        GameObject car = other.transform.root.gameObject;

        CheckpointTracker tracker = car.GetComponent <CheckpointTracker>();

        if (tracker == null || !tracker.isNextCheckPoint(this))
        {
            return;
        }

        tracker.SetNextCheckPoint(NextCheckpoint);

        LapCounter counter = car.GetComponent <LapCounter>();

        if (counter != null && isGoal)
        {
            counter.AddLap();
            Debug.Log($"{car.name} - Lap!");
        }

        if (car.tag != "Player")
        {
            return;
        }

        SetCheckpoint(false);

        NextCheckpoint?.ActivateCheckpoint();
    }
        public void SetUp()
        {
            _mockBoard = Fixture.Mock <IBoardWithEnd>();

            _lapCounter = Fixture.Create <LapCounter>();

            _numberOfLaps = Fixture.Create <uint>();
        }
예제 #8
0
    //public bool multiplayer = false;

    // Use this for initialization
    void Awake()
    {
        #region
        PlayerPrefs.SetInt("WeAreOnTrack", 1);                                                                                                                                                  // This PlayerPrefs = 1 : allow to display race selection when player came back to main menu

        if (canvas_MainMenu &&
            inventoryItemList.inventoryItem[0].b_TestMode == false
            /*&& PlayerPrefs.GetInt ("TestMode") == 0 */
            && !b_TuningZone)                                                                                                                   // If we are not in test mode
        {
            canvas_MainMenu.GoToOtherPageWithHisNumber(7);                                                                                      // Display Loading_Page
        }
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        if (!PlayerPrefs.HasKey("PP_1_Desktop_Left"))                                                                                                                                           // If no Input have been setup, init inputs
        {
            DefaultInputsParameters();
        }

        if (countdown == null)                                                                                                                                                                                          // Access coundown gameobject component
        {
            if (gameObject.GetComponent <Countdown>())
            {
                countdown = GetComponent <Countdown> ();
            }
        }

        if (lapcounter == null)                                                                                                                                                                                         // Access coundown gameobject component
        {
            GameObject objLapCounter = GameObject.Find("StartLine_lapCounter");
            if (objLapCounter)
            {
                lapcounter = objLapCounter.GetComponent <LapCounter> ();
            }
        }

        if (                                                         /*PlayerPrefs.GetInt ("TestMode") == 1 */
            inventoryItemList.inventoryItem[0].b_TestMode == true && // --> Demo Mode is activated
            inventoryItemList != null)                               // --> Feedback on screen : to say that the game is in Test Mode
        {
            GameObject objTextModeTest = inventoryItemList.inventoryItem [0].Canvas_TestMode;
            if (objTextModeTest)
            {
                GameObject instance = Instantiate(objTextModeTest) as GameObject;
                instance.name = "Canvas_TestMode";
            }
        }
        #endregion
    }
예제 #9
0
    public void TestWithNormalRemoteUpdate()
    {
        LapCounter lc = new LapCounter(2, cLapWaypointCount);

        //车被裁剪后,启用PreferRemote策略
        lc.SetStrategy(LapCounter.UpdateStrategy.PreferRemote);

        lc.UpdateWayPointRemote(1, 10);

        Assert.AreEqual(1, lc.CurrentLap);
        Assert.AreEqual(10, lc.CurrentWaypointIndex);
    }
예제 #10
0
    public void TestFinish()
    {
        LapCounter lc = new LapCounter(3, cLapWaypointCount);

        for (int i = 0; i <= cLapWaypointCount * 3; i++)
        {
            var k = i % cLapWaypointCount;

            lc.UpdateWayPointLocal(k);
        }

        Assert.AreEqual(3, lc.CurrentLap);
        Assert.IsTrue(lc.IsFinished);
    }
예제 #11
0
    public override void OnInspectorGUI()
    {
        if (SeeInspector.boolValue)                                                                                                                                     // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        serializedObject.Update();

        GUIStyle style_Yellow_01     = new GUIStyle(GUI.skin.box);   style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue          = new GUIStyle(GUI.skin.box);   style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple        = new GUIStyle(GUI.skin.box);   style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange        = new GUIStyle(GUI.skin.box);   style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);   style_Yellow_Strong.normal.background = Tex_02;



        GUILayout.Label("");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Inspector :", GUILayout.Width(90));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();

        LapCounter myScript = (LapCounter)target;

        GUILayout.Label("");

        if (inventoryItemCar.objectReferenceValue == null)
        {
            EditorGUILayout.HelpBox("You need to connect ''Data_CarList'' on the next SLot" +
                                    "\nMCR Creator -> Assets -> Data -> Data_CarList.", MessageType.Warning);
        }
        EditorGUILayout.PropertyField(inventoryItemCar, new GUIContent(""));

        GUILayout.Label("");
// --> Number of Lap
        EditorGUILayout.BeginVertical(style_Yellow_Strong);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Number of Lap :", GUILayout.Width(90));
        EditorGUILayout.PropertyField(lapNumber, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        GUILayout.Label("");



        serializedObject.ApplyModifiedProperties();
    }
예제 #12
0
    // Use this for initialization
    void Start()
    {
        // clear dir
        DirectoryInfo di = new DirectoryInfo("Assets/Screenshots/");

        foreach (FileInfo file in di.GetFiles())
        {
            file.Delete();
        }

        car         = GameObject.Find("Car");
        lc          = car.GetComponent <LapCounter>();
        tmpLapCount = 0;
        cam         = GameObject.FindGameObjectWithTag("CameraFollow").GetComponent <Camera>();
    }
예제 #13
0
    // Update is called once per frame
    void Update()
    {
        if (lapCounter == null)
        {
            lapCounter = GameObject.Find("StartLine_lapCounter").GetComponent <LapCounter>();
        }

        if (!b_btn_NextTrack)                                                 // button Next Track in championship mode is not pressed
        {
            if (lapCounter != null)
            {
                if (TimeIsCalulated.Count != lapCounter.raceFinished.Count)
                {
                    TimeIsCalulated.Clear();
                    for (var i = 0; i < lapCounter.raceFinished.Count; i++)
                    {
                        TimeIsCalulated.Add(false);
                        objScoreContent.GetComponent <RectTransform>().sizeDelta = new Vector2(0, 40 * lapCounter.raceFinished.Count);
                    }
                }


                if (TimeIsCalulated.Count == lapCounter.raceFinished.Count)
                {
                    for (var i = 0; i < lapCounter.raceFinished.Count; i++)
                    {
                        if (lapCounter.raceFinished[i] && !TimeIsCalulated[i] && PositionCounter == lapCounter.carPosition[i])
                        {
                            MCR_InstantiateScorePrefab(i);
                        }
                    }
                }
            }
        }


        for (var i = 0; i < lapCounter.carController.Count; i++)
        {
            if (lapCounter.carController[i])
            {
                lapCounter.carController[i].audio_.volume              = Mathf.MoveTowards(lapCounter.carController[i].audio_.volume, .1f, Time.deltaTime * fadeSpeed);
                lapCounter.carController[i].objSkid_Sound.volume       = Mathf.MoveTowards(lapCounter.carController[i].audio_.volume, 0, Time.deltaTime);
                lapCounter.carController[i].obj_CarImpact_Sound.volume = Mathf.MoveTowards(lapCounter.carController[i].audio_.volume, 0, Time.deltaTime);
            }
        }
    }
예제 #14
0
    void OnTriggerExit()
    {
        if (isCurrent)
        {
            // Aktywuj nastepny checkpoint
            isCurrent = false;
            GameObject gameObject = GameObject.Find(nextCheckpoint);
            gameObject.GetComponent <Checkpoint>().isCurrent = true;

            if (isGoal)
            {
                GameObject lapText    = GameObject.Find("lapText");
                LapCounter lapCounter = lapText.GetComponent <LapCounter>();
                if (lapCounter.lap == 3)
                {
                    // Jesli jest to startowy checkpoint i gracz wykonal 3 okrazenia - wyswietl podsumowanie
                    GameObject endRace = GameObject.Find("endRace");
                    endRace.GetComponent <EndRace>().enabled = true;
                    Time.timeScale = 0.0f;
                }
                lapCounter.lap++;
            }
        }
    }
예제 #15
0
 // Use this for initialization
 void Start()
 {
     //transform.Rotate(Vector3.left, 180.0f); // Za test ...
     car = GameObject.Find("Car");
     lc  = car.GetComponent <LapCounter>();
 }
예제 #16
0
    void OnGUI()
    {
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, true, true, GUILayout.Width(position.width), GUILayout.Height(position.height));

        if (Tex_01 == null)
        {
            Tex_01 = MakeTex(2, 2, new Color(1, .8f, 0.2F, .4f));
            Tex_02 = MakeTex(2, 2, new Color(1, .8f, 0.2F, 1f));
            Tex_03 = MakeTex(2, 2, new Color(.3F, .9f, 1, .5f));
            Tex_04 = MakeTex(2, 2, new Color(1, .3f, 1, .3f));
            Tex_05 = MakeTex(2, 2, new Color(1, .5f, 0.3F, .4f));
        }


        GUIStyle style_Yellow_01 = new GUIStyle(GUI.skin.box);

        style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue = new GUIStyle(GUI.skin.box);

        style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple = new GUIStyle(GUI.skin.box);

        style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange = new GUIStyle(GUI.skin.box);

        style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);

        style_Yellow_Strong.normal.background = Tex_02;

        EditorGUI.BeginChangeCheck();


        EditorGUILayout.LabelField("");
        if (inventoryItemList == null)
        {
            EditorGUILayout.HelpBox("Drag and drop the file ''Data_MCRTestingTrack'' on the next field" +
                                    "\n(MCR Creator -> Assets -> Datas -> Data_MCRTestingTrack)", MessageType.Warning);
        }
// --> Display Data
        inventoryItemList = EditorGUILayout.ObjectField(inventoryItemList, typeof(Object), true) as InventoryGlobalPrefs;


        if (EditorGUI.EndChangeCheck())
        {
            if (inventoryItemList)
            {
                string relPath = AssetDatabase.GetAssetPath(inventoryItemList);
                EditorPrefs.SetString("MCRGlobalPref_Path_", relPath);
            }
        }


        EditorGUILayout.HelpBox("IMPORTANT : If ''Test Mode'' is activated all the Unity project is affected by the Test Mode", MessageType.Info);

        if (inventoryItemList)
        {
            EditorGUILayout.BeginVertical(style_Yellow_Strong);

            SerializedObject serializedObject0 = new UnityEditor.SerializedObject(inventoryItemList);
            serializedObject0.Update();
            SerializedProperty m_b_TestMode = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("b_TestMode");

            EditorGUILayout.LabelField("");

// --> Test mode is activated or deactivated
            if (!m_b_TestMode.boolValue)
            {
                if (GUILayout.Button("Test Mode is deactivated"))
                {
                    //PlayerPrefs.SetInt ("TestMode", 1);                                                                   // --> activated

                    if (inventoryItemList)
                    {
                        m_b_TestMode.boolValue = true;
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Test Mode is Activated"))
                {
                    //PlayerPrefs.SetInt ("TestMode", 0);                                                                   // --> deactivated

                    if (inventoryItemList)
                    {
                        m_b_TestMode.boolValue = false;
                    }

                    if (lapCounter && game_Manager)                                                                                                                                                                                     // Activate Lap Counter
                    {
                        SerializedObject serializedObject1 = new UnityEditor.SerializedObject(game_Manager.inventoryItemCar);
                        serializedObject1.Update();
                        SerializedProperty m_b_LapCounter = serializedObject1.FindProperty("b_LapCounter");
                        m_b_LapCounter.boolValue = true;
                        serializedObject1.ApplyModifiedProperties();
                    }


                    if (game_Manager)                                                                                                                                                                                                                   // Activate Countdown
                    {
                        SerializedObject serializedObject2 = new UnityEditor.SerializedObject(game_Manager.inventoryItemCar);
                        serializedObject2.Update();
                        SerializedProperty m_b_Countdown = serializedObject2.FindProperty("b_Countdown");
                        m_b_Countdown.boolValue = true;
                        serializedObject2.ApplyModifiedProperties();
                    }

                    if (game_Manager == null)                                                                                                                                                                                   // --> Case : We are not on a track scene
                    {
                        string       objectPath       = "Assets/MCR Creator/Assets/Datas/Data_CarList.asset";
                        InventoryCar inventoryItemCar = AssetDatabase.LoadAssetAtPath(objectPath, typeof(Object)) as InventoryCar;
                        if (inventoryItemCar)
                        {
                            SerializedObject serializedObject1 = new UnityEditor.SerializedObject(inventoryItemCar);
                            serializedObject1.Update();
                            SerializedProperty m_b_LapCounter = serializedObject1.FindProperty("b_LapCounter");
                            m_b_LapCounter.boolValue = true;
                            serializedObject1.ApplyModifiedProperties();

                            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(inventoryItemCar);
                            serializedObject2.Update();
                            SerializedProperty m_b_Countdown = serializedObject2.FindProperty("b_Countdown");
                            m_b_Countdown.boolValue = true;
                            serializedObject2.ApplyModifiedProperties();
                        }
                    }



                    // --> Find and Pause Cars

                    /*	GameObject[] arrCars = GameObject.FindGameObjectsWithTag ("Car");												// Delete cars on scene
                     *
                     *
                     *      List<GameObject> tmpList	= new List<GameObject> ();
                     *      foreach (GameObject car in arrCars) {
                     *              if (car.GetComponent<CarController> ()) {
                     *                      tmpList.Add (car);
                     *              }
                     *      }
                     *      for (var i = tmpList.Count - 1; i >= 0; i--) {
                     *              Undo.DestroyObjectImmediate (tmpList [i]);
                     *      }
                     *      tmpList.Clear ();*/
                }
            }
            serializedObject0.ApplyModifiedProperties();
            EditorGUILayout.LabelField("");

            EditorGUILayout.EndVertical();


            if (!game_Manager)
            {
                GameObject tmpObj = GameObject.Find("Game_Manager");
                if (tmpObj)
                {
                    game_Manager = tmpObj.GetComponent <Game_Manager> ();
                }
            }

            if (m_b_TestMode.boolValue && game_Manager)                                                                                                                                                                                                 // if Test Mode activated
            {
                EditorGUILayout.LabelField("");
                EditorGUILayout.BeginVertical(style_Yellow_01);
                EditorGUILayout.LabelField("Add cars to test the scene"
                                           , EditorStyles.boldLabel);


                // Block of code with controls
                // that may set GUI.changed to true.
                EditorGUILayout.HelpBox("This section allow to add cars in the scene when you want to test a scene" +
                                        "\n1-Press button ''Apply to create'' for each car you want to create on scene." +
                                        "\n2-For Car 1 and 2 you could press button ''Player/CPU'' to choose if the car is manage by a Player or a CPU. Don't forget to press ''Apply'' after your modification" +
                                        "\n3-You could choose the car you want to add in the scene. Drag and drop a car prefab in the first field" +
                                        "\n" +
                                        "\nINFO : If you want to delete a car. You could delete the car on the Hierarchy. Or you could Hide the car on the Hierarchy", MessageType.Info);



                if (inventoryItemList && game_Manager)
                {
                    EditorGUILayout.BeginVertical();
// --> Options to add cars on screen
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("", GUILayout.Width(50));
                    EditorGUILayout.LabelField("Drag and drop your car", GUILayout.Width(150));
                    EditorGUILayout.LabelField("Who control car", GUILayout.Width(100));
                    EditorGUILayout.LabelField("Add car to the scene", GUILayout.Width(120));
                    EditorGUILayout.EndHorizontal();

                    for (var i = 0; i < 4; i++)
                    {
                        SerializedObject serializedObject01 = new UnityEditor.SerializedObject(inventoryItemList);
                        serializedObject01.Update();
                        SerializedProperty m_carName    = serializedObject01.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_Cars");
                        SerializedProperty m_PlayerType = serializedObject01.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_playerType");
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Car " + (i + 1) + " :", GUILayout.Width(50));


                        if (inventoryItemList)
                        {
                            EditorGUILayout.PropertyField(m_carName.GetArrayElementAtIndex(i), new GUIContent(""), GUILayout.Width(150));

                            if (i == 0 || i == 1)
                            {
                                if (m_PlayerType.GetArrayElementAtIndex(i).boolValue)
                                {
                                    if (GUILayout.Button("CPU", GUILayout.Width(50)))                                                                                                                                           // Clear All the playerPrefs
                                    {
                                        m_PlayerType.GetArrayElementAtIndex(i).boolValue = false;
                                    }
                                }
                                else
                                {
                                    if (GUILayout.Button("Player", GUILayout.Width(50)))                                                                                                                                                // Clear All the playerPrefs
                                    {
                                        m_PlayerType.GetArrayElementAtIndex(i).boolValue = true;
                                    }
                                }
                            }
                            else
                            {
                                EditorGUILayout.LabelField("CPU", GUILayout.Width(50));
                            }
                        }
                        EditorGUILayout.LabelField("", GUILayout.Width(50));
                        if (GUILayout.Button("Apply", GUILayout.Width(60)))                                                                                                                             // Clear All the playerPrefs
                        {
                            ReplaceACar(i);
                        }

                        EditorGUILayout.EndHorizontal();
                        serializedObject01.ApplyModifiedProperties();
                    }

                    EditorGUILayout.LabelField("");


                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.LabelField("");

                EditorGUILayout.BeginVertical(style_Blue);
                EditorGUILayout.LabelField("Lap Counter Options"
                                           , EditorStyles.boldLabel);

                EditorGUILayout.HelpBox("The next two buttons are the same as buttons you find on gameObject ''StartLine_LapCounter'' on the Hierarchy" +
                                        "\n(Grp_Manager -> Grp_StartLine -> StartLine_LapCounter", MessageType.Info);


                if (GUILayout.Button("Initilize car positions on the start line"))
                {
                    InitCarPositionOnTheStartLine();
                }

                if (!lapCounter)
                {
                    GameObject tmpObj = GameObject.FindGameObjectWithTag("TriggerStart");
                    if (tmpObj)
                    {
                        lapCounter = tmpObj.GetComponent <LapCounter> ();
                    }
                }



                if (lapCounter && game_Manager)
                {
                    SerializedObject serializedObject1 = new UnityEditor.SerializedObject(game_Manager.inventoryItemCar);
                    serializedObject1.Update();
                    //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
                    SerializedProperty m_b_LapCounter = serializedObject1.FindProperty("b_LapCounter");


                    if (m_b_LapCounter.boolValue)
                    {
                        if (GUILayout.Button("Lap Counter is activated"))
                        {
                            m_b_LapCounter.boolValue = false;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Lap Counter is deactivated"))
                        {
                            m_b_LapCounter.boolValue = true;
                        }
                    }
                    serializedObject1.ApplyModifiedProperties();
                }
                EditorGUILayout.EndVertical();


                EditorGUILayout.LabelField("");

                EditorGUILayout.BeginVertical(style_Orange);
                EditorGUILayout.LabelField("Countdown"
                                           , EditorStyles.boldLabel);

                EditorGUILayout.HelpBox("The next button is the same as button you find on gameObject ''Game_Manager'' on the Hierarchy" +
                                        "\n(Grp_Manager -> Game_Manager", MessageType.Info);



                if (game_Manager)
                {
                    SerializedObject serializedObject2 = new UnityEditor.SerializedObject(game_Manager.inventoryItemCar);
                    serializedObject2.Update();
                    //SerializedProperty m_b_UseCountdown = serializedObject2.FindProperty ("b_UseCountdown");
                    SerializedProperty m_b_Countdown = serializedObject2.FindProperty("b_Countdown");


                    if (m_b_Countdown.boolValue)
                    {
                        if (GUILayout.Button("Countdown is activated"))
                        {
                            m_b_Countdown.boolValue = false;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Countdown is deactivated"))
                        {
                            m_b_Countdown.boolValue = true;
                        }
                    }
                    serializedObject2.ApplyModifiedProperties();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.LabelField("");

                EditorGUILayout.BeginVertical(style_Purple);
                if (!game_ManagerDifficulty)
                {
                    GameObject tmpObj = GameObject.Find("Game_Manager");

                    if (tmpObj)
                    {
                        game_ManagerDifficulty = tmpObj.GetComponent <DifficultyManager> ();
                    }
                }

                if (game_ManagerDifficulty)
                {
                    EditorGUILayout.LabelField("Choose Difficulty for Test Mode", EditorStyles.boldLabel);
                    SerializedObject serializedObject3 = new UnityEditor.SerializedObject(game_ManagerDifficulty);
                    serializedObject3.Update();
                    SerializedProperty m_SelectedDifficulties = serializedObject3.FindProperty("selectedDifficulties");

                    string tmpDifficulty = "";
                    if (m_SelectedDifficulties.intValue == 0)
                    {
                        tmpDifficulty = "Easy";
                        PlayerPrefs.SetInt("DifficultyChoise", 0);
                    }
                    if (m_SelectedDifficulties.intValue == 1)
                    {
                        tmpDifficulty = "Medium";
                        PlayerPrefs.SetInt("DifficultyChoise", 1);
                    }
                    if (m_SelectedDifficulties.intValue == 2)
                    {
                        tmpDifficulty = "Expert";
                        PlayerPrefs.SetInt("DifficultyChoise", 2);
                    }

                    if (GUILayout.Button(tmpDifficulty))
                    {
                        m_SelectedDifficulties.intValue = (m_SelectedDifficulties.intValue + 1) % 3;
                    }
                    serializedObject3.ApplyModifiedProperties();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.LabelField("");
            }
        }
        GUILayout.EndScrollView();
    }
예제 #17
0
    public override void OnInspectorGUI()
    {
        if (SeeInspector.boolValue)                                                             // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        serializedObject.Update();
        Game_Manager myScript = (Game_Manager)target;

        GUIStyle style_Yellow_01     = new GUIStyle(GUI.skin.box);   style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue          = new GUIStyle(GUI.skin.box);   style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple        = new GUIStyle(GUI.skin.box);   style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange        = new GUIStyle(GUI.skin.box);   style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);   style_Yellow_Strong.normal.background = Tex_02;

        GUILayout.Label("");

        GUILayout.Label("");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Inspector :", GUILayout.Width(90));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();



        GUILayout.Label("");
        EditorGUILayout.HelpBox("This script Manager Game Rules.", MessageType.Info);
        GUILayout.Label("");


        SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript.inventoryItemCar);

        serializedObject2.Update();
        SerializedProperty m_b_mobile             = serializedObject2.FindProperty("b_mobile");
        SerializedProperty m_mobileMaxSpeedOffset = serializedObject2.FindProperty("mobileMaxSpeedOffset");
        SerializedProperty mobileWheelStearingOffsetReactivity = serializedObject2.FindProperty("mobileWheelStearingOffsetReactivity");

        //SerializedProperty m_b_LapCounter = serializedObject2.FindProperty ("b_LapCounter");


// -->Mobile Options
        EditorGUILayout.BeginVertical(style_Yellow_Strong);



        EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section." +
                                "\n" +
                                "\n-You could modify the Max speed for all car on Mobile." +
                                "\n" +
                                "-You could modify the wheel stearing reactivity for all cars on mobile." +
                                "\n", MessageType.Info);

        if (m_b_mobile.boolValue)
        {
            if (GUILayout.Button("Cars are setup for Mobile Inputs"))
            {
                m_b_mobile.boolValue = false;
            }
        }
        else
        {
            if (GUILayout.Button("Cars are setup for Desktop Inputs"))
            {
                m_b_mobile.boolValue = true;
            }
        }


        if (m_b_mobile.boolValue)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Mobile Max Speed Offset :", GUILayout.Width(220));
            EditorGUILayout.PropertyField(m_mobileMaxSpeedOffset, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Mobile Wheel Stearing Offset Reactivity :", GUILayout.Width(220));
            EditorGUILayout.PropertyField(mobileWheelStearingOffsetReactivity, new GUIContent(""));
            EditorGUILayout.EndHorizontal();
        }



        EditorGUILayout.EndVertical();


// --> Countdown

/*		EditorGUILayout.BeginVertical (style_Orange);
 *              EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section.",MessageType.Info);
 *
 *              if (m_b_Countdown.boolValue) {
 *                      if (GUILayout.Button ("Countdown is activated when game Start")) {
 *                              //b_UseCountdown.boolValue = false;
 *                              m_b_Countdown.boolValue = false;
 *                      }
 *              } else {
 *                      if (GUILayout.Button ("Countdown is deactivated when game Start")) {
 *                              //b_UseCountdown.boolValue = true;
 *                              m_b_Countdown.boolValue = true;
 *                      }
 *              }
 *              EditorGUILayout.EndVertical ();*/

// --> Lap Counter

        /*	EditorGUILayout.BeginVertical (style_Blue);
         *      EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section.",MessageType.Info);
         *      if (!lapCounter) {
         *              GameObject tmpObj = GameObject.FindGameObjectWithTag ("TriggerStart");
         *              if (tmpObj)
         *                      lapCounter = tmpObj.GetComponent<LapCounter> ();
         *      }
         *
         *      if (lapCounter) {
         *              //SerializedObject serializedObject1 = new UnityEditor.SerializedObject (lapCounter);
         *              //serializedObject1.Update ();
         *              //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
         *              //SerializedProperty m_lapNumber = serializedObject1.FindProperty ("lapNumber");
         *
         *
         *              if (m_b_LapCounter.boolValue) {
         *                      if (GUILayout.Button ("Lap Counter is activated")) {
         *                              m_b_LapCounter.boolValue = false;
         *                      }
         *              } else {
         *                      if (GUILayout.Button ("Lap Counter is deactivated")) {
         *                              m_b_LapCounter.boolValue = true;
         *                      }
         *              }
         *
         *              //serializedObject1.ApplyModifiedProperties ();
         *      }
         *      EditorGUILayout.EndVertical ();*/

        serializedObject2.ApplyModifiedProperties();

        GUILayout.Label("");
        GUILayout.Label("");
        // --> Lap Counter
        EditorGUILayout.BeginVertical(style_Yellow_01);
        EditorGUILayout.HelpBox("The next sections only affect this scene.", MessageType.Info);
        if (!lapCounter)
        {
            GameObject tmpObj = GameObject.FindGameObjectWithTag("TriggerStart");
            if (tmpObj)
            {
                lapCounter = tmpObj.GetComponent <LapCounter> ();
            }
        }

        if (lapCounter)
        {
            SerializedObject serializedObject1 = new UnityEditor.SerializedObject(lapCounter);
            serializedObject1.Update();
            //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
            SerializedProperty m_lapNumber = serializedObject1.FindProperty("lapNumber");

            // --> Lap Numbers
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Lap number:", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_lapNumber, new GUIContent(""));
            EditorGUILayout.EndHorizontal();


            serializedObject1.ApplyModifiedProperties();
        }
        EditorGUILayout.EndVertical();

        GUILayout.Label("");



        EditorGUILayout.BeginVertical(style_Yellow_01);
        EditorGUILayout.HelpBox("Set the number of player for this race.", MessageType.Info);


        // --> Lap Numbers
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Cars number:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(howManyCarsInRace, new GUIContent(""));
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Cars per line:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(numberOfLine, new GUIContent(""));
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Distance between cars on the same line X:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(distanceXbetweenTwoCars, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Offset between two cars on the same line Z:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(distanceZbetweenTwoCarsInSameLine, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Distance between two lines Z:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(distanceZbetweenTwoCars, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        GUILayout.Label("");

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Offset car AI:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(offsetRoadAi, new GUIContent(""));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("random Range Offset Road AI:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(randomRangeOffsetRoadAI, new GUIContent(""));
        EditorGUILayout.EndHorizontal();



        if (GUILayout.Button("Update"))
        {
            List <float> listFloat = new List <float>();
            float        newValue  = offsetRoadAi.floatValue;
            listFloat.Clear();
            float multipler = 1;
            int   counter   = 0;

            if (numberOfLine.intValue % 2 != 0)
            {
                listFloat.Add(0);
            }

            int howManyEntry = numberOfLine.intValue;
            if (numberOfLine.intValue % 2 != 0)
            {
                howManyEntry = numberOfLine.intValue - 1;
            }

            for (var i = 0; i < howManyEntry; i++)
            {
                listFloat.Add(newValue);

                counter++;
                if (counter % 2 == 0)
                {
                    multipler++;
                    newValue += offsetRoadAi.floatValue;
                }
                counter = counter % 2;
            }

            counter = 0;
            for (var i = 0; i < listFloat.Count; i++)
            {
                if (counter % 2 == 0)
                {
                    listFloat[i] = -listFloat[i];
                }
                counter++;
            }


            string value = "";
            foreach (float val in listFloat)
            {
                value += val + " : ";
            }
            //Debug.Log(value);

            listFloat.Sort();
            value = "";
            foreach (float val in listFloat)
            {
                value += val + " : ";
            }
            // Debug.Log(value);

            //-> Destroy current StartPosition
            GameObject refStartPosition = GameObject.Find("Start_Position_01");

            for (var i = 1; i < 300; i++)
            {
                GameObject tmpPosition = GameObject.Find("Start_Position_0" + (i + 1));
                if (tmpPosition)
                {
                    Undo.DestroyObjectImmediate(tmpPosition);
                }
            }


            //-> Create new Start_Position
            Undo.RegisterFullObjectHierarchyUndo(refStartPosition, refStartPosition.name);
            //float offsetX = distanceXbetweenTwoCars.floatValue;
            float offsetDependingNumberOfLine = distanceXbetweenTwoCars.floatValue * .5f * (numberOfLine.intValue - 1);

            refStartPosition.transform.localPosition = new Vector3(0 - offsetDependingNumberOfLine,
                                                                   -0.4f,
                                                                   1.2f);
            refStartPosition.name = "Start_Position_0" + howManyCarsInRace.intValue;

            //distanceXbetweenTwoCars
            //distanceZbetweenTwoCars
            float newPos    = 0;
            int   newModulo = 0;
            for (var i = howManyCarsInRace.intValue - 1; i > 0; i--)
            {
                //offsetX = -offsetX;

                GameObject tmpPosition = Instantiate(refStartPosition, refStartPosition.transform.parent);
                tmpPosition.name = "Start_Position_0" + i;

                newModulo++;
                newModulo %= numberOfLine.intValue;

                if (newModulo == 0)
                {
                    newPos += .5f + distanceZbetweenTwoCars.floatValue;
                }


                //numberOfLine
                tmpPosition.transform.localPosition = new Vector3(newModulo * distanceXbetweenTwoCars.floatValue - offsetDependingNumberOfLine,
                                                                  -0.4f,
                                                                  1.2f - newPos - distanceZbetweenTwoCarsInSameLine.floatValue * newModulo);

                //tmpPosition.transform.localPosition = new Vector3(offsetX,0,1.5f - howManyCarsInRace.intValue * .5f + (1+i)*.5f);

                Undo.RegisterCreatedObjectUndo(tmpPosition, tmpPosition.name);
            }

            //-> Destroy current target for each car
            GameObject refTarget = GameObject.Find("P1_Target");

            for (var i = 1; i < 300; i++)
            {
                GameObject tmptarget = GameObject.Find("P" + (i + 1) + "_Target");
                if (tmptarget)
                {
                    Undo.DestroyObjectImmediate(tmptarget);
                }
            }

            //-> Create new target for each car
            for (var i = 0; i < howManyCarsInRace.intValue - 1; i++)
            {
                GameObject tmptarget = Instantiate(refTarget);
                tmptarget.name = "P" + (i + 2) + "_Target";
                tmptarget.transform.GetChild(0).name = tmptarget.name + "_Part2";

                Undo.RegisterCreatedObjectUndo(tmptarget, tmptarget.name);
            }


            //-> Create new difficulties parameters
            Undo.RegisterFullObjectHierarchyUndo(myScript, myScript.name);
            for (var i = 0; i < 3; i++)
            {
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].addGlobalSpeedOffset.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointSuccesRate.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMinTarget.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMaxTarget.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].speedSuccesRate.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].speedOffset.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].rotationSuccesRate.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].rotationOffset.Clear();


                for (var j = 0; j < howManyCarsInRace.intValue - 1; j++)
                {
                    if (j % 3 == 0)
                    {
                        SetCarValue(myScript,
                                    i,
                                    -.2f, 0, 100, 100,
                                    -.05f, 0, 100, 100,
                                    .05f, 0, 100, 100);
                    }
                    else if (j % 3 == 1)
                    {
                        SetCarValue(myScript,
                                    i,
                                    -.1f, 0, 50, 70,
                                    0f, 0, 50, 70,
                                    .15f, 0, 50, 70);
                    }
                    else
                    {
                        SetCarValue(myScript,
                                    i,
                                    0f, 0, 100, 70,
                                    .1f, 0, 100, 70,
                                    .25f, 0, 100, 70);
                    }

                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMinTarget.Add(0);
                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMaxTarget.Add(0);


                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].speedOffset.Add(0);

                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].rotationOffset.Add(-15);

                    counter++;
                    counter = counter % listFloat.Count;
                }

                counter = 0;
                for (var k = howManyCarsInRace.intValue - 2; k >= 0; k--)
                {
                    float newValue2 = returnRandomValue(listFloat[counter]);
                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMinTarget[k] = newValue2;
                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMaxTarget[k] = newValue2;

                    counter++;
                    counter = counter % listFloat.Count;
                    //Debug.Log("car_" + k);
                }
            }
        }

        EditorGUILayout.EndVertical();

        GUILayout.Label("");


        serializedObject.ApplyModifiedProperties();
    }
예제 #18
0
    public override void OnInspectorGUI()
    {
        if (SeeInspector.boolValue)                                                             // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        serializedObject.Update();
        Game_Manager myScript = (Game_Manager)target;

        GUIStyle style_Yellow_01     = new GUIStyle(GUI.skin.box);   style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue          = new GUIStyle(GUI.skin.box);   style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple        = new GUIStyle(GUI.skin.box);   style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange        = new GUIStyle(GUI.skin.box);   style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);   style_Yellow_Strong.normal.background = Tex_02;

        GUILayout.Label("");

        GUILayout.Label("");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Inspector :", GUILayout.Width(90));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();



        GUILayout.Label("");
        EditorGUILayout.HelpBox("This script Manager Game Rules.", MessageType.Info);
        GUILayout.Label("");


        SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript.inventoryItemCar);

        serializedObject2.Update();
        SerializedProperty m_b_mobile             = serializedObject2.FindProperty("b_mobile");
        SerializedProperty m_mobileMaxSpeedOffset = serializedObject2.FindProperty("mobileMaxSpeedOffset");
        SerializedProperty mobileWheelStearingOffsetReactivity = serializedObject2.FindProperty("mobileWheelStearingOffsetReactivity");

        //SerializedProperty m_b_Countdown = serializedObject2.FindProperty ("b_Countdown");
        //SerializedProperty m_b_LapCounter = serializedObject2.FindProperty ("b_LapCounter");


// -->Mobile Options
        EditorGUILayout.BeginVertical(style_Yellow_Strong);



        EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section." +
                                "\n" +
                                "\n-You could modify the Max speed for all car on Mobile." +
                                "\n" +
                                "-You could modify the wheel stearing reactivity for all cars on mobile." +
                                "\n", MessageType.Info);

        if (m_b_mobile.boolValue)
        {
            if (GUILayout.Button("Cars are setup for Mobile Inputs"))
            {
                m_b_mobile.boolValue = false;
            }
        }
        else
        {
            if (GUILayout.Button("Cars are setup for Desktop Inputs"))
            {
                m_b_mobile.boolValue = true;
            }
        }


        if (m_b_mobile.boolValue)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Mobile Max Speed Offset :", GUILayout.Width(220));
            EditorGUILayout.PropertyField(m_mobileMaxSpeedOffset, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Mobile Wheel Stearing Offset Reactivity :", GUILayout.Width(220));
            EditorGUILayout.PropertyField(mobileWheelStearingOffsetReactivity, new GUIContent(""));
            EditorGUILayout.EndHorizontal();
        }



        EditorGUILayout.EndVertical();


// --> Countdown

/*		EditorGUILayout.BeginVertical (style_Orange);
 *              EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section.",MessageType.Info);
 *
 *              if (m_b_Countdown.boolValue) {
 *                      if (GUILayout.Button ("Countdown is activated when game Start")) {
 *                              //b_UseCountdown.boolValue = false;
 *                              m_b_Countdown.boolValue = false;
 *                      }
 *              } else {
 *                      if (GUILayout.Button ("Countdown is deactivated when game Start")) {
 *                              //b_UseCountdown.boolValue = true;
 *                              m_b_Countdown.boolValue = true;
 *                      }
 *              }
 *              EditorGUILayout.EndVertical ();*/

// --> Lap Counter

        /*	EditorGUILayout.BeginVertical (style_Blue);
         *      EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section.",MessageType.Info);
         *      if (!lapCounter) {
         *              GameObject tmpObj = GameObject.FindGameObjectWithTag ("TriggerStart");
         *              if (tmpObj)
         *                      lapCounter = tmpObj.GetComponent<LapCounter> ();
         *      }
         *
         *      if (lapCounter) {
         *              //SerializedObject serializedObject1 = new UnityEditor.SerializedObject (lapCounter);
         *              //serializedObject1.Update ();
         *              //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
         *              //SerializedProperty m_lapNumber = serializedObject1.FindProperty ("lapNumber");
         *
         *
         *              if (m_b_LapCounter.boolValue) {
         *                      if (GUILayout.Button ("Lap Counter is activated")) {
         *                              m_b_LapCounter.boolValue = false;
         *                      }
         *              } else {
         *                      if (GUILayout.Button ("Lap Counter is deactivated")) {
         *                              m_b_LapCounter.boolValue = true;
         *                      }
         *              }
         *
         *              //serializedObject1.ApplyModifiedProperties ();
         *      }
         *      EditorGUILayout.EndVertical ();*/

        serializedObject2.ApplyModifiedProperties();

        GUILayout.Label("");
        GUILayout.Label("");
        // --> Lap Counter
        EditorGUILayout.BeginVertical(style_Yellow_01);
        EditorGUILayout.HelpBox("The next sections only affect this scene.", MessageType.Info);
        if (!lapCounter)
        {
            GameObject tmpObj = GameObject.FindGameObjectWithTag("TriggerStart");
            if (tmpObj)
            {
                lapCounter = tmpObj.GetComponent <LapCounter> ();
            }
        }

        if (lapCounter)
        {
            SerializedObject serializedObject1 = new UnityEditor.SerializedObject(lapCounter);
            serializedObject1.Update();
            //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
            SerializedProperty m_lapNumber = serializedObject1.FindProperty("lapNumber");

            // --> Lap Numbers
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Lap number:", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_lapNumber, new GUIContent(""));
            EditorGUILayout.EndHorizontal();


            serializedObject1.ApplyModifiedProperties();
        }
        EditorGUILayout.EndVertical();

        GUILayout.Label("");

        serializedObject.ApplyModifiedProperties();
    }