コード例 #1
0
 private void OnTriggerExit(Collider other)
 {
     if (control.Toggleable)
     {
         // Check if the outgoing object was part of the circuit
         if (conductingObj != null && conductingObj == other.gameObject)
         {
             // If the object was part of the circuit, turn off the objects in ConduitControl
             control.TurnOff();
             conductingObj = null;
         }
     }
     else
     {
         Debug.LogWarning("Conduit Controls attached to Box Conduits must be set to Toggleable in order to function");
     }
 }
コード例 #2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Conduit"))  // Look for a conduit tag
        {
            ConduitControl condControl = collision.gameObject.GetComponent <ConduitControl>();

            if (!condControl.Toggleable)
            {
                condControl.TurnOn();   // Turn on the conduit
            }
            else
            {
                if (condControl.ConduitEnabled)
                {
                    condControl.TurnOff();
                }
                else
                {
                    condControl.TurnOn();
                }
            }
        }
    }