from github
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user