ManakhovN / FigmaToUnityImporter

The project that imports nodes from Figma into unity.
MIT License
483 stars 59 forks source link

An error that I accidentally found in the last topiс - NullReferenceException: Object reference not set to an instance of an object FigmaImporter.Editor.FigmaNodeGenerator.AddFills #31

Open VladislavMm opened 1 year ago

VladislavMm commented 1 year ago

NullReferenceException: Object reference not set to an instance of an object FigmaImporter.Editor.FigmaNodeGenerator.AddFills (FigmaImporter.Editor.Node node, UnityEngine.GameObject nodeGo) (at Assets/Plugins/FI/Editor/FigmaNodeGenerator.cs:147) image They don't catch me like that because of this - image The project is very large and complex, before that they still get this warning- Serialization depth limit 10 exceeded at 'FigmaImporter.Editor::Node.children'. There may be an object composition cycle in one or more of your serialized classes.

Serialization hierarchy: 11: FigmaImporter.Editor::Node.children 10: FigmaImporter.Editor::Node.children 9: FigmaImporter.Editor::Node.children 8: FigmaImporter.Editor::Node.children 7: FigmaImporter.Editor::Node.children 6: FigmaImporter.Editor::Node.children 5: FigmaImporter.Editor::Node.children 4: FigmaImporter.Editor::Node.children 3: FigmaImporter.Editor::Node.children 2: FigmaImporter.Editor::Node.children 1: FigmaImporter.Editor::Node.children 0: FigmaImporter.Editor::Node.children

This is an error message related to object serialization in Unity. The error occurs when the serialization depth limit of 10 levels is reached, and objects continue to refer to each other in a loop. This can happen if one object references another, and the second refers back to the first, creating an infinite loop. To solve this error, it is necessary to review the structure of objects and make sure that there are no cyclic references.

You can also try using another serialization method, for example, JSON or XML, instead of standard serialization in Unity. This can help avoid problems with serialization depth and circular references.

I don't think that if (node.field != null) probably a good solution, although it works well, it's good for me, maybe it won't be suitable for other people) wrote it here that it is possible to solve it well and in the future someone will not encounter it

VladislavMm commented 1 year ago

As an option - image image

ManakhovN commented 1 year ago

@VladislavMm Looks like the problem is in tree view. I will think how to limit it. I will also check the solution that you proposed. But a bit later. Thank you for your help 👍

shacharoz commented 2 weeks ago

@ManakhovN @VladislavMm have you found a solution to this issue? or can explain how to solve it? i am experiencing it also. this is the first plugin that at least imports the document into unity. but the last step of generating the content on the UI is not yet working for me.

shacharoz commented 2 weeks ago

i have found something. there is an issue with some of the sample images that are being created inside figma.

second issue was to arrange the ui in different pages, rather than as several layouts in one page

shacharoz commented 2 weeks ago

if user uses this url: https://www.figma.com/design/project_hex_code/project_name?node-id=2-522 things will be ok. the frame content is the one being imported correctly!

you can close the ticket

ManakhovN commented 2 weeks ago

@shacharoz Hello, thanks for your messages. So with the proper URL it works as intended? Or how did you fix it?

shacharoz commented 2 weeks ago

@ManakhovN at the end i saw that in your documentation it is actually say to take the link from the Frame. so I guess you are fine. close this ticket.