38 lines
558 B
C#
38 lines
558 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class Switch : MonoBehaviour
|
|
{
|
|
private Renderer curr_obj;
|
|
|
|
public bool Open;
|
|
|
|
public Color32 Open_color;
|
|
|
|
public Color32 Close_color;
|
|
|
|
private void Start()
|
|
{
|
|
curr_obj = GetComponent<Renderer>();
|
|
curr_obj.sharedMaterial.shader = Shader.Find("Standard");
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
set_lock();
|
|
}
|
|
|
|
private void set_lock()
|
|
{
|
|
if (Open)
|
|
{
|
|
curr_obj.material.SetColor("_EmissionColor", Open_color);
|
|
}
|
|
else
|
|
{
|
|
curr_obj.material.SetColor("_EmissionColor", Close_color);
|
|
}
|
|
}
|
|
}
|