This happens on only SOME types of meshes and prefabs and this error only happens when the project
is built as exe (Am using Mono backend as IL2CPP completely fails)
I am attaching the package of the prefab/model in question.
Ok, managed to reproduce this one, and found a work around. I still need to look deeper into this and make sure this fix is solid, but if you are in a hurry, here it is:
In CGData.cs, go to line 2004, and replace this line:
private static readonly Material NullMaterialDictionaryKey = new Material(Shader.Find("Diffuse"));
with this one
private static readonly Material NullMaterialDictionaryKey = new Material(Shader.Find("Standard"));
Will keep you updated
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
04-22-2022, 02:37 PM (This post was last modified: 04-22-2022, 02:50 PM by studentloan.)
Unfortunately am still getting an exception even when I apply the said code change
I've attached a screenshot of the error
Edit: btw, if I add a standard cube into the Prefab then it works but if I just have my road prefab as-is, it crashes (Only in the mono build, not in editor, editor works fine)
Btw, you will have to enable the development build to see the exception otherwise it's silent and Spline segments can't be added dynamically, it goes completely unnoticed otherwise and you notice is when you debug
I don't know if this will help but it seems that, inputMeshTangents is a vector of size 0 as inputMesh.TangentsList.Array seems to be
unpopulated. If I add a simple cube to the game object then it works.
04-22-2022, 03:16 PM (This post was last modified: 04-22-2022, 03:16 PM by studentloan.)
The project is over a few GB, so will make a repro project. Please give me 40 minutes or so.
In the meanwhile if you'd like, I can explain, this exception is unnoticed but you'll notice that InsertAfter calls on that spline will not work when you supply this particular mesh inside your game object.
Or even easier you can notice the exception if you make a development build and attach your debugger to it, it'll break at the line I screenshotted.
I have sent you the repro project in PM if you build it you'll understand what I mean, the control point is not added dynamically through script in the windows build, but it is added dynamically in the editor, and if you do a development build it will throw many exceptions in the error log on screen (you can even attach it to your debugger and it'll break at the line with the exception)
After further investigation, here is my conclusion about this issue:
The issue happens because of the combination of two issues, one on me, and one seemingly on Unity:
Issue A: The one on Unity: Your fbx model file has no tangents in it. Unity, following the settings on the model import settings, generates tangents for that model (based on its geometry). The issue is that those generated tangents are present in editor, but are not in the build. As far as I see it, this is a bug in Unity. I tried different variations of the import settings, and none solved the issue.
Issue B: The one on me: when a mesh has no tangents, the deform mesh module throws exceptions.
Now, about the solutions:
Issue A: the short term solution is to reexport the fbx file but this time with the tangents included. Also I recommend that you open a Unity bug report raising the issue.
Issue B: I will soon prepare a fix for it Once prepared, I will send it to you via PM. If it works with no issues with your project, then I will include it in the next update of Curvy.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.