Beispiel #1
0
    /// Called every frame the user is still looking at a valid GameObject. This
    /// can be a 3D or UI element.
    ///
    /// The camera is the event camera, the target is the object the user is
    /// looking at, and the intersectionPosition is the intersection point of the
    /// ray sent from the camera on the object.
    public void OnGazeStay(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
                           bool isInteractive)
    {
        SetGazeTarget(intersectionPosition, isInteractive);
        // code for pick up
        if (isInteractive)
        {
            // exclude some functional components
            // CHANGE
            string tag = targetObject.tag;
            if (tag == "Inventory")
            {
                circularBar.fillAmount += Time.deltaTime;
                if (circularBar.fillAmount == 1)
                {
                    InventoryShow = !InventoryShow;
                    Inventory.SetActive(InventoryShow);
                    script.RefreshDisplay();
                    circularBar.fillAmount = 0;
                }
            }
            else if (tag == "Colors")
            {
                circularBar.fillAmount += Time.deltaTime;
                if (circularBar.fillAmount == 1)
                {
                    ColorShow = !ColorShow;
                    ColorCanvas.SetActive(ColorShow);
                    circularBar.fillAmount = 0;
                }
            }
            else if (tag == "Quit")
            {
                ;
            }
            else if (tag == "Reborn")
            {
                Debug.Log("Reborn");
            }
            // ENDCHANGE
            else if (tag != "SampleButton" && tag != "SlideBar" && tag != "Untagged" && tag != "Red" &&
                     tag != "White" && tag != "Black" && tag != "Yellow" && tag != "Green" && tag != "Blue" && tag != "Silver" && tag != "Pink")
            {
                circularBar.fillAmount += Time.deltaTime / time;
                if (circularBar.fillAmount == 1)
                {
                    targetObject.SetActive(false);
                    // access PlayerNew script
                    PlayerNew behavior = gameObject.GetComponentInParent <PlayerNew> ();
                    // record in the player's inventory
                    behavior.changeItem(targetObject.tag, 1, false, 100);
                    //CHANGE
                    script.RefreshDisplay();
                }
                //targetObject.SetActive (false);
                Debug.Log(targetObject.tag);
            }
        }


        //Debug.Log ("look");
//		if (isInteractive) {
//			camera.
//		}
//		GameObject other;
    }