Open Fire-Cube opened 2 years ago
Having the same error on Unity 2022.1.21f1 Mac Silicon.
Having the same error on Unity 2022.2.1f1 Ubuntu 22.04
I had the same issue with unity 2022.2.7f1 on Windows. The issue seems to be at line 47 of PathCreatorData.cs
it checks if the bezier path is null. For some reason it seems to already be initialized but the points array in BezierPath
was not initialized. To fix it I added the following lines in BezierPath.cs
:
/// Is the points array null?
public bool HasPoints
{
get
{
return points != null;
}
}
and then i added the check at line 47 of PathCreatorData.cs
:
- if (_bezierPath == null) {
+ if (_bezierPath == null || !_bezierPath.HasPoints) {
CreateBezier (Vector3.zero, defaultIs2D);
}
I'm not very familiar with the codebase so i'm not sure if it will have impacts somewhere else in the code.
If BezierPath having zero points is a valid scenario then I would change the method name from HasPoints to IsValid or IsPointsNull. If it is not a valid scenario then I think it is worth adding an empty check after the null check. It is an old bug. I think I'll create a pull request. @SebLague can you confirm if it makes sense for the BezierPath to have an empty points list?
edit: it looks like a problem with newer unity versions. when the editor is instantiating a new PathCreatorData it is probably setting the invalid BelzierPath instance through the [SerializeField]
, I removed it to test and the _bezierPath
is null during PathCreatorData
initialization.
When I create an empty object and add the path creator script, I get the following error messages.