Custom Component
Last updated
Was this helpful?
Last updated
Was this helpful?
One may want to introduce a component with custom logic. Unity Figma Importer handles this scenario with a workflow that is easy to understand and apply.
When designing custom components, you need to name your component via Unity Importer in Figma, just type in the desired name to Component Type field. For example, Progress Spinner is named "ProgressSpinner". In this Progress Spinner example, a child container with binding key "Container" of the component is rotated endlessly.
When declaring a custom component, [FigmaComponent(typeId)] attribute should be used. For example, the declaration of class ProgressSpinner should be:
Now anytime Unity Figma Importer sees an instance (only instances of components are imported) of "ProgressSpinner" component, it adds this behavior to the GameObject.
To assign behavior on import time, implementing IFigmaNodeBinder for your custom component would be a good choice. For more information, you may want to check Bindings documentation.