puzzle module framework, puzzle a ball module
This commit is contained in:
48
Assets/Escape Room Engine/Desert/Scripts/EmissionToggle.cs
Normal file
48
Assets/Escape Room Engine/Desert/Scripts/EmissionToggle.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user