ColorMode.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ColorMode : MonoBehaviour
{
GameObject RedC;
Transform RedCar;
Transform PinkCar;
GameObject PinkC;
Transform BlueCar;
GameObject BlueC;
public static ColorMode Instance { get; private set; }
//public void Awake()
//{
// Instance = this;
//}
public void Start()
{
Instance = this;
RedC = GameObject.Find("RedC");
RedCar = RedC.transform.Find("RedCar");
PinkC = GameObject.Find("PinkC");
PinkCar = PinkC.transform.Find("PinkCar");
BlueC = GameObject.Find("BlueC");
BlueCar = BlueC.transform.Find("BlueCar");
RedCar.gameObject.SetActive(false);
BlueCar.gameObject.SetActive(false);
}
public void ChRed()
{
PinkCar.gameObject.SetActive(false);
RedCar.gameObject.SetActive(true);
BlueCar.gameObject.SetActive(false);
}
public void ChPink()
{
PinkCar.gameObject.SetActive(true);
RedCar.gameObject.SetActive(false);
BlueCar.gameObject.SetActive(false);
}
public void ChBlue()
{
PinkCar.gameObject.SetActive(false);
RedCar.gameObject.SetActive(false);
BlueCar.gameObject.SetActive(true);
}
}
Redbut.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Redbut : MonoBehaviour
{
public void OnBtnStart()
{
ColorMode.Instance.ChRed();
}
}
Pinkbut.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pinkbut : MonoBehaviour
{
public void OnBtnStart()
{
ColorMode.Instance.ChPink();
}
}
Bluebut.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bluebut : MonoBehaviour
{
public void OnBtnStart()
{
ColorMode.Instance.ChBlue();
}
}