protected void PlaceActorAtCursor() { // Place the actor & it's shadow plane at the last detected cursor postion. var pos = m_cursorManager.GetCurrentCursorPosition(); var rot = m_cursorManager.GetCurrentCursorRotation(); if (m_actorTransform == null) { m_actorTransform = GameObject.Instantiate(m_actorPrefab, pos, rot).transform; } else { m_actorTransform.position = pos; m_actorTransform.rotation = rot; } if (m_shadowPlaneTransform == null) { m_shadowPlaneTransform = GameObject.Instantiate(m_shadowPlanePrefab, pos, rot).transform; } else { m_shadowPlaneTransform.position = pos; m_shadowPlaneTransform.rotation = rot; } }
void Update() { if (m_isHidden) { return; } if (Utils.IsTouchOnUI()) { // Ignore touch events if a button is pressed return; } if (Utils.WasTouchStartDetected()) { Vector3 cursorPos = m_cursorManager.GetCurrentCursorPosition(); if (m_numVerticesAdded == 0) { InitializePartialMesh(cursorPos); ++m_numVerticesAdded; } else { AddNextVertex(cursorPos); if (m_numVerticesAdded == 4) { // Update the mesh collider var meshCollider = m_partialQuad.GetComponent <MeshCollider>(); meshCollider.sharedMesh = m_partialMesh; m_partialQuad.transform.parent = m_quadsHolder; m_partialMesh = null; m_partialQuad = null; m_numVerticesAdded = 0; } } } else { if (m_numVerticesAdded > 0) { Vector3 cursorPos = m_cursorManager.GetCurrentCursorPosition(); m_lineRenderer.SetPosition(m_numVerticesAdded, cursorPos); } } }
// Update is called once per frame void Update() { if (Utils.WasTouchStartDetected()) { if (m_objectTransform == null) { // On the first tap, instantiate the object at the cursor location. m_objectTransform = GameObject.Instantiate(m_objectPrefab, m_cursorManager.GetCurrentCursorPosition(), Quaternion.identity).transform; } else { // On subsequent taps, move the object to the new location. m_objectTransform.position = m_cursorManager.GetCurrentCursorPosition(); } StopAllCoroutines(); StartCoroutine(PointObjectToGeographicNorthPole(m_objectTransform, m_cameraTransform)); } }
// Update is called once per frame void Update() { if (!m_isObjectPlaced) { if (Utils.WasTouchStartDetected()) { // Place the actor & it's shadow plane at the last detected cursor postion. var pos = m_cursorManager.GetCurrentCursorPosition(); var rot = m_cursorManager.GetCurrentCursorRotation(); if (m_actor == null) { m_actor = GameObject.Instantiate(m_actorPrefab, pos, rot); m_materialToUpdate = Utils.FindMaterialOnObject(m_actor, "COLOR BASICO 04"); m_actorAnimator = m_actor.GetComponentInChildren <Animator> (); } if (m_shadowPlane == null) { m_shadowPlane = GameObject.Instantiate(m_shadowPlanePrefab, pos, rot); } m_isObjectPlaced = true; } } else if (m_isCursorHidden) { Debug.Log("Capture color and enable cursor"); m_actorAnimator.SetTrigger(m_animationId); m_materialToUpdate.color = m_pixelCapturer.m_lastCapturedColor; m_cursorManager.Enable(); m_isCursorHidden = false; } else if (Utils.WasTouchStartDetected()) { Debug.Log("Hide cursor and render a frame before capturing the color."); m_cursorManager.Disable(); m_pixelCapturer.m_shouldCaptureOnNextFrame = true; m_isCursorHidden = true; } }