// Try to select this object. private void Select() { if (ObjectManipulationPointer.IsObjectSelected()) { return; } // This can be null in start, so let's just check here. if (automaticallyAssignPointer) { if (GvrPointerInputModule.Pointer != null) { controlTransform = GvrPointerInputModule.Pointer.PointerTransform; } } if (controlTransform == null) { return; } // Only select the object if it's in the correct state, and the state didn't change this frame. if (state != ObjectState.None || lastStateChangeFrame == Time.frameCount) { return; } OnSelect(); }
protected override void OnDeselect() { base.OnDeselect(); ObjectManipulationPointer.ReleaseSelected(gameObject.transform); // this.photonView.RPC("TurnOnGravity", PhotonTargets.AllViaServer); // Turn gravity off for this rigidbody. rigidbodyCmp.useGravity = useGravityDefault; // Make this rigidbody not kinematic. rigidbodyCmp.isKinematic = isKinematicDefault; ResetRigidbody(); }
void Update() { if (!ObjectManipulationPointer.IsObjectSelected() && interactiveObject.Hover) { targetHighlight = 1f; } else { targetHighlight = 0f; } highlight = Mathf.Lerp(highlight, targetHighlight, Time.deltaTime * highlightSpeed); materialPropertyBlock.SetFloat(highlightID, highlight); meshRenderer.SetPropertyBlock(materialPropertyBlock); }
protected override void OnSelect() { // Perform the transformation relative to control. Vector3 vectorToObject = transform.position - ControlPosition; float d = vectorToObject.magnitude; // Only select the object if it conforms to the min and max distance. if (d >= minDistance && d <= maxDistance) { ObjectManipulationPointer.SetSelected(transform, handleOffset); targetYaw = yaw; yawSpeed = 0; base.OnSelect(); } }
protected override void OnSelect() { // Perform the transformation relative to control. Vector3 vectorToObject = transform.position - ControlPosition; float d = vectorToObject.magnitude; // Only select the object if it conforms to the min and max distance. if (d >= minDistance && d <= maxDistance) { base.OnSelect(); // Call the static SetSelected() function on ObjectPointer. ObjectManipulationPointer.SetSelected(gameObject.transform, Vector3.zero); // The selected object sets initial values for the control transform. controlTransformPosition = transform.position; controlTransformRotation = transform.rotation; // Store the initial rotation for the object. objectStartRotation = controlTransformRotation; // If the distance vector cannot be normalized, use the look vector. if (d > NORMALIZATION_EPSILON) { normalizedForward = vectorToObject / d; } else { d = 0; normalizedForward = ControlForward; } // Reset distance interpolation values to current values. targetControlZDistance = controlZDistance = d; // Reset orientation interpolation values to 0. targetOrientationDelta = orientationDelta = Quaternion.identity; // Get the up vector for the object. Vector3 objectUp = transform.TransformDirection(Vector3.up); // Get the dot product of the object up vector and the world up vector. float dotUp = Vector3.Dot(objectUp, Vector3.up); // Mark whether the object is upside down or rightside up. objectInverted = dotUp < 0; } }
protected override void OnDeselect() { base.OnDeselect(); ObjectManipulationPointer.ReleaseSelected(gameObject.transform); ResetRigidbody(); }
protected override void OnDeselect() { ObjectManipulationPointer.ReleaseSelected(gameObject.transform); base.OnDeselect(); }