Skip to content

Commit d083ef6

Browse files
committed
BREAKING CHANGE: If you parented ParticlesFollowBezier to its spline or vice versa, particle system's rotation may change after the update. Instead of parenting, consider using BezierAttachment component (see demo scene)
- "Always" option for "Auto Construct Spline" and/or "Auto Calculate Normals" buttons now have runtime support (i.e. it is no longer an editor-only functionality) - Added onSplineChanged event to BezierSpline to get notified when spline is modified - Added CalculateEvenlySpacedPoints function to find uniformly spaced normalizedT values on the spline (it returns a lookup table with convenience functions). Instead of calling the function with default parameters, use the 'evenlySpacedPoints' property instead which is cached and is updated automatically when spline is modified - Added BezierLineRenderer component that synchronizes a Line Renderer with a spline - Added BendMeshAlongBezier component that deforms a mesh to bend it in the direction of a spline - Added BezierAttachment component that moves/rotates an object together with a spline - Added "High Quality" option to BezierWalkerWithTime and BezierWalkerLocomotion components that will tradeoff quality with performance - Added "Bezier Solution" section to Project Settings (Preferences on older Unity versions) to customize the Scene view gizmos - Added tooltips to important variables and buttons - Added read-only "spline" and "index" properties to BezierPoint - Updated demo scene
1 parent f53642f commit d083ef6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3496
-636
lines changed
File renamed without changes.
21.2 KB
Loading

.github/Images/BezierAttachment.png

16.4 KB
Loading

.github/Images/BezierLineRenderer.png

12.6 KB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

.github/Images/GizmoSettings.png

16.8 KB
Loading
File renamed without changes.
File renamed without changes.

.github/README.md

Lines changed: 75 additions & 49 deletions
Large diffs are not rendered by default.

Plugins/BezierSolution/Attributes.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using UnityEngine;
2+
#if UNITY_EDITOR
3+
using UnityEditor;
4+
#endif
5+
6+
namespace BezierSolution
7+
{
8+
public class MinMaxRangeAttribute : PropertyAttribute
9+
{
10+
public float min;
11+
public float max;
12+
13+
public MinMaxRangeAttribute( float min, float max )
14+
{
15+
this.min = min;
16+
this.max = max;
17+
}
18+
}
19+
}
20+
21+
#if UNITY_EDITOR
22+
namespace BezierSolution.Extras
23+
{
24+
[CustomPropertyDrawer( typeof( MinMaxRangeAttribute ) )]
25+
public class BaseInputDrawer : PropertyDrawer
26+
{
27+
private const float MIN_MAX_SLIDER_TEXT_FIELD_WIDTH = 45f;
28+
29+
// Min-max slider credit: https://github.com/Unity-Technologies/UnityCsReference/blob/61f92bd79ae862c4465d35270f9d1d57befd1761/Editor/Mono/Inspector/LightEditor.cs#L328-L363
30+
public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )
31+
{
32+
MinMaxRangeAttribute minMaxRange = attribute as MinMaxRangeAttribute;
33+
34+
SerializedProperty minProp = property.FindPropertyRelative( "x" );
35+
SerializedProperty maxProp = property.FindPropertyRelative( "y" );
36+
37+
position = EditorGUI.PrefixLabel( position, label );
38+
EditorGUI.BeginProperty( position, GUIContent.none, property );
39+
40+
Rect minRect = new Rect( position ) { width = MIN_MAX_SLIDER_TEXT_FIELD_WIDTH };
41+
Rect maxRect = new Rect( position ) { xMin = position.xMax - MIN_MAX_SLIDER_TEXT_FIELD_WIDTH };
42+
Rect sliderRect = new Rect( position ) { xMin = minRect.xMax + 5f, xMax = maxRect.xMin - 5f };
43+
44+
EditorGUI.BeginChangeCheck();
45+
46+
EditorGUI.PropertyField( minRect, minProp, GUIContent.none );
47+
48+
Vector2 value = property.vector2Value;
49+
EditorGUI.BeginChangeCheck();
50+
EditorGUI.MinMaxSlider( sliderRect, ref value.x, ref value.y, minMaxRange.min, minMaxRange.max );
51+
if( EditorGUI.EndChangeCheck() )
52+
property.vector2Value = value;
53+
54+
EditorGUI.PropertyField( maxRect, maxProp, GUIContent.none );
55+
56+
if( EditorGUI.EndChangeCheck() )
57+
{
58+
float x = minProp.floatValue;
59+
float y = maxProp.floatValue;
60+
61+
if( x < minMaxRange.min || x > minMaxRange.max )
62+
minProp.floatValue = Mathf.Clamp( x, minMaxRange.min, minMaxRange.max );
63+
if( y < minMaxRange.min || y > minMaxRange.max )
64+
maxProp.floatValue = Mathf.Clamp( y, minMaxRange.min, minMaxRange.max );
65+
}
66+
67+
EditorGUI.EndProperty();
68+
}
69+
}
70+
}
71+
#endif

Plugins/BezierSolution/Attributes/MinMaxRangeAttribute.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)