using UnityEngine; using System.Collections; public class DiaphragmOpenButtonController : MonoBehaviour { public Button1 openPredicate; private float gateDirection = 1.0f; public float gateSpeed = 1.0f; private float gateState = 1.0f; public Diaphragm target; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (openPredicate != null) { gateDirection = openPredicate.State() ? -1.0f : 1.0f; } gateState = Mathf.Clamp01 (gateState + Time.deltaTime * gateSpeed * gateDirection); if (target != null) { target.State = gateState; } } }