Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved How to reference to the Variable from a script in LocalizeStringEvent

Discussion in 'Localization Tools' started by Voskovets, Sep 20, 2023.

  1. Voskovets

    Voskovets

    Joined:
    Jul 13, 2018
    Posts:
    9
    Hi, I have a question with the Localization plugin.


    I have an object with Script with public Strings variables and TextMeshPro component + LocalizeStringEvent.
    When I am trying to use 'Smart' feature, I don't see my variables. (Attached Files)


    I want to have text: You unlocked {currentLockStatus}%. {currentLockStatus} is from the TestObject (Parent object) with Script.
    But I receive: You unlocked TestObject(UnityEngine.GameObject)%

    What I am doing wrong?


    Thank you
     

    Attached Files:

  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    currentLockStatus is the object reference.
    It gets it and then calls ToString on it. so you probably need to do
    {currentLockStatus.currentLockStatus}
    The first gets the object reference and the 2nd gets the variable from it.
    You may want to rename the object reference to avoid confusion.
    It also sounds like it's currently referencing the GameObject, you need to make sure to drag the component into the field, not the Gameobject .You can do it by opening a 2nd inspector and locking it. Then drag the component from the inspector into the other
     
    Voskovets likes this.
  3. Voskovets

    Voskovets

    Joined:
    Jul 13, 2018
    Posts:
    9
    Thank you karl_jones for help!

    I tried for do it but still have some issue.
    I tried to add script for the same Gameobject and add only this script as a reference. In brackets also wrote as you mentioned above.
     

    Attached Files:

  4. Voskovets

    Voskovets

    Joined:
    Jul 13, 2018
    Posts:
    9
    Hi, I got it for "I tried for do it but still have some issue.
    I tried to add script for the same Gameobject and add only this script as a reference. In brackets also wrote as you mentioned above."

    But I can't do the same if the script is on parent object...
     

    Attached Files:

  5. Voskovets

    Voskovets

    Joined:
    Jul 13, 2018
    Posts:
    9
    Omg. I got it.

    Sorry for spam. I thought I tried everything.

    Thank you!
     
    karl_jones likes this.