FigmaToUnity is a specialized Unity tool that streamlines the UI development process by enabling the direct import of Figma page documents into Unity. The tool automatically converts Figma designs into UI Toolkit assets, allowing for quick and accurate integration of UI interfaces into your Unity games.
In our extensive experience working with Unity3D, we have engaged with various User Interface (UI) systems. However, we found that these systems often did not facilitate a clean division between UI programming and UI/UX design tasks. This particular tool has enabled us to concentrate on core programming activities.
5easqg
Experimental Release: This plugin is currently in an experimental phase and is provided “as is” without warranty of any kind. It was originally developed for internal use and may contain issues or limitations. Use it at your own risk. Feedback and contributions are welcome but please keep in mind the experimental nature of this tool.
The code repository published by the author is poorly maintained and very difficult to run successfully, I tried for many hours without being able to run it. The main problems are: 1. Dependent packages are not published correctly, 2. async syntax is used incorrectly (even in unity2023)
The problem with incorrect dependencies comes from complex dependencies on CommonUtil and AsyncAwaitUtil (they look like they should be a published package, but they aren’t). com.trackman.commonutils can be relied on locally,
but the other one is not managed by package, must pull the git project and copy the script to the target project. I believe this inconsistency is very confusing.
async syntax problems come from the OnEnable method of Figma.cs. WaitForEndOfFrame cannot be awaited in my environment (this looks like the await extension for WaitForEndOfFrame is not in effect).
That’s all I can give you.
Your job looks valuable, but it’s not easy to use right now. It is recommended that you optimize the configuration of the project, and do not let the complicated setup cause the job to not be recognized.
I ended up running it and converting some of the figma documents. But the result of the conversion is not satisfactory, it will make the size of the vector image or picture fixed at 100% * 100%. And for complex documents, json parsing fails.
Thanks for the update, I’m going to update readme file, so it will be more clear that you need to install CommonUtils and such.
There are some limitations with what Unity supports, but I’m curious if you can share you documents for us to test on them.
As for the vectors we use them all the time, and they work great so far, maybe there is a layout issue with your document (Unity does not support some Figma layouts, and we have to fine tune the document sometimes).
Edit: reviewed Awaitable and it seems like it’s not supported in our target Unity version of 2022.3
Hello. You have a great project. However, it has many dependencies on external, not often used libraries.
I’m trying to create a button with hover and pressed states using the template https://www.figma.com/community/file/992422778538944984/battlefield-4-main-menu-ui-design.
However, the documentation doesn’t explain how to properly group components so that they are imported as styles. There is the code for IsStateNode, which separates styles from the components themselves, but I can’t figure out the logic behind how it works.
Could you please add information on working with styles to the documentation of your project?
Yes, you basically need to have the same element in the hierarchy (in Figma) but with a state postifx.
For example, if you have one Label in the scene with the name “TestLabel”, your scene might look like this:
TestLabel
TestLabel:hover
This will add additional states to the uss and will not modify the hierarchy (in uxml) of the final output.
There is one downside to this issue, is that it does not support deep hierarchy, so all elements with the state will have to have a satellite element with the correct name of the state.
As for the dependencies, currently we have next things:
AsyncAwaitUtil (this will be removed when we transition to 2023)
CommonUtils (our in house library of things to work with network and json, we share this library with many other packages we develop, so not sure there is a benefit in embedding it into the Figma package)
Newtonsoft (this is Unity based, so it’s automatically resolved and not an issue I hope)
Thank you for the response. I dug into the code and implemented the ability to work with nested hierarchies for styles. It’s not perfect, but it works. Perhaps later, I will create a pull request.
I installed your package into my UNity Project, v6000. I created a PAT on figma.com website 4 hours ago, and attached the Figma script to a Gameobject.
When I ran the “Update”, I got a 404 error.
Ok, I think I have found. The “Title” means in fact : “file_key” in Figma world.
I got it, and loading of Figma file is OK.
But I got an error when finishing loading :
JsonSerializationException: Could not find member 'fontStyle' on object of type 'Style'. Path '[0].style.fontStyle', *****
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject ****
Hello @sylvain, this issue is related to Figma API update. We will enroll an update with fix soon, but if you want to go ahead without waiting, you can insert public string fontStyle; into file Figma.Types.cs at line #360, in type TextNode.Style.
The Figma.Types.cs is a file which does reflect the Figma’s API and should always follow the structure. Unfortunately, when Figma do update their API, we have to update that as well.