public void OnFingerTap(Lean.LeanFinger finger)
    {
        // Does the prefab exist?
        if (Prefab != null)
        {
            // Make sure the finger isn't over any GUI elements
            if (finger.IsOverGui == false)
            {
                // Clone the prefab, and place it on the spawning plane where the finger was tapped
                Ray hit = finger.GetRay();
                RaycastHit hitResult;

                if (mSpawningCollider.Raycast(hit, out hitResult, 100.0f))
                {
                    Transform clone = GameObject.Instantiate(Prefab) as Transform;
                    clone.transform.position = hitResult.point;

                    // Set image target as parent
                    clone.transform.parent = transform;

                    // Set image target's TrackableBehaviour component as parent (in the event that the above does not work)
                    //clone.transform.parent = mTrackableBehaviour.transform;

                    clone.rotation = Quaternion.identity;

                    clones.Add(clone);
                }
            }
        }
    }
	public void OnFingerTap(Lean.LeanFinger finger)
	{
		if (finger.IsOverGui == false && mButtonCollider != null)
		{
			Ray hit = finger.GetRay();
			RaycastHit hitResult;

			if (mButtonCollider.Raycast(hit, out hitResult, 10.0f))
			{
				Application.LoadLevel(Scene);
			}
		}
	}
Exemple #3
0
	public void OnFingerTap(Lean.LeanFinger finger)
	{
		if (finger.IsOverGui == false && mButtonCollider != null)
		{
			Ray hit = finger.GetRay();
			RaycastHit hitResult;

			if (mButtonCollider.Raycast(hit, out hitResult, 10.0f))
			{
				newCam.enabled = !newCam.enabled;
				oldCam.enabled = !oldCam.enabled;
			}
		}
	}
Exemple #4
0
	public void OnFingerTap(Lean.LeanFinger finger)
	{
		if (finger.IsOverGui == false && mButtonCollider != null)
		{
			Ray hit = finger.GetRay();
			RaycastHit hitResult;

			if (mButtonCollider.Raycast(hit, out hitResult, 10.0f))
			{
				mButtonCollider = null;
				mEnterScene = true;
				Play.gameObject.SetActive(false);
			}
		}
	}
Exemple #5
0
	public void OnFingerDown(Lean.LeanFinger finger)
	{
		// Raycast information
		var ray = finger.GetRay();
		var hit = default(RaycastHit);
		
		// Was this finger pressed down on a collider?
		if (Physics.Raycast(ray, out hit, float.PositiveInfinity, LayerMask) == true)
		{
			// Was that collider this one?
			if (hit.collider.gameObject == gameObject)
			{
				// Set the current finger to this one
				draggingFinger = finger;
			}
		}
	}
	public void OnFingerTap(Lean.LeanFinger finger) {
		if (finger.IsOverGui == false && !finished) {
			if (!placeClip.isPlaying){
				placeClip.Play();
			}
			Ray hit = finger.GetRay();
			RaycastHit hitResult;
			bool hitFirst = false;
			bool hitPlay = false;

			if (direction == 1) {
				for (int i = 0; i < frontView.transform.childCount; i++) {
					if (frontView.transform.GetChild (i).GetComponent<BoxCollider> ().Raycast (hit, out hitResult, 1000.0f)) {
						if (frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2000) {
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material = notPlaced;
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2001;
						} else if (frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2001) {
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material = placed;
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2000;
						}
						hitFirst = true;
						hitPlay = true;
						break;
					}
				}
				for (int i = 0; i < backView.transform.childCount; i++) {
					if (hitFirst)
						break;
					if (backView.transform.GetChild (i).GetComponent<BoxCollider> ().Raycast (hit, out hitResult, 1000.0f)) {
						if (backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2000) {
							backView.transform.GetChild (i).GetComponent<Renderer> ().material = notPlaced;
							backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2001;
						} else if (backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2001) {
							backView.transform.GetChild (i).GetComponent<Renderer> ().material = placed;
							backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2000;
						}
						hitPlay = true;
						break;
					}
				}
			} else {
				for (int i = 0; i < backView.transform.childCount; i++) {
					if (backView.transform.GetChild (i).GetComponent<BoxCollider> ().Raycast (hit, out hitResult, 1000.0f)) {
						if (backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2000) {
							backView.transform.GetChild (i).GetComponent<Renderer> ().material = notPlaced;
							backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2001;
						} else if (backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2001) {
							backView.transform.GetChild (i).GetComponent<Renderer> ().material = placed;
							backView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2000;
						}
						hitFirst = true;
						hitPlay = true;
						break;
					}
				}
				for (int i = 0; i < frontView.transform.childCount; i++) {
					if (hitFirst)
						break;
					if (frontView.transform.GetChild (i).GetComponent<BoxCollider> ().Raycast (hit, out hitResult, 1000.0f)) {
						if (frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2000) {
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material = notPlaced;
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2001;
						} else if (frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue == 2001) {
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material = placed;
							frontView.transform.GetChild (i).GetComponent<Renderer> ().material.renderQueue = 2000;
						}
						hitPlay = true;
						break;
					}
				}
			}

			/*Renderer[] renderF = frontView.GetComponentsInChildren<Renderer> ();
			foreach (Renderer f in renderF){
				if (f.material.renderQueue == 2000 || f.material.renderQueue == 2001) {
					if (f.GetComponent<BoxCollider> ().Raycast (hit, out hitResult, 1000.0f)) {
						if (f.material == notPlaced) {
							f.material = placed;
							f.material.renderQueue = 2000;
						} else {
							f.material = notPlaced;
							f.material.renderQueue = 2001;
						}
						break;
					}
				}
			}
				
			Renderer[] renderB = backView.GetComponentsInChildren<Renderer> ();
			foreach (Renderer b in renderB){
				if (b.material.renderQueue == 2000 || b.material.renderQueue == 2001) {
					if (b.GetComponent<BoxCollider> ().Raycast (hit, out hitResult, 1000.0f)) {
						if (b.material == notPlaced) {
							b.material = placed;
							b.material.renderQueue = 2000;
						} else {
							b.material = notPlaced;
							b.material.renderQueue = 2001;
						}
						break;
					}
				}
			}*/
		}
	}
	public void OnFingerTap(Lean.LeanFinger finger)
	{
		// Does the prefab exist?
		if (Prefab != null)
		{
			// Make sure the finger isn't over any GUI elements
			if (finger.IsOverGui == false)
			{
				Ray hit = finger.GetRay();
				RaycastHit hitResult;
				var position = hit.origin;

				Vector3 referenceForward;
				Vector3 newDirection;
				float angle1, angle2, angle3;

				for (int i = 0; i < 7; i++) {
					if (mPieceCollider[i] == null)
						continue;

					if (mPieceCollider[i].Raycast(hit, out hitResult, 100.0f)) // see if collide
					{
						int j = i * 6;
						referenceForward = Vertices[j].transform.position - position;
						newDirection = Vertices[j+3].transform.position - position;
						angle1 = Vector3.Angle(newDirection, referenceForward);
						
						referenceForward = Vertices[j+1].transform.position - position;
						newDirection = Vertices[j+4].transform.position - position;
						angle2 = Vector3.Angle(newDirection, referenceForward);
						
						referenceForward = Vertices[j+2].transform.position - position;
						newDirection = Vertices[j+5].transform.position - position;
						angle3 = Vector3.Angle(newDirection, referenceForward);
						
						if (angle1 < Treshold && angle2 < Treshold && angle3 < Treshold)
						{
							//position = hitResult.point;
							//var rotation = Quaternion.identity;
							//var clone    = (GameObject)Instantiate(Prefab, position, rotation);
							// Make sure the prefab gets destroyed after some time
							//Destroy(clone, 2.0f);
							swap (i);
							mPieceCollider[i] = null;
							break;
						}
						break;
					}
				}
			}
		}
	}