Search Unity

Issue with parsing {{ }} in text fields

Discussion in 'UI Toolkit' started by taylank, Oct 28, 2019.

  1. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    182
    I have a bunch of ScriptableObjects that hold in-game dialogue data. I write string data into these assets using TextField UIElements. Recently I implemented a system to inject runtime variables into the dialogue by using a simple string.Replace mechanism. So when a designer enters a text like "I have {{goldAmount}} gold pieces" the system converts {{goldAmount}} to the inventory variable representing the player's gold amount. Which works just fine.

    But then I started getting these errors:
    Unable to parse file Assets/Resources/Dialogue.asset: [Parser Failure at line 820: Expected closing '}']

    It doesn't seem to interfere with the actual saving and loading of the asset, but it's making me nervous. Is there a rule for using {{ }} inside a text field? Are they not automatically escaped/sanitized for some reason?
     
  2. wbahnassi_unity

    wbahnassi_unity

    Unity Technologies

    Joined:
    Mar 12, 2018
    Posts:
    28
    Sounds like a parser bug to me. Please log a bug with the asset file you have as an example. I'm (happily) surprised that at least it's still able to save/load correctly.