Hello! There is a rather old and massive project on Unity which contains more than 2000 Spine files. Since the project is very old, it initially used version 3.5. A little later the files were converted to version 3.7. Now the task is to switch to version 4.2. I wrote an AHK script which uses CLI for conversion according to the documentation from your site. 80 - 85% of the files were successfully converted to the new version. The rest give a vertex error. I found a solution on how to fix this error manually. If I import a binary file of version 3.7 directly into the project, then as a rule I see some mesh which does not display a picture and does not allow itself to be edited, and when I try to delete any vertex, it gives an error - the vertex cannot be deleted. But if I export this file to json without nonessential and then import it back. I get import warning: Nonessential not checking when exporting ..... I click ok and can edit the points. After such an operation, I save the file as .spine version 3.7. Then I open it in the editor of version 4.2 and get a warning window again with messages that the vertices were recalculated and corrected, and after that I calmly export the binary file to 4.2. And it is perceived by unity as working. But if I do all these steps through the CLI, then fixing and recalculation of vertices does not occur. I read the documentation and did not find flags there that would help me fix vertex errors and I get a binary file at the output that is not accepted by unity. As I understand it, the fixing vertex function is only available in the editor and is not available through the CLI? Thank you.
Update project with CLI
It sounds like you are past this stage, but we provide an export script here:
EsotericSoftware/spine-scriptstree/master/export
Question time:
- What are the 2000 files? Spine project files, JSON, or binary?
- When exactly do you get a "vertex error" when using the CLI?
- What is the exact error message?
- Can you post a problematic 3.7 project?
The logic to fix the vertices when nonessential wasn't checked is relatively simple. Depending on your answers, we may be able to write a script to do it.
- 수정됨
Hi Nate! The project was made a long time ago and we only have binary files available. "The logic to fix the vertices when nonessential wasn't checked is relatively simple. Depending on your answers, we may be able to write a script to do it." - That would be great!
I recorded a video that clearly shows the problem and how to solve it in the editor. There is no triangle correction functionality in the CLI, so no matter how I tried to repeat the same actions, the B_bear_L_arm mesh is missing, or the file is not imported into Unity and is marked as corrupted. Thank you!
[
If you have any questions, please ask, I will be happy to answer.
Sorry it took a while! This vertex is the problem:
It's hard to see, but the vertex is actually on the wrong side of the hull. That should be impossible and must have been a bug in 3.7. You'll find you can't move any of the vertices, because with that vertex outside the hull the constraints (blue and orange lines) are invalid, so no triangulation can be computed. Note there are no dashed triangle lines.
If you move the vertex, then everything is fine, you can move other vertices/etc and now we have dashed triangle lines:
That's the issue, now for how to fix it. Manual fix up is possible, but could be tedious with many projects. Exporting JSON with 4.2 gives:
Mesh has internal vertex outside hull: [mesh: B_bear_L_arm, slot: B_bear_L_arm]
Yep, that's the problem. The JSON data shows no triangles "triangles": []
. Importing the JSON back into 4.2 fails:
Cause: [error] Error reading attachment: B_bear_L_arm
Cause: [error] Invalid number of triangles: 0 < 3
Bummer. Giving it some triangles, eg "triangles": [ 0, 1, 2 ]
, allows it to import, but new triangles aren't automatically generated (because doing so could wreck things). To get new triangles you'd need to manually move a vertex.
What can work is:
spine -u 3.7 -i bearskel.skel -o temp.spine -r
spine -u 3.7 -i temp.spine -o . -e json.json
spine -u 3.7 -i bearskel.json -o fixed.spine -r
del bearskel.json temp.spine
Those commands:
- Import 3.7 binary data into
temp.spine
. - Export
temp.spine
as 3.7 JSON without nonessential data. - Import 3.7 JSON to
fixed.spine
.
The json.json
file contains:
{
"class": "json",
"nonessential": false,
"prettyPrint": true
}
When you open fixed.spine
with 4.2 it will fix the mesh:
WARNING: Fixed invalid triangulation: [mesh: B_bear_L_arm, skeleton: bearskel, slot: B_bear_L_arm]
Unfortunately this fixing does not happen from the CLI, eg if you were to do a JSON or binary export. That is a bug that we have now fixed in 4.3.38-beta. For versions before that, you'd have to open the project, then save it (no need to move a mesh vertex).
We've also improved some related things in 4.3.38-beta:
Fix triangulation when importing data into a project and when exporting JSON or binary data.
Thank you