48 lines
956 B
C#
48 lines
956 B
C#
using UnityEngine;
|
|
|
|
namespace Escape_Room_Engine.Desert.Scripts
|
|
{
|
|
public class EmissionToggle : MonoBehaviour
|
|
{
|
|
internal bool active;
|
|
|
|
private bool _previousActive;
|
|
private Material _material;
|
|
|
|
private void Awake()
|
|
{
|
|
_material = GetComponent<Renderer>().material;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
Changed();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (_previousActive != active)
|
|
{
|
|
Changed();
|
|
_previousActive = active;
|
|
}
|
|
}
|
|
|
|
private void Changed()
|
|
{
|
|
if (active)
|
|
{
|
|
_material.EnableKeyword("_EMISSION");
|
|
}
|
|
else
|
|
{
|
|
_material.DisableKeyword("_EMISSION");
|
|
}
|
|
}
|
|
|
|
public void SetActive(bool to)
|
|
{
|
|
this.active = to;
|
|
}
|
|
}
|
|
} |