Editor/Effects/SFXREnvelopeEditor.cs
using Editor;
using Sandbox;
using System.Linq;
namespace SFXR.Editor;
[CustomEditor( typeof( SFXREnvelope ) )]
public class SFXREnvelopeEditor : ComponentEditorWidget
{
SFXREnvelope Envelope;
public SFXREnvelopeEditor( SerializedObject obj ) : base( obj )
{
var defaultInspector = new PropertyControlSheet();
defaultInspector.AddObject( obj );
Envelope = obj.Targets.First() as SFXREnvelope;
Layout = Layout.Column();
Layout.Add( defaultInspector );
Layout.AddSpacingCell( 5 );
Layout.AddSpacingCell( 90 );
}
protected override void OnPaint()
{
base.OnPaint();
Rect adsrRect = new Rect( 12, 138, Width - 30, 80 );
Paint.SetBrush( Theme.ControlBackground );
Paint.SetPen( Theme.ControlBackground );
Paint.DrawRect( adsrRect, 2 );
Paint.SetPen( Theme.Green, 2 );
Envelope.GetCurve().DrawLine( adsrRect, 3, 0, 1 );
}
}