示例#1
0
        private void Awake()
        {
            responder = GetComponent <ButtonResponder>();

            if (responder == null)
            {
                Debug.LogWarningFormat("Button Handler[{0}] requires a Button Responder. Deleting script.", gameObject);
            }
        }
 public void OnExit(ButtonResponder responder)
 {
     if (state.Equals(ButtonState.On) || state.Equals(ButtonState.Enter))
     {
         state = ButtonState.Exit;
         responder.ExitTrigger(this);
         responder.OffTrigger(this);
     }
     else
     {
         state = ButtonState.Off;
         responder.OffTrigger(this);
     }
 }
 public void OnStay(ButtonResponder responder)
 {
     if (state.Equals(ButtonState.Off) || state.Equals(ButtonState.Exit))
     {
         state = ButtonState.Enter;
         responder.EnterTrigger(this);
         responder.StayTrigger(this);
     }
     else
     {
         state = ButtonState.On;
         responder.StayTrigger(this);
     }
 }
 public void OnSubmit(ButtonResponder responder, bool forceTrue = false)
 {
     if (forceTrue)
     {
         Submit = true;
         responder.Submit(this);
     }
     else
     {
         Submit = !Submit;
         if (Submit)
         {
             responder.Submit(this);
         }
     }
 }