Beispiel #1
0
    /* ===================== Unity Events ================== */

    protected virtual void OnTriggerEnter(Collider other)
    {
        //Check if collider was the cursor
        if (!other.gameObject.CompareTag("VRUI-Cursor"))
        {
            return;
        }

        IsTriggering = true;

        InteractingGO = other.gameObject;

        if (!InteractingGO)
        {
            return;
        }

        InteractingController = InteractingGO.GetComponentInParent <VRUI_Controller>();
        if (InteractingController == null)
        {
            InteractingController = InteractingGO.GetComponent <VRUI_Controller>();
        }


        if (IsActivating())
        {
            ActivateBegin();
        }
        else
        {
            HoverBegin();
        }
    }
Beispiel #2
0
    /// <summary>
    /// Called when trigger exited by collider. Sets all references to cursor to null
    /// </summary>
    /// <param name="other">Collider that exited trigger</param>
    private void OnTriggerExit(Collider other)
    {
        //Check if collider was the cursor
        if (!other.gameObject.CompareTag("VRUI-Cursor"))
        {
            return;
        }

        CursorController = null;
        Cursor           = null;
    }
Beispiel #3
0
    /* ================ Collision Detection ================ */

    /// <summary>
    /// Called when triggered by collider. If other has controller component, also store reference to that
    /// </summary>
    /// <param name="other">Collider that triggered</param>
    private void OnTriggerEnter(Collider other)
    {
        //Check if collider was the cursor
        if (!other.gameObject.CompareTag("VRUI-Cursor"))
        {
            return;
        }

        Cursor = other.gameObject;
        if (Cursor)
        {
            CursorController = Cursor.GetComponentInParent <VRUI_Controller>();
        }
    }
Beispiel #4
0
    /// <summary>
    /// Handles calling of interaction events and simulating surface
    /// </summary>
    protected virtual void Update()
    {
        if (IsTriggering)
        {
            if (IsActivating())
            {
                if (!WasActivating)
                {
                    ActivateBegin();
                }
                else
                {
                    Activating();
                }
                WasActivating = true;
            }
            else
            {
                if (WasActivating)
                {
                    ActivateEnd();
                }
                else
                {
                    Hovering();
                }
                WasActivating = false;
            }
        }
        else
        {
            if (WasActivating)
            {
                ActivateEnd();

                InteractingController = null;
                InteractingGO         = null;
            }
            VolumePhysics.Simulate(Time.deltaTime);
        }
    }
Beispiel #5
0
    protected virtual void OnTriggerExit(Collider other)
    {
        //Check if collider was the cursor
        if (!other.gameObject.CompareTag("VRUI-Cursor"))
        {
            return;
        }

        if (IsActivating())
        {
            return;
        }

        HoverEnd();

        InteractingController = null;

        InteractingGO = null;

        IsTriggering = false;
    }