Files
racesm/Assets/Scripts/map selector script/Map Selector Script.cs
2024-04-25 21:43:53 +02:00

58 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Unity.Mathematics;
public class MapSelectorScript : MonoBehaviour
{
public GameObject[] Maps;
GameObject currentMap;
quaternion currentRotation;
public GameObject CameraRotator;
public int scene;
void Start()
{
DisableAllMaps();
SelectMap(0);
}
private void FixedUpdate()
{
CameraRotator.transform.eulerAngles += Vector3.up * 0.7f;
}
void DisableAllMaps()
{
foreach (GameObject map in Maps)
{
map.SetActive(false);
}
}
void SelectMap(int index)
{
DisableAllMaps();
currentMap = Maps[index];
currentMap.SetActive(true);
}
public void ChangeToTrack2()
{
scene = 2;
SelectMap(0);
}
public void ChangeToTrack3()
{
scene = 3;
SelectMap(1);
}
public void SelectMapAndLoadScene()
{
SceneManager.LoadScene(scene);
}
}