Files
sbox-public/game/addons/tools/Code/Scene/Tools/Component/CapsuleColliderTool.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

37 lines
1.0 KiB
C#

using Sandbox;
namespace Editor;
public class CapsuleColliderTool : EditorTool<CapsuleCollider>
{
private IDisposable _componentUndoScope;
public override void OnUpdate()
{
var capsuleCollider = GetSelectedComponent<CapsuleCollider>();
if ( capsuleCollider == null )
return;
using ( Gizmo.Scope( "Capsule Collider Editor", capsuleCollider.WorldTransform ) )
{
var currentCapsule = new Capsule( capsuleCollider.Start, capsuleCollider.End, capsuleCollider.Radius );
if ( Gizmo.Control.Capsule( "capsule", currentCapsule, out var newCapsule, Gizmo.Colors.Green ) )
{
if ( _componentUndoScope == null )
{
_componentUndoScope = SceneEditorSession.Active.UndoScope( "Resize Capsule Collider" ).WithComponentChanges( capsuleCollider ).Push();
}
capsuleCollider.Start = newCapsule.CenterA;
capsuleCollider.End = newCapsule.CenterB;
capsuleCollider.Radius = newCapsule.Radius;
}
if ( Gizmo.WasLeftMouseReleased )
{
_componentUndoScope?.Dispose();
_componentUndoScope = null;
}
}
}
}