Example #1
0
        /// <summary>Manually force the trigger to test if the target(s) is inside it</summary>
        public void TestTrigger()
        {
            var triggerPos = ProCamera2D.TargetsMidPoint;

            //   Debug.LogError("trigger pos:" + triggerPos);
            if (!UseTargetsMidPoint && TriggerTarget != null)
            {
                triggerPos = TriggerTarget.position;
            }

            if (TriggerShape == TriggerShape.RECTANGLE &&
                Utils.IsInsideRectangle(
                    Vector3H(_transform.position),
                    Vector3V(_transform.position),
                    Vector3H(_transform.localScale),
                    Vector3V(_transform.localScale),
                    Vector3H(triggerPos),
                    Vector3V(triggerPos)))
            {
                if (!_insideTrigger)
                {
                    EnteredTrigger();
                }
            }
            else if (TriggerShape == TriggerShape.CIRCLE &&
                     Utils.IsInsideCircle(
                         Vector3H(_transform.position),
                         Vector3V(_transform.position),
                         (Vector3H(_transform.localScale) + Vector3V(_transform.localScale)) * .25f,
                         Vector3H(triggerPos),
                         Vector3V(triggerPos)))
            {
                if (!_insideTrigger)
                {
                    EnteredTrigger();
                }
            }
            else
            {
                if (_insideTrigger)
                {
                    ExitedTrigger();
                }
            }
        }