Esempio n. 1
0
 void OnEnable()
 {
     highlightEvent    = serializedObject.FindProperty("highlightEvent");
     highlightDuration = serializedObject.FindProperty("highlightDuration");
     triggerMode       = serializedObject.FindProperty("triggerMode");
     raycastCamera     = serializedObject.FindProperty("raycastCamera");
     raycastSource     = serializedObject.FindProperty("raycastSource");
     trigger           = (HighlightTrigger2D)target;
     trigger.Init();
 }
        public void SwitchesCollider(Transform newObject)
        {
            if (currentEffect != null)
            {
                if (OnObjectHighlightEnd != null)
                {
                    //if(InteractionChecker.Instance.lastHighlightedObject_Closest == null)
                    OnObjectHighlightEnd(currentEffect.gameObject);
                }
                if (InteractionChecker.Instance.lastHighlightedObject_Closest == null)
                {
                    currentEffect.SetHighlighted(false);
                }
                currentEffect = null;
            }
            currentObject = newObject;
            if (newObject == null)
            {
                return;
            }
            HighlightTrigger2D ht = newObject.GetComponent <HighlightTrigger2D> ();

            if (ht != null && ht.enabled)
            {
                return;
            }

            if (OnObjectHighlightStart != null)
            {
                bool cancelHighlight = false;
                OnObjectHighlightStart(newObject.gameObject, ref cancelHighlight);
                if (cancelHighlight)
                {
                    return;
                }
            }

            HighlightEffect2D otherEffect = newObject.GetComponent <HighlightEffect2D> ();

            currentEffect = otherEffect != null ? otherEffect : baseEffect;
            currentEffect.SetTarget(currentObject.transform);
            currentEffect.SetHighlighted(true);
            //Debug.Log("highlighting " + newObject);
            if (highlightEvent > 0)
            {
                CancelInvoke();
                Invoke("CancelHighlight", highlightDuration);
            }
        }