Skip to main content
1-Visitor
August 14, 2018
Question

Create a 3D Label widget from script

  • August 14, 2018
  • 1 reply
  • 965 views
I would like to parse some JSON and then create 3D Labels at runtime via script. Is it possible to create widgets from script?
What i found so far is the Home.json which stores all elements in the scene, and it seems Icould be able to add objects by writing to this file, but this honestly feels a little rough and i also doubt that that will work at runtime.

1 reply

1-Visitor
August 20, 2018

I don't believe there is any way to create widgets at run. A solution and what i do it to just change the content (text or image src) via JS as needed. So for example i have localization of my experiences and i load a JSON object with all the things i want to change for each language. Some are images with local language text on them others are raw text for things like buttons and toggles. Then when you pick a language i just blast thru the section of this object with the chosen language key and feed it all into a $scope.setWidgetProp function.

 

With the exception of the problem you have found about 3D images not accepting new widths (and also not recalculating 'auto' widths) this works well.