InputField with accented character & reading parameter from URL

Hey there!

I’ve been messing around with InputFields in Needle and found that they work fine for regular characters, but got an error with accented ones like “á”. Any ideas on how to fix this? Also, I noticed TextMeshPro InputFields aren’t working, only the legacy ones - is that right?

To get around the accented characters issue, I thought about using a standard HTML input field and button, and reading the input text from it in Needle. Maybe I could read the input box directly after a button press, or even read a parameter from the website URL. I’ve done this with regular Unity and WebGL exports before, but I’m not sure how to make it work with Needle.

Any help would be super cool! Thanks a bunch!

Original Post on Discord

by user 287627627240488971

Hello, the character needs to be present in the font atlas that is automatically generated. By default it includes all Ascii characters and all characters found on export in existing text components. You have a few options, either:

  • Add an AdditionalFontCharacter component in the scene and add the chars that must be included
  • Add a text component somewhere (you can set it to Editor Only) and add the characters there
  • edit the FontAsset import settings and explicitly setup your character set (default is dynamic)

TextMeshPro is currently exported as a static mesh by UnityGLTF and not dynamic. It is currently not fully supported

About your input suggestion: thats pretty much how the InputField works behind the scenes in Needle to make the keyboard show up etc :slightly_smiling_face:

Awesome! thanks. I will try your suggestions during the day. Regarding reading a parameter from the url, like index.html?test=“hello”, is it possible to read this using Needle? I’m thinking reading the parameter using a javascript function added to the template, and then sending the variable somewhere?

by user 287627627240488971

Sure, there’s some handy util methods that we use all the time

getParam and others like setParamWithoutReload etc

import { getParam } from "@needle-tools/engine/src/engine/engine_utils";

const myPram = getParam("test");

Reminds me to expose some of those to the toplevel import

Thanks! alright so I imagine the previous import and const goes in the template right? Now in Unity, how could I get the myParam const and do something with that? sorry for asking for a step by step haha but I’m a little lost!

by user 287627627240488971

So you write your application in typescript / javascript. You dont get it back into Unity. It’s the other way around (you setup your component, animations, materials in Unity and it gets exported to be used in threejs/Typescript/…)

All data is bundled in the glb files we export which is then loaded by Needle Engine (the web runtime)

Ohh I see, thanks for clearing that up. I was hoping on building a small app that takes some text from a url parameter and then displays a custom 3D model for each letter. So, the best way to go about this would be coding the logic directly in threejs/Typescript? Could I build the logic for this using regular C# inside Unity? I know the question is somewhat redundant but I just want to be clear on the limitations and possibilities

by user 287627627240488971

You have to code the logic in Typescript yes, C# logic is not exported.

For maybe trying to get a headstart if you have some C# script already there’s an experimental feature for converting Typescript skeleton files from existing C# code (they build the variable fields and methods but not the logic inside the methods). It’s available via Context Menus on components or script assets

It might be useful to get familiar with the syntax. But in general its very fast if you code in Typescript (and we have a compiler that builds Unity stub components for you from your Typescript files - so everything it’s really the other way around :slightly_smiling_face: )

Here’s a short video about that workflow

thank you! I sense a fun weekend ahead tinkering with Needle :partying_face:

by user 287627627240488971