using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
// Sets the script to be executed later than all default scripts
// This is helpful for UI, since other things may need to be initialized before setting the UI
[DefaultExecutionOrder(1000)]
public class MenuUIHandler : MonoBehaviour
{
public ColorPicker ColorPicker;
public void NewColorSelected(Color color)
{
// add code here to handle when a color is selected
foreach(Color choosenColor in ColorPicker.AvailableColors)
{
ColorPicker.ColorButtonPrefab.interactable = true;
color = ColorPicker.SelectedColor;
}
}
private void Start()
{
ColorPicker.Init();
//this will call the NewColorSelected function when the color picker have a color button clicked.
ColorPicker.onColorChanged += NewColorSelected;
}
public void StartMainScene()
{
SceneManager.LoadScene("Main");
}
public void ExitFromApplication()
{
Application.Quit();
Debug.Log("Exit");
}
public void SaveColor()
{
if (ColorPicker.ColorButtonPrefab.interactable == true)
{
PlayerPrefs.SetString("SetColor", ColorPicker.onColorChanged.ToString());
PlayerPrefs.Save();
}
}
public void LoadColor()
{
PlayerPrefs.GetString("SetColor", ColorPicker.onColorChanged.ToString());
}
}