Example #1
0
    void OnTriggerEnter(Collider other)
    {
        // Only do this if the thing entering has the triggering object component
        //and that it is currently triggering stuff
        IsTriggeringObject trigger = other.gameObject.GetComponent <IsTriggeringObject>();

        if (trigger != null)
        {
            IsTriggeringObject.eventWrapper eventObj = new IsTriggeringObject.eventWrapper(stateChanged, trigger);
            trigger.AddChangedStatusFunction(eventObj);
            objectsOnButton.Add(eventObj);

            if (trigger.IsCurrentlyTriggering)
            {
                // If there was no block here before
                if (BlocksOnButton == 0)
                {
                    // Activate the button
                    signal.Trigger();
                    ChangeIndicatorMaterial(active);
                }

                BlocksOnButton++;
            }
            else
            {
                if (BlocksOnButton == 0)
                {
                    ChangeIndicatorMaterial(couldBeActive);
                }
            }
        }
    }
Example #2
0
    void OnTriggerEnter(Collider other)
    {
        // Only do this if the thing entering has the triggering object component
        //and that it is currently triggering stuff
        IsTriggeringObject trigger = other.gameObject.GetComponent <IsTriggeringObject>();

        if (trigger != null)
        {
            IsTriggeringObject.eventWrapper eventObj = new IsTriggeringObject.eventWrapper(stateChanged, trigger);
            trigger.AddChangedStatusFunction(eventObj);
            objectsOnButton.Add(eventObj);

            if (trigger.IsCurrentlyTriggering)
            {
                Entered();
            }
        }
    }