File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 1
1
# eppz! ` Geometry `
2
2
3
+ * 0.8.2
4
+
5
+ + `PolygonSource`
6
+ + Offset now can be manipulated at runtime
7
+ + Maintain the original polygon, so offset polygon can be recalculated any time
8
+
3
9
* 0.8.0
4
10
5
11
+ Test scenes
Original file line number Diff line number Diff line change @@ -20,19 +20,21 @@ public class PolygonSource : MonoBehaviour
20
20
21
21
22
22
public Transform [ ] pointTransforms ;
23
- [ Range ( - 2 , 2 ) ] public float offset = 0.0f ;
23
+ public float offset = 0.0f ;
24
24
25
25
public enum UpdateMode { Awake , Update , LateUpdate } ;
26
26
public UpdateMode update = UpdateMode . Awake ;
27
27
28
- public Polygon polygon ;
28
+ Polygon _polygon ;
29
+ Polygon _offsetPolygon ;
30
+ public Polygon polygon { get { return ( offset != 0.0f ) ? _offsetPolygon : _polygon ; } }
29
31
30
32
31
33
void Awake ( )
32
34
{
33
35
// Construct a polygon model from transforms (if not created by a root polygon already).
34
- if ( polygon == null ) polygon = Polygon . PolygonWithSource ( this ) ;
35
- if ( offset != 0.0f ) polygon = polygon . OffsetPolygon ( offset ) ;
36
+ if ( _polygon == null ) _polygon = Polygon . PolygonWithSource ( this ) ;
37
+ if ( offset != 0.0f ) _offsetPolygon = _polygon . OffsetPolygon ( offset ) ;
36
38
}
37
39
38
40
void Update ( )
@@ -50,8 +52,8 @@ void LateUpdate()
50
52
void UpdateModel ( )
51
53
{
52
54
// Update polygon model with transforms, also update calculations.
53
- polygon . UpdatePointPositionsWithSource ( this ) ;
54
- if ( offset != 0.0f ) polygon = polygon . OffsetPolygon ( offset ) ;
55
+ _polygon . UpdatePointPositionsWithSource ( this ) ;
56
+ if ( offset != 0.0f ) _offsetPolygon = _polygon . OffsetPolygon ( offset ) ;
55
57
}
56
58
}
57
59
}
Original file line number Diff line number Diff line change @@ -27,18 +27,23 @@ public class PolygonLineRenderer : GeometryLineRenderer
27
27
public bool normals = false ;
28
28
29
29
public Polygon polygon ;
30
+ PolygonSource polygonSource ;
30
31
31
32
32
33
void Start ( )
33
34
{
34
35
// Model reference.
35
- PolygonSource polygonSource = GetComponent < PolygonSource > ( ) ;
36
+ polygonSource = GetComponent < PolygonSource > ( ) ;
37
+
36
38
if ( polygonSource != null )
37
39
{ polygon = polygonSource . polygon ; }
38
40
}
39
41
40
42
protected override void OnDraw ( )
41
43
{
44
+ if ( polygonSource != null )
45
+ { polygon = polygonSource . polygon ; }
46
+
42
47
if ( polygon == null ) return ; // Only having polygon
43
48
44
49
DrawRect ( polygon . bounds , boundsColor ) ;
Original file line number Diff line number Diff line change @@ -80,7 +80,6 @@ public static Polygon PolygonWithSource(PolygonSource polygonSource)
80
80
if ( eachChildPolygonSource != null )
81
81
{
82
82
Polygon eachSubPolygon = Polygon . PolygonWithSource ( eachChildPolygonSource ) ;
83
- eachChildPolygonSource . polygon = eachSubPolygon ; // Inject into source
84
83
rootPolygon . AddPolygon ( eachSubPolygon ) ;
85
84
}
86
85
}
You can’t perform that action at this time.
0 commit comments