55 lines
No EOL
1.4 KiB
C#
55 lines
No EOL
1.4 KiB
C#
using ShiroginSDK.Runtime.Services.Base;
|
|
using ShiroginSDK.Runtime.Services.Interfaces;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace ShiroginSDK.Samples.ThemeSample.Scripts
|
|
{
|
|
/// <summary>
|
|
/// Simple demo UI for switching between themes at runtime.
|
|
/// Uses the ThemeService through the ServiceLocator system.
|
|
/// </summary>
|
|
public class ThemeSampleUI : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Button fireThemeButton;
|
|
|
|
[SerializeField]
|
|
private Button snowThemeButton;
|
|
|
|
private IThemeService _themeService;
|
|
|
|
private void Awake()
|
|
{
|
|
_themeService = ServiceLocator.Get<IThemeService>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (snowThemeButton != null)
|
|
snowThemeButton.onClick.AddListener(OnSnowThemeClick);
|
|
|
|
if (fireThemeButton != null)
|
|
fireThemeButton.onClick.AddListener(OnFireThemeClick);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (snowThemeButton != null)
|
|
snowThemeButton.onClick.RemoveAllListeners();
|
|
|
|
if (fireThemeButton != null)
|
|
fireThemeButton.onClick.RemoveAllListeners();
|
|
}
|
|
|
|
private void OnSnowThemeClick()
|
|
{
|
|
_themeService?.SetTheme("Snow");
|
|
}
|
|
|
|
private void OnFireThemeClick()
|
|
{
|
|
_themeService?.SetTheme("Fire");
|
|
}
|
|
}
|
|
} |