Class SDFCurve
Draws a curve with multiple points. Rendered in SDF (signed distance field).
Namespace: MouseDance.Runtime
Assembly: MouseDance.Runtime.dll
Syntax
public class SDFCurve : MonoBehaviour
  Fields
_camera
Declaration
[SerializeField]
protected Camera _camera
  Field Value
| Type | Description | 
|---|---|
| Camera | 
_canvasTransform
Declaration
[SerializeField]
protected RectTransform _canvasTransform
  Field Value
| Type | Description | 
|---|---|
| RectTransform | 
_controlPoints
Declaration
protected readonly List<Vector2> _controlPoints
  Field Value
| Type | Description | 
|---|---|
| List<Vector2> | 
_curveSmoothnessPercent
Declaration
[SerializeField]
[Range(0.01F, 1F)]
[Tooltip("How many points the curve will have compared to its pixel length. 1.0 means to use 100% of the pixel length value.\n\nThe pixel length is a high value, and we don't need that much points in the curve to produce a smooth-looking curve (you may even have problems in WebGL builds if the amount of points is too high), so a value of 0.1 (10%) is advisable as more than enough, but you can change this value as needed.")]
protected float _curveSmoothnessPercent
  Field Value
| Type | Description | 
|---|---|
| Single | 
_materialNonCompute
Declaration
[SerializeField]
protected Material _materialNonCompute
  Field Value
| Type | Description | 
|---|---|
| Material | 
_materialPropertyBlock
Declaration
protected MaterialPropertyBlock _materialPropertyBlock
  Field Value
| Type | Description | 
|---|---|
| MaterialPropertyBlock | 
_materialWithCompute
Declaration
[SerializeField]
protected Material _materialWithCompute
  Field Value
| Type | Description | 
|---|---|
| Material | 
_max
Bottom-rightmost corner of the curve, in osu!pixels
Declaration
protected Vector2 _max
  Field Value
| Type | Description | 
|---|---|
| Vector2 | 
_meshFilter
Declaration
[SerializeField]
protected MeshFilter _meshFilter
  Field Value
| Type | Description | 
|---|---|
| MeshFilter | 
_min
Upper-leftmost corner of the curve, in osu!pixels
Declaration
protected Vector2 _min
  Field Value
| Type | Description | 
|---|---|
| Vector2 | 
_points
Declaration
protected readonly List<Vector2> _points
  Field Value
| Type | Description | 
|---|---|
| List<Vector2> | 
_positionAdjustLandscape
Declaration
[SerializeField]
protected Vector2 _positionAdjustLandscape
  Field Value
| Type | Description | 
|---|---|
| Vector2 | 
_positionAdjustPortrait
Declaration
[SerializeField]
protected Vector2 _positionAdjustPortrait
  Field Value
| Type | Description | 
|---|---|
| Vector2 | 
_positionsBuffer
Declaration
protected ComputeBuffer _positionsBuffer
  Field Value
| Type | Description | 
|---|---|
| ComputeBuffer | 
_rectTransform
Declaration
[SerializeField]
protected RectTransform _rectTransform
  Field Value
| Type | Description | 
|---|---|
| RectTransform | 
_renderer
Declaration
[SerializeField]
protected Renderer _renderer
  Field Value
| Type | Description | 
|---|---|
| Renderer | 
_screenAdjust
Declaration
[SerializeField]
protected RectTransform _screenAdjust
  Field Value
| Type | Description | 
|---|---|
| RectTransform | 
_slider
Declaration
protected Slider _slider
  Field Value
| Type | Description | 
|---|---|
| OsuParsers.Beatmaps.Objects.Slider | 
SPECIFIED_POINT_COUNT_LIMIT
Declaration
protected const int SPECIFIED_POINT_COUNT_LIMIT = 2147483647
  Field Value
| Type | Description | 
|---|---|
| Int32 | 
USE_COMPUTE_KEYWORD
Declaration
protected const string USE_COMPUTE_KEYWORD = "USE_COMPUTE"
  Field Value
| Type | Description | 
|---|---|
| String | 
Methods
Init(Camera, RectTransform, RectTransform)
Assign the dependencies that SDFCurve needs.
Declaration
public virtual void Init(Camera viewCamera, RectTransform canvasTransform, RectTransform screenAdjust)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Camera | viewCamera | Needed to get the camera's orthographic size (SDFCurve works best when displayed by a camera in orthographic mode). The orthographic size is needed due to how the SDFCurve is rendered, it affects how the SDFCurve is positioned.  | 
      
| RectTransform | canvasTransform | Transform component of the Unity UI Canvas that is displaying this SDFCurve. Needed because it should affect how the SDFCurve is positioned and scaled.  | 
      
| RectTransform | screenAdjust | Used for additional offset on how the SDFCurve is positioned.  | 
      
OnDestroy()
Declaration
protected virtual void OnDestroy()
  Reposition()
Declaration
public virtual void Reposition()
  Reposition(Slider, Boolean)
If Slider position has changed, this updates the currently shown SDF curve to that new position.
Declaration
public virtual void Reposition(Slider slider, bool applyImmediately)
  Parameters
| Type | Name | Description | 
|---|---|---|
| OsuParsers.Beatmaps.Objects.Slider | slider | Where position comes from.  | 
      
| Boolean | applyImmediately | Apply the MaterialPropertyBlock now. Set to false if you plan to do it later.  | 
      
Resize(Single, Single, Single, Boolean)
Change line thickness of the curve.
Declaration
public virtual void Resize(float radius, float globalSizeMultiplier, float sliderSizeMultiplier, bool applyImmediately)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Single | radius | Thickness of the line. Since the line has circular caps, we express line thickness as a radius.  | 
      
| Single | globalSizeMultiplier | Multiplier to the size coming from CircleRadiusMultiplier.  | 
      
| Single | sliderSizeMultiplier | Multiplier to the size coming from _sliderThicknessMultiplier.  | 
      
| Boolean | applyImmediately | Apply the MaterialPropertyBlock now. Set to false if you plan to do it later.  | 
      
SetOpacity(Single)
Set the alpha of the entire curve. Use this for fading-in or fading-out.
Declaration
public virtual void SetOpacity(float alpha)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Single | alpha | Value from 0.0 to 1.0.  | 
      
Show(Slider, Single, Single, Single, Gradient, Color)
Show the SDF Curve with the specified properties. Points of the curve will come from the Slider data.
Declaration
public virtual void Show(Slider slider, float radius, float globalSizeMultiplier, float sliderSizeMultiplier, Gradient colour, Color borderColour)
  Parameters
| Type | Name | Description | 
|---|---|---|
| OsuParsers.Beatmaps.Objects.Slider | slider | Where point data will come from.  | 
      
| Single | radius | Thickness of the line. Since the line has circular caps, we express line thickness as a radius.  | 
      
| Single | globalSizeMultiplier | Multiplier to the size coming from CircleRadiusMultiplier.  | 
      
| Single | sliderSizeMultiplier | Multiplier to the size coming from _sliderThicknessMultiplier.  | 
      
| Gradient | colour | Colour to apply to the body of the curve. This is a gradient so we're blending between two colors.  | 
      
| Color | borderColour | Colour to apply to the borders of the curve.  | 
      
Show(Slider, Single, Single, Single, Color, Color, Color)
Show the SDF Curve with the specified properties. Points of the curve will come from the Slider data.
Declaration
public virtual void Show(Slider slider, float radius, float globalSizeMultiplier, float sliderSizeMultiplier, Color gradientInnerColour, Color gradientOuterColour, Color borderColour)
  Parameters
| Type | Name | Description | 
|---|---|---|
| OsuParsers.Beatmaps.Objects.Slider | slider | Where point data will come from.  | 
      
| Single | radius | Thickness of the line. Since the line has circular caps, we express line thickness as a radius.  | 
      
| Single | globalSizeMultiplier | Multiplier to the size coming from CircleRadiusMultiplier.  | 
      
| Single | sliderSizeMultiplier | Multiplier to the size coming from _sliderThicknessMultiplier.  | 
      
| Color | gradientInnerColour | Color of the line starting from the center.  | 
      
| Color | gradientOuterColour | Color of the line at the outer edges.  | 
      
| Color | borderColour | Colour to apply to the borders of the curve.  |