Can't set points on polyline
Why doesn't this work? Seems I can't set point positions?
polyline.PolyPoints[0].point.z = 3f;
Why doesn't this work? Seems I can't set point positions?
polyline.PolyPoints[0].point.z = 3f;
I found polyLine.PolyPoints[0].point.Set();
However now I'm getting a new error.
NullReferenceException: Object reference not set to an instance of an object
Shapes.ShapeRenderer.ApplyProperties () (at Assets/Shapes/Scripts/Runtime/Components/ShapeRenderer.cs:254)
Shapes.ShapeRenderer.SetFloatNow (System.Int32 prop, System.Single value) (at Assets/Shapes/Scripts/Runtime/Components/ShapeRenderer.cs:273)
Shapes.Disc.set_Radius (System.Single value) (at Assets/Shapes/Scripts/Runtime/Components/Disc.cs:115)
BuildingUiNear.ResizeShapes () (at Assets/game/scripts/game/buildings/ui/BuildingUiNear.cs:45)
I found polyLine.SetPointPosition() which works. Shouldn't there be documentation for this?!
Setting disc.Radius gives the following error.
NullReferenceException: Object reference not set to an instance of an object
Shapes.ShapeRenderer.ApplyProperties () (at Assets/Shapes/Scripts/Runtime/Components/ShapeRenderer.cs:254)
Shapes.ShapeRenderer.SetFloatNow (System.Int32 prop, System.Single value) (at Assets/Shapes/Scripts/Runtime/Components/ShapeRenderer.cs:273)
Shapes.Disc.set_Radius (System.Single value) (at Assets/Shapes/Scripts/Runtime/Components/Disc.cs:115)
BuildingUiNear.ResizeShapes () (at Assets/game/scripts/game/buildings/ui/BuildingUiNear.cs:42)
generally, when modifying polyline points, you'll either want to use the SetPointPosition() method, like you did
there is also a direct indexer on polyline itself, if you want to use that!
your line: polyline.PolyPoints[0].point.z = 3f; doesn't work, because C# doesn't work that way
PolylinePoint and Vector3 are both value types, which means when you access them, you're only modifying a copy, not a reference to the original data
the proper way to modify points would be to reassign the struct, as well as using the indexer like this:
PolylinePoint p = polyline[0]; // p is a copy, not a reference
p.point = new Vector3( p.point.x, p.point.y, 3f );
polyline[0] = p; // assign back to polyline
as for the errors - are they disabled objects? seems similar to this issue
closing this then, as there's already a topic on the other issue! assuming setting your polyline points is working and all :)
generally, when modifying polyline points, you'll either want to use the SetPointPosition() method, like you did
there is also a direct indexer on polyline itself, if you want to use that!
your line: polyline.PolyPoints[0].point.z = 3f; doesn't work, because C# doesn't work that way
PolylinePoint and Vector3 are both value types, which means when you access them, you're only modifying a copy, not a reference to the original data
the proper way to modify points would be to reassign the struct, as well as using the indexer like this:
PolylinePoint p = polyline[0]; // p is a copy, not a reference
p.point = new Vector3( p.point.x, p.point.y, 3f );
polyline[0] = p; // assign back to polyline
as for the errors - are they disabled objects? seems similar to this issue
https://shapes.userecho.com/communities/1/topics/56-changing-color-while-disc-gameobjcet-is-not-active-gives-error