multi-line label text

  • Hi Robert, thanks for the message and glad you're enjoying Label. At this time, we do not support multiline. To achieve this, you'll have to create multiple Label components for each line. There's also a potentially helpful function on the Label Component called MesureTexture( "My Text" ). This returns the width and the height of the Label if it were to render the passed in text. Check it out in the api here: https://lensstudio.snapchat.com/api/classes/Label/

    We'll add this as a feature request, thanks!

    Comment actions Permalink
  • Thanks Travis.  I want to programmatically add labels for a list of texts and am having problems.

    I first tried to copy an existing object with a Label using .copyWholeHierarchy.  I do this in Initialize but that didn't work.  I suspect its related to this discussion where Jacob commented that the object isn't initialized right away.  I can neither change the transform nor set the label text:

    https://lensstudio.zendesk.com/hc/en-us/community/posts/360000808546-Is-it-possible-to-duplicate-a-scene-object-via-code-?page=1#community_comment_360000820986

    I also tried to create an object with a text component from scratch.  That fails with a:

    var new_object = global.scene.createSceneObject("text_line_" + i);
    var text_component = new_object.createComponent("Component.Label");

    "Trying to set text on Label without TextProvider".  Do you have an example of creating a label programmatically (including font selection, etc)?

    I really don't want to manually add and setup each SceneObject.

    Finally, I can't use prefab's because they all share the same text value.

     

    Thanks for any suggestions.

     
    Comment actions Permalink
  • Hey Robert, sorry for the delay here. Unfortunately, the label component depends on a resource of a Material AND a texture. We do have a script ability to clone materials but don't have the same functionality for texture assets. Because of this, you can't programmatically create every piece of a label component. Some of it needs to be stored as resources (as you suggested why prefabs wasn't working for you). 

    I created a project here that should help. Each time you tap the screen in this project, it spawns a new Label prefab. It then sets that label's material to an instance of a label material which I've created in the resources panel. Then, it randomly sets the text which can be different because it's using a unique material. Depending on the number of labels you want to create, you need to add more instances of label materials in the resources panel. 

    Check it out here and let me know if you have questions:

    https://storage.googleapis.com/snapchat-lens-assets/f1a09194-f02d-43ed-92b8-62e843179ff0/lensStudio/Forum-Helpers/label_prefab_example.zip

    Hope that helps and we'll try to make instancing label easier in the future!

    Travis

     

    Comment actions Permalink
  • Thank you travis.  Your project worked as you describe.  This is a fine option as I know I am "misusing" the original intent of the text.  My goal was to create an opening text crawl:

    https://www.snapchat.com/unlock/?type=SNAPCODE&uuid=05a23e035742489da3187837a1d03b40&metadata=01

    For the lens above, I created multiple SceneObjects in a parent which moves to a point far-far away.

    Thanks for the response.

    Comment actions Permalink
Have a comment?

Please sign in to leave a comment.

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!