private void HandleGravity() { if (ActionGravity == ACTIVABLE_OPTION.NOTHING) { return; } // It's important to give full controll to the user in terms of gravity management, this instruction // is usefull for example when the user drops and object that its attachable it will lock causing // the problem of not being able to activate gravity again (By unlocking it this problem is solved). if (IO.ActualGravityState == Gaze_GravityState.LOCKED) { Gaze_GravityManager.ChangeGravityState(IO, Gaze_GravityRequestType.UNLOCK); } if (ActionGravity == ACTIVABLE_OPTION.ACTIVATE) { Gaze_GravityManager.ChangeGravityState(IO, Gaze_GravityRequestType.ACTIVATE_AND_DETACH); } else { Gaze_GravityManager.ChangeGravityState(IO, Gaze_GravityRequestType.DEACTIVATE_AND_ATTACH); } Gaze_GravityManager.ChangeGravityState(IO, Gaze_GravityRequestType.SET_AS_DEFAULT); }
/// <summary> /// Shows the alter gravity option and warns the user if he desn't have a rigidbody /// </summary> private void ShowGravityOption() { actionsScript.ActionGravity = (Gaze_Actions.ACTIVABLE_OPTION)EditorGUILayout.EnumPopup("Gravity:", actionsScript.ActionGravity); // Warn the user if he is trying to change the gravity of an IO that does not have a rigibody on the root if (actionsScript.ActionGravity != Gaze_Actions.ACTIVABLE_OPTION.NOTHING) { Gaze_InteractiveObject IO = actionsScript.GetIO(); if (IO.GetComponentInParent <Rigidbody>() == null) { if (GUILayout.Button("+ Add Rigidbody")) { Gaze_GravityManager.AddRigidBodyToIO(IO); } EditorGUILayout.HelpBox("No rigidbody found on " + IO.name, MessageType.Error); } } }