38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
//this script stors the selected color to the playerprefs
|
|
|
|
public class ColorButton : MonoBehaviour
|
|
{
|
|
[SerializeField] Color buttonColor;
|
|
[SerializeField] GameObject nameInput;
|
|
|
|
private void Start()
|
|
{
|
|
GetComponent<Image>().color = buttonColor;
|
|
|
|
GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
PlayerPrefs.SetFloat("playerColorR", buttonColor.r);
|
|
PlayerPrefs.SetFloat("playerColorG", buttonColor.g);
|
|
PlayerPrefs.SetFloat("playerColorB", buttonColor.b);
|
|
PlayerPrefs.Save();
|
|
transform.parent.parent.gameObject.SetActive(false);
|
|
changeScene();
|
|
});
|
|
}
|
|
|
|
public void changeScene()
|
|
{
|
|
//if the name has already been set, change the scene
|
|
if (nameInput.activeInHierarchy == false)
|
|
{
|
|
SceneManager.LoadScene("RoomCreation");
|
|
}
|
|
}
|
|
}
|