/// <summary> /// Performs all necessary initializations. /// </summary> private void Start() { // Create the 4 gizmos _objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); _objectRotationGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); _objectScaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo(); _objectUniversalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo(); // Call the 'SetEnabled' function on the parent gizmo to make sure // the gizmos are initially hidden in the scene. We want the gizmo // to show only when we have a target object available. _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // Link the selected objects list to the gizmos _objectMoveGizmo.SetTargetObjects(_selectedObjects); _objectRotationGizmo.SetTargetObjects(_selectedObjects); _objectScaleGizmo.SetTargetObjects(_selectedObjects); _objectUniversalGizmo.SetTargetObjects(_selectedObjects); // We initialize the work gizmo to the move gizmo by default. _workGizmo = _objectMoveGizmo; _workGizmoId = GizmoId.Move; // Find side menu sideMenu = GameObject.Find("SideMenu"); scene = sideMenu.GetComponent <SceneObjects>(); }
/// <summary> /// Performs all necessary initializations. /// </summary> private void Start() { // Create the 4 gizmos _objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); _objectRotationGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); _objectScaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo(); _objectUniversalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo(); // Call the 'SetEnabled' function on the parent gizmo to make sure // the gizmos are initially hidden in the scene. We want the gizmo // to show only when we have a target object available. _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // We initialize the work gizmo to the move gizmo by default. This means // that the first time an object is clicked, the move gizmo will appear. // You can change the default gizmo, by simply changing these 2 lines of // code. For example, if you wanted the scale gizmo to be the default work // gizmo, replace '_objectMoveGizmo' with '_objectScaleGizmo' and GizmoId.Move // with GizmoId.Scale. _workGizmo = _objectMoveGizmo; _workGizmoId = GizmoId.Move; }
/// <summary> /// Performs all necessary initializations. /// </summary> private void Start() { // Create the 4 gizmos _objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); _objectRotationGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); _objectScaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo(); _objectUniversalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo(); // Call the 'SetEnabled' function on the parent gizmo to make sure // the gizmos are initially hidden in the scene. We want the gizmo // to show only when we have a target object available. _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // Link the selected objects list to the gizmos // Note: The 'SetTargetObjects' function will instruct the gizmo to store // a direct reference to the '_selecteObjects' list. This means that // when you add or remove objects from this list, the gizmos will have // access to the most recent/updated collection. You don't need to call // 'SetTargetObjects' again when the list changes. _objectMoveGizmo.SetTargetObjects(_selectedObjects); _objectRotationGizmo.SetTargetObjects(_selectedObjects); _objectScaleGizmo.SetTargetObjects(_selectedObjects); _objectUniversalGizmo.SetTargetObjects(_selectedObjects); // We initialize the work gizmo to the move gizmo by default. This means // that the first time an object is clicked, the move gizmo will appear. // You can change the default gizmo, by simply changing these 2 lines of // code. For example, if you wanted the scale gizmo to be the default work // gizmo, replace '_objectMoveGizmo' with '_objectScaleGizmo' and GizmoId.Move // with GizmoId.Scale. _workGizmo = _objectMoveGizmo; _workGizmoId = GizmoId.Move; // <BEGIN TUTORIAL> // Get a reference to the object whose pivot we want to modify GameObject doorObject = GameObject.Find("GreenCube"); // Calculate the object's world OBB and then use the 'BoxMath.CalcBoxFaceCenter' // to calculate the center of the object's left face in world space. We will use // this face center as our pivot. OBB worldOBB = ObjectBounds.GetMeshWorldOBB(doorObject); Vector3 faceCenter = BoxMath.CalcBoxFaceCenter(worldOBB.Center, worldOBB.Size, worldOBB.Rotation, BoxFace.Left); // Use the 'SetObjectCustomLocalPivot' function to specify the object's pivot. // Note: We need to call 'InverseTransformPoint' on the face center because the function expects // a pivot point expressed in the object's local coordinate system. _objectRotationGizmo.SetObjectCustomLocalPivot(doorObject, doorObject.transform.InverseTransformPoint(faceCenter)); // Change the transform pivot to 'CustomObjectLocalPivot' _objectRotationGizmo.SetTransformPivot(GizmoObjectTransformPivot.CustomObjectLocalPivot); // <END TUTORIAL> }
// Start is called before the first frame update void Start() { // Create the 4 gizmos _objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); _objectRotationGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _workGizmo = _objectMoveGizmo; _workGizmoId = GizmoId.Move; }
/// <summary> /// This function is called to change the type of work gizmo. This is /// used in the 'Update' function in response to the user pressing the /// W,E,R,T keys to switch between different gizmo types. /// </summary> private void SetWorkGizmoId(GizmoId gizmoId) { // If the specified gizmo id is the same as the current id, there is nothing left to do if (gizmoId == _workGizmoId) { return; } // Start with a clean slate and disable all gizmos _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // At this point all gizmos are disabled. Now we need to check the gizmo id // and adjust the '_workGizmo' variable. _workGizmoId = gizmoId; if (gizmoId == GizmoId.Move) { _workGizmo = _objectMoveGizmo; } else if (gizmoId == GizmoId.Rotate) { _workGizmo = _objectRotationGizmo; } else if (gizmoId == GizmoId.Scale) { _workGizmo = _objectScaleGizmo; } else if (gizmoId == GizmoId.Universal) { _workGizmo = _objectUniversalGizmo; } // If we have any selected objects, we need to make sure the work gizmo is enabled if (_selectedObjects.Count != 0) { // Make sure the work gizmo is enabled. There is no need to check if the gizmo is already // enabled. The 'SetEnabled' call will simply be ignored if that is the case. _workGizmo.Gizmo.SetEnabled(true); // When working with transform spaces and pivots, the gizmos need to know about the pivot object. // This piece of information is necessary when the transform space is set to local because in that // case the gizmo will have its rotation synchronized with the target objects rotation. But because // there is more than one target object, we need to tell the gizmo which object to use. This is the // role if the pivot object in this case. This pivot object is also useful when the transform pivot // is set to 'ObjectMeshPivot' because it will be used to adjust the position of the gizmo. _workGizmo.SetTargetPivotObject(_selectedObjects[_selectedObjects.Count - 1]); } }
/// <summary> /// This function is called to change the type of work gizmo. This is /// used in the 'Update' function in response to the user pressing the /// W,E,R,T keys to switch between different gizmo types. /// </summary> private void SetWorkGizmoId(GizmoId gizmoId) { // If the specified gizmo id is the same as the current id, there is nothing left to do if (gizmoId == _workGizmoId) { return; } // Start with a clean slate and disable all gizmos _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // At this point all gizmos are disabled. Now we need to check the gizmo id // and adjust the '_workGizmo' variable. _workGizmoId = gizmoId; if (gizmoId == GizmoId.Move) { _workGizmo = _objectMoveGizmo; } else if (gizmoId == GizmoId.Rotate) { _workGizmo = _objectRotationGizmo; } else if (gizmoId == GizmoId.Scale) { _workGizmo = _objectScaleGizmo; } else if (gizmoId == GizmoId.Universal) { _workGizmo = _objectUniversalGizmo; } // If we have any selected objects, we need to make sure the work gizmo is enabled if (_selectedObjects.Count != 0) { // Make sure the work gizmo is enabled. There is no need to check if the gizmo is already // enabled. The 'SetEnabled' call will simply be ignored if that is the case. _workGizmo.Gizmo.SetEnabled(true); // The last step we need to perform is to make sure that the work gizmo is positioned // and rotated correctly. This is because the gizmos (as will become more clear in // later tutorials) have 2 properties such as transform space and transform pivot and // when the selected objects change, these 2 properties will dictate how the gizmo should // be positioned and rotated. In order to ensure that the correct position and rotation // are used, we need to call 'RefreshPositionAndRotation'. _workGizmo.RefreshPositionAndRotation(); } }
/// <summary> /// Performs all necessary initializations. /// </summary> private void Start() { // Create the 4 gizmos _objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); _objectRotationGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); _objectScaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo(); _objectUniversalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo(); // Call the 'SetEnabled' function on the parent gizmo to make sure // the gizmos are initially hidden in the scene. We want the gizmo // to show only when we have a target object available. _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // Link the selected objects list to the gizmos // Note: The 'SetTargetObjects' function will instruct the gizmo to store // a direct reference to the '_selecteObjects' list. This means that // when you add or remove objects from this list, the gizmos will have // access to the most recent/updated collection. You don't need to call // 'SetTargetObjects' again when the list changes. _objectMoveGizmo.SetTargetObjects(_selectedObjects); _objectRotationGizmo.SetTargetObjects(_selectedObjects); _objectScaleGizmo.SetTargetObjects(_selectedObjects); _objectUniversalGizmo.SetTargetObjects(_selectedObjects); // We initialize the work gizmo to the move gizmo by default. This means // that the first time an object is clicked, the move gizmo will appear. // You can change the default gizmo, by simply changing these 2 lines of // code. For example, if you wanted the scale gizmo to be the default work // gizmo, replace '_objectMoveGizmo' with '_objectScaleGizmo' and GizmoId.Move // with GizmoId.Scale. _workGizmo = _objectMoveGizmo; _workGizmoId = GizmoId.Move; // <BEGIN TUTORIAL> // Get a reference to the object whose position we will use as the world pivot GameObject pivotObject = GameObject.Find("Sphere"); // Set the world pivot _objectRotationGizmo.SetCustomWorldPivot(pivotObject.transform.position); _objectRotationGizmo.SetTransformPivot(GizmoObjectTransformPivot.CustomWorldPivot); // <END TUTORIAL> }
/// <summary> /// This function is called to change the type of work gizmo. This is /// used in the 'Update' function in response to the user pressing the /// W,E,R,T keys to switch between different gizmo types. /// </summary> private void SetWorkGizmoId(GizmoId gizmoId) { // If the specified gizmo id is the same as the current id, there is nothing left to do if (gizmoId == _workGizmoId) { return; } // Start with a clean slate and disable all gizmos _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); // At this point all gizmos are disabled. Now we need to check the gizmo id // and adjust the '_workGizmo' variable. _workGizmoId = gizmoId; if (gizmoId == GizmoId.Move) { _workGizmo = _objectMoveGizmo; } else if (gizmoId == GizmoId.Rotate) { _workGizmo = _objectRotationGizmo; } else if (gizmoId == GizmoId.Scale) { _workGizmo = _objectScaleGizmo; } else if (gizmoId == GizmoId.Universal) { _workGizmo = _objectUniversalGizmo; } // At this point, the work gizmo points to the correct gizmo based on the // specified gizmo id. All that's left to do is to activate the gizmo. // Note: We only activate the gizmo if we have a target object available. // If no target object is available, we don't do anything because we // only want to show a gizmo when a target is available for use. if (_targetObject != null) { _workGizmo.Gizmo.SetEnabled(true); } }
private void Start() { _objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); _objectRotateionGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); _objectScaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo(); _objectUniversalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo(); _objectMoveGizmo.SetTargetObjects(_selectObjects); _objectRotateionGizmo.SetTargetObjects(_selectObjects); _objectScaleGizmo.SetTargetObjects(_selectObjects); _objectUniversalGizmo.SetTargetObjects(_selectObjects); _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotateionGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); _workGizmoId = GizmoId.move; _workGizmo = _objectMoveGizmo; }
private void SetWorkGizmoId(GizmoId gizmoId) { // Start with a clean slate and disable all gizmos _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotationGizmo.Gizmo.SetEnabled(false); _workGizmoId = gizmoId; if (gizmoId == GizmoId.Move) { _workGizmo = _objectMoveGizmo; } else if (gizmoId == GizmoId.Rotate) { _workGizmo = _objectRotationGizmo; } if (_targetObject != null) { _workGizmo.Gizmo.SetEnabled(true); _workGizmo.RefreshPositionAndRotation(); } }
void SetWorkGizmoId(GizmoId gizmoId) { if (gizmoId == _workGizmoId) { return; } _objectMoveGizmo.Gizmo.SetEnabled(false); _objectRotateionGizmo.Gizmo.SetEnabled(false); _objectScaleGizmo.Gizmo.SetEnabled(false); _objectUniversalGizmo.Gizmo.SetEnabled(false); _workGizmoId = gizmoId; if (gizmoId == GizmoId.move) { _workGizmo = _objectMoveGizmo; } else if (gizmoId == GizmoId.Rotate) { _workGizmo = _objectRotateionGizmo; } else if (gizmoId == GizmoId.Scale) { _workGizmo = _objectScaleGizmo; } else if (gizmoId == GizmoId.Universal) { _workGizmo = _objectUniversalGizmo; } if (_selectObjects.Count != 0) { _workGizmo.Gizmo.SetEnabled(true); _workGizmo.RefreshPositionAndRotation(); } }