public void Update() { if (Application.isPlaying == true && GUIUtility.hotControl == 0) { if (SGT_Input.GetKey((KeyCode)rotationRequires, 1) == true) { var x = SGT_Input.DragY * -rotationSpeed; var y = SGT_Input.DragX * rotationSpeed; targetRotation *= Quaternion.Euler(x, y, 0.0f); } } var currentRotation = transform.localRotation; if (Application.isPlaying == true) { var dampenFactor = SGT_Helper.DampenFactor(rotationDampening, Time.deltaTime); currentRotation = Quaternion.Slerp(currentRotation, targetRotation, dampenFactor); } else { currentRotation = targetRotation; } SGT_Helper.SetLocalRotation(transform, currentRotation); }
public void Update() { if (Application.isPlaying == true && GUIUtility.hotControl == 0) { if (Input.GetKey(KeyCode.Mouse0) == true) { var x = SGT_Input.DragY * -rotationSpeed; var y = SGT_Input.DragX * rotationSpeed; targetRotation *= Quaternion.Euler(x, y, 0.0f); } if (rotationRoll == true) { if (Input.GetKey(KeyCode.Mouse1) == true) { var z = SGT_Input.DragRoll; targetRotation *= Quaternion.Euler(0.0f, 0.0f, z); } } targetDistance -= SGT_Input.Zoom * (1.0f + targetDistance - distanceMin) * distanceSpeed; } targetDistance = Mathf.Clamp(targetDistance, distanceMin, distanceMax); var currentDistance = transform.localPosition.magnitude; var currentRotation = transform.localRotation; if (Application.isPlaying == true) { var rotationDampenFactor = SGT_Helper.DampenFactor(rotationDampening, Time.deltaTime); var distanceDampenFactor = SGT_Helper.DampenFactor(distanceDampening, Time.deltaTime); currentRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationDampenFactor); currentDistance = Mathf.Lerp(currentDistance, targetDistance, distanceDampenFactor); } else { currentRotation = targetRotation; currentDistance = targetDistance; } SGT_Helper.SetLocalRotation(transform, currentRotation); SGT_Helper.SetLocalPosition(transform, currentRotation * new Vector3(0.0f, 0.0f, -currentDistance)); }
private void UpdateRingRotations() { if (generatedRotations != null && generatedRotations.Length > 0) { ringMesh.Resize(generatedRotations.Length); ringMesh.Update(); for (var i = 0; i < generatedRotations.Length; i++) { var meshRoot = ringMesh.GetMeshGameObject(i); if (meshRoot != null) { SGT_Helper.SetLocalRotation(meshRoot.transform, generatedRotations[i]); } } } else { ringMesh.Resize(1); ringMesh.Update(); } }