Ejemplo n.º 1
0
    void Update()
    {
        Collider[] colliders = new Collider[3];

        int count = Physics.OverlapBoxNonAlloc(
            myTransform.position + bc.center,
            bc.size / 2,
            colliders,
            myTransform.rotation,
            ignoreLayers);

        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                if (interactive == null || !interactive.enabled ||
                    (interactive.gameObject.GetInstanceID() != colliders[i].gameObject.GetInstanceID()))
                {
                    if (interactive)
                    {
                        interactive.Dehighlight();
                    }

                    interactive = null;

                    Interactive n = colliders[i].GetComponent <Interactive>();
                    if (n && n.enabled)
                    {
                        interactive = n;
                        interactive.Highlight();
                        break;
                    }
                }
            }
        }
        else
        {
            if (interactive)
            {
                interactive.Dehighlight();
                interactive = null;
            }
        }

        UpdateUIHint();
    }