mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 13:59:22 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
37 lines
1.0 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|