-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple rigidbody drawer and enum pop-up... (#1902)
* Added simple debug component editor for rigidbody, added searchbar for searching through the hierarchy when attempting to find a gameobject with a specific name or component. * Undid showing the debuggers when debugging, removed extraneous whitespace from the NitroxDebugManager class, expanded the mass text input field * Undo searchbar in hierarchy because there is already one in the other debugger. * Added pagination to the existing search functionality. * Added additional rigidbody fields, reworked search results display logic * Reworked the rigidbody layout to use NitroxGUILayout, added support for Flags enums to the EnumPopup. * Make velocity and angular velocity read-only. * Set the read-only vector3 back to editable textboxes. * Added method to handle an unknown Enum type. * Added enum visibility toggle. Co-authored-by: Measurity <[email protected]>
- Loading branch information
Showing
5 changed files
with
329 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.Debuggers.Drawer.Unity | ||
{ | ||
/// <summary> | ||
/// Draws a Rigidbody component on the gameobjects in the <see cref="SceneDebugger"/> | ||
/// </summary> | ||
public class RigidbodyDrawer : IDrawer | ||
{ | ||
private const float LABEL_WIDTH = 120; | ||
private const float VALUE_MAX_WIDTH = 405; | ||
|
||
public Type[] ApplicableTypes => new[] { typeof(Rigidbody) }; | ||
|
||
public void Draw(object target) | ||
{ | ||
Rigidbody rb = (Rigidbody)target; | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Mass", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
rb.mass = NitroxGUILayout.FloatField(rb.mass, VALUE_MAX_WIDTH); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Drag", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
rb.drag = NitroxGUILayout.FloatField(rb.drag, VALUE_MAX_WIDTH); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Angular Drag", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
rb.angularDrag = NitroxGUILayout.FloatField(rb.angularDrag, VALUE_MAX_WIDTH); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Use Gravity"); | ||
NitroxGUILayout.Separator(); | ||
rb.useGravity = NitroxGUILayout.BoolField(rb.useGravity); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Is Kinematic"); | ||
NitroxGUILayout.Separator(); | ||
rb.isKinematic = NitroxGUILayout.BoolField(rb.isKinematic); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Interpolate", GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
rb.interpolation = NitroxGUILayout.EnumPopup(rb.interpolation, NitroxGUILayout.VALUE_WIDTH); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Collision Detection", GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
rb.collisionDetectionMode = NitroxGUILayout.EnumPopup(rb.collisionDetectionMode, NitroxGUILayout.VALUE_WIDTH); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Freeze Rotation"); | ||
NitroxGUILayout.Separator(); | ||
rb.freezeRotation = NitroxGUILayout.BoolField(rb.freezeRotation); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Velocity", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
VectorDrawer.DrawVector3(rb.velocity, VALUE_MAX_WIDTH); | ||
} | ||
|
||
GUILayout.Space(10); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Angular Velocity", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
VectorDrawer.DrawVector3(rb.angularVelocity, VALUE_MAX_WIDTH); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.