Ejemplo n.º 1
0
 protected override void Awake()
 {
     base.Awake();
     gameManager    = FindObjectOfType <DockLevelGameManager>();
     objectCollider = GetComponent <BoxCollider2D>();
     gazeableObject = GetComponent <GazeableObject>();
 }
    public void Start()
    {
        messageDisplayer      = GetComponentInParent <MessageDisplayer>();
        gazeableObject        = GetComponent <GazeableObject>();
        spriteRenderer.sprite = levelSprites[0];

        checkIfLevelUnlocked();
    }
Ejemplo n.º 3
0
 private void ClearCurrentObject()
 {
     if (currentGazeObject != null)
     {
         currentGazeObject.OnGazeExit();
         SetReticleColor(inactiveReticleColor);
         currentGazeObject = null;
     }
 }
Ejemplo n.º 4
0
 private void ClearCurrentObject()
 {
     if (currentGazeObject != null)
     {
         currentGazeObject.OnGazeExit();
         SetReticleColor(originalColor);
         currentGazeObject.Pressed -= HandleGazeablePressed;
         currentGazeObject          = null;
     }
 }
 private void ClearCurrentObject()
 {
     if (currentGazeObject != null)
     {
         //finish looking at the current obj
         currentGazeObject.OnGazeExit();
         //clear the current currentGazeObject
         currentGazeObject = null;
     }
 }
Ejemplo n.º 6
0
    /**
     * @ProcessGaze() method
     * process the gaze object interactions like when we move and staire somthing, stop stairing
     * and many more
     */
    public void ProcessGaze()
    {
        Ray        raycastRay = new Ray(transform.position, transform.forward);
        RaycastHit hitInfo;

        Debug.DrawRay(raycastRay.origin, raycastRay.direction * 100);

        if (Physics.Raycast(raycastRay, out hitInfo))
        {
            // 1: check if the object is interactable

            // get the GameObject from the hitInfo
            // below code will get the currentObject which we are looking at
            GameObject hitObj = hitInfo.collider.gameObject;

            // get the GazebaleObject from the hit object
            // also @gazeObj would be null if the object we are looking at is not GazeableObject
            GazeableObject gazeObj = hitObj.GetComponentInParent <GazeableObject>();

            // object has a GazeableObject component
            if (gazeObj != null)
            {
                // object we're looking at is different
                if (gazeObj != currentGazeObject)
                {
                    ClearCurrentObject();
                    currentGazeObject = gazeObj;
                    currentGazeObject.OnGazeEnter(hitInfo);

                    // set reticle color
                    SetReticleColor(activeReticleColor);
                }
                else
                {
                    // else means we are looking at the same object as erlier
                    currentGazeObject.OnGaze(hitInfo);
                }
            }
            else
            {
                // else means we are looking at a non GazeableObject
                ClearCurrentObject();
            }

            lastHit = hitInfo;
        }
        else
        {
            ClearCurrentObject();
        }
    }
    // Create Gaze System
    public void ProcessGaze()
    {
        Ray raycastRay = new Ray(transform.position, transform.forward);

        RaycastHit hitInfo;

        Debug.DrawRay(raycastRay.origin, raycastRay.direction * 100);

        if (Physics.Raycast(raycastRay, out hitInfo))
        {
            // Do something to the object

            // Check if the object is interactable

            // Get the gameObject from the hitInfo
            GameObject hitObj = hitInfo.collider.gameObject;

            // Get the GazeableObject from the hit object
            GazeableObject gazeObj = hitObj.GetComponentInParent <GazeableObject> ();

            // Object has a GazeableObject component
            if (gazeObj != null)
            {
                // Object we're looking at is different
                if (gazeObj != currentGazeObject)
                {
                    ClearCurrentObject();

                    currentGazeObject = gazeObj;

                    currentGazeObject.OnGazeEnter(hitInfo);

                    SetReticleColor(activeReticleColor);
                }
                else
                {
                    currentGazeObject.OnGaze(hitInfo);
                }
            }
            else
            {
                ClearCurrentObject();
            }

            lastHit = hitInfo;
        }
        else
        {
            ClearCurrentObject();
        }
    }
Ejemplo n.º 8
0
    private void ClearCurrentObject()
    {
        if (currentGazeObject != null)
        {
            // when clearing we call @OnGazeExit method
            currentGazeObject.OnGazeExit();

            // then setting the color of reticle back to default (gray)
            SetReticleColor(inactiveReticleColor);

            // clear the object as we are no longer looking at it
            currentGazeObject = null;
        }
    }
Ejemplo n.º 9
0
    void GazeableOjectInteract(bool isStart)
    {
        GazeableObject grabbedGazeableObject = GetGrabbedGazeableObject();

        if (grabbedGazeableObject != null)
        {
            if (isStart)
            {
                grabbedGazeableObject.DoGazeStart(this, VRTK_DeviceFinder.HeadsetTransform());
            }
            else
            {
                grabbedGazeableObject.DoGazeStop(this, VRTK_DeviceFinder.HeadsetTransform());
            }
        }
    }
    public void ProcessGaze()
    {
        Ray        raycastRay = new Ray(transform.position, transform.forward);
        RaycastHit hitInfo;

        //raycastRay.direction * 100 because raycastRay.direction is just a very small unit
        Debug.DrawRay(raycastRay.origin, raycastRay.direction * 100);

        if (Physics.Raycast(raycastRay, out hitInfo))
        {
            // Get the GameObject from the hitInfo
            GameObject hitObj = hitInfo.collider.gameObject;

            // Get the GazeableObject from the hit Object, if the obj is not gazable, gazeObj will be NULL
            GazeableObject gazeObj = hitObj.GetComponentInParent <GazeableObject>();

            // Check if object is gazeable
            if (gazeObj != null)
            {
                // Check if object we're looking at is different from the one we've been looking
                if (gazeObj != currentGazeObject)
                {
                    ClearCurrentObject();
                    currentGazeObject = gazeObj;
                    currentGazeObject.OnGazeEnter(hitInfo);
                }
                else
                {
                    //if we keep looking at the same object, call the OnGaze function
                    currentGazeObject.OnGaze(hitInfo);
                }
            }
            else
            {
                //if we're not looking at a gazeable object
                ClearCurrentObject();
            }
            //the last sucessful hit when we keep pressing on the button but moving our eye sight to a ungazeable object
            lastHit = hitInfo;
        }
        else
        {
            //if we're not looking at anything
            ClearCurrentObject();
        }
    }
Ejemplo n.º 11
0
    private void CheckForInput(RaycastHit hit)
    {
        if (Input.GetMouseButtonDown(0) && currentGazeObject != null)
        {
            currentSelectableObject = currentGazeObject;
            currentSelectableObject.OnPress(hit);
        }

        if (Input.GetMouseButtonDown(0) && currentSelectableObject != null)
        {
            currentSelectableObject.OnHold(hit);
        }

        if (Input.GetMouseButtonUp(0) && currentSelectableObject != null)
        {
            currentSelectableObject.OnRelease(hit);
            currentSelectableObject = null;
        }
    }
Ejemplo n.º 12
0
    private void CheckforInput(RaycastHit hitinfo)
    {
        if (Input.GetMouseButtonDown(0) && currentGazeObject != null)
        {
            currentSelectedObject = currentGazeObject;
            currentSelectedObject.OnPress(hitinfo);
        }

        // Check for hold
        else if (Input.GetMouseButton(0) && currentSelectedObject != null)
        {
            currentSelectedObject.OnHold(hitinfo);
        }
        // Check for release
        else if (Input.GetMouseButtonUp(0) && currentSelectedObject != null)
        {
            currentSelectedObject.OnRelease(hitinfo);
            currentSelectedObject = null;
        }
    }
Ejemplo n.º 13
0
    public void ProcessGaze()
    {
        var        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            var hitObject = hit.collider.gameObject;
            var gaze      = hitObject.GetComponentInParent <GazeableObject>();

            if (gaze != null)
            {
                if (gaze != currentGazeObject)
                {
                    ClearCurrentObject();
                    currentGazeObject = gaze;
                    gaze.OnGazeEnter(hit);
                    SetReticleColor(activeReticleColor);
                }
                else
                {
                    currentGazeObject.OnGaze(hit);
                }
            }
            else
            {
                ClearCurrentObject();
            }

            lastHit = hit;
        }
        else
        {
            ClearCurrentObject();
        }
    }
Ejemplo n.º 14
0
 private void CheckForInput(RaycastHit hitInfo)
 {
     //Debug.Log(Input.GetMouseButton(0));
     //Debug.Log(currentGazeObject);
     if (currentGazeObject != null)
     {
         //Debug.Log(currentGazeObject);
     }
     //Check for down (press the button, in that very moment)
     if (Input.GetMouseButtonDown(0) && currentGazeObject != null)
     {
         currentSelectedObject = currentGazeObject;
         currentSelectedObject.OnPress(hitInfo);
     }
     else if (Input.GetMouseButton(0) && currentGazeObject != null)
     {                       //Check for hold (for frames after, with button stll down)
         currentSelectedObject.OnHold(hitInfo);
     }
     else if (Input.GetMouseButton(0) && currentGazeObject != null)
     {                       //Check for hold (for frames after, with button stll down)
         currentSelectedObject.OnRelease(hitInfo);
         currentSelectedObject = null;
     }
 }
Ejemplo n.º 15
0
 protected override void Awake()
 {
     base.Awake();
     gazeableObject = GetComponent <GazeableObject>();
 }
 protected override void Awake()
 {
     base.Awake();
     gazeableObject = GetComponent <GazeableObject>();
     objectCollider = GetComponent <BoxCollider2D>();
 }
Ejemplo n.º 17
0
 private void AssignCurrentObject(GazeableObject gaze)
 {
     currentGazeObject          = gaze;
     currentGazeObject.Pressed += HandleGazeablePressed;
 }