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; } }