Last active
March 4, 2023 15:09
-
-
Save rogie/e4fd3976e0cec49b6079d9624ddc7235 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SAVING some settings on a layer (code.ts/figma scene) | |
| // Namespace | |
| const dataNamespace = 'stipple-settings' | |
| // get a node | |
| let layer = figma.currentPage.selection[0] | |
| // options to save in json format | |
| let options = { | |
| some: true, | |
| settings: 1, | |
| here: [1,2,3] | |
| } | |
| layer.setPluginData(dataNamespace, JSON.stringify(options)) | |
| // GETTING settings from a layer | |
| figma.on("selectionchange", () => { | |
| let selected = figma.currentPage.selection[0] | |
| let settings = selected.getPluginData(dataNamespace) | |
| if(settings){ | |
| settings = JSON.parse(settings) | |
| } else { | |
| //some default settings? | |
| } | |
| //post message to ui, passing the settings | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment