PreviousObject() public method

public PreviousObject ( ) : GameObject
return GameObject
Ejemplo n.º 1
0
    private void CardboardGazeChange(object sender)
    {
        // You can grab the data from the sender instead of the CardboardControl object
        CardboardControlGaze gaze = sender as CardboardControlGaze;

        // We can access to the object we're looking at
        // gaze.IsHeld will make sure the gaze.Object() isn't null
        if (gaze.IsHeld() && gaze.Object().name.Contains("Cube"))
        {
            ChangeObjectColor(gaze.Object().name);
            if (gaze.Object().name == "HighlightCube")
            {
                // Highlighting can help identify which objects can be interacted with
                // The reticle is hidden by default but we already toggled that in the Inspector
                cardboard.reticle.Highlight(Color.red);
            }
        }
        // We also can access to the last object we looked at
        // gaze.WasHeld() will make sure the gaze.PreviousObject() isn't null
        if (gaze.WasHeld() && gaze.PreviousObject().name.Contains("Cube"))
        {
            ResetObjectColor(gaze.PreviousObject().name);
            // Use these to undo reticle hiding and highlighting
            cardboard.reticle.Show();
            cardboard.reticle.ClearHighlight();
        }

        // Be sure to set the Reticle Layer Mask on the CardboardControlManager
        // to grow the reticle on the objects you want. The default is everything.

        // Not used here are gaze.Forward(), gaze.Right(), and gaze.Rotation()
        // which are useful for things like checking the view angle or shooting projectiles
    }
	// Be sure to set the Reticle Layer Mask on the CardboardControlManager
	// to grow the reticle on the objects you want. The default is everything.

	//TODO: detect if object is destroyed. Check if current gaze object still exists?


	private void CardboardGazeChange(object sender) {
		// You can grab the data from the sender instead of the CardboardControl object
		gaze = sender as CardboardControlGaze;
		// We can access to the object we're looking at
		// gaze.IsHeld will make sure the gaze.Object isn't null
		if (gaze.IsHeld() && gaze.Object().name.Contains("Asteroid")) {
			//ChangeObjectColor(gaze.Object().name);
			// Highlighting can help identify which objects can be interacted with
			// The pointer is hidden by default but we already toggled that in the inspector
			//currentObject = gaze.Object();
			//InvokeRepeating("TargetExistsCheck", 1, 1);
			cardboard.reticle.Highlight(Color.red);
			//autoFireOn = true;
		}
		// We also can access to the last object we looked at
		// gaze.WasHeld will make sure the gaze.PreviousObject isn't null
		if (gaze.WasHeld() && gaze.PreviousObject().name.Contains("Asteroid")) {
			//ResetObjectColor(gaze.PreviousObject().name);
			// Use these to undo pointer hiding and highlighting
			//cardboard.reticle.Show();
			CancelInvoke ("TargetExistsCheck");
			autoFireOn = false;
			cardboard.reticle.ClearHighlight();
		}
	}