mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
Add VolumetricFogVolumeTool editor tool to edit volume bounds (#3465)
Co-authored-by: Kicks <nolandimensions@gmail.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Sandbox;
|
||||
|
||||
namespace Editor;
|
||||
|
||||
public class VolumetricFogVolumeTool : EditorTool<VolumetricFogVolume>
|
||||
{
|
||||
private IDisposable _componentUndoScope;
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
var volumetricFogVolume = GetSelectedComponent<VolumetricFogVolume>();
|
||||
if ( volumetricFogVolume == null )
|
||||
return;
|
||||
|
||||
var currentBounds = volumetricFogVolume.Bounds;
|
||||
|
||||
using ( Gizmo.Scope( "Volumetric Fog Volume Editor", volumetricFogVolume.WorldTransform ) )
|
||||
{
|
||||
if ( Gizmo.Control.BoundingBox( "Bounds", currentBounds, out var newBounds ) )
|
||||
{
|
||||
if ( Gizmo.WasLeftMousePressed )
|
||||
{
|
||||
_componentUndoScope = SceneEditorSession.Active.UndoScope( "Resize Volumetric Fog Volume Bounds" ).WithComponentChanges( volumetricFogVolume ).Push();
|
||||
}
|
||||
volumetricFogVolume.Bounds = newBounds;
|
||||
}
|
||||
|
||||
if ( Gizmo.WasLeftMouseReleased )
|
||||
{
|
||||
_componentUndoScope?.Dispose();
|
||||
_componentUndoScope = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user