TIM.Translator
  • ⬇️Installation
  • ❔About
  • Guides
    • 🔖Change the language in Editor
    • 🏷️Text Translatable
    • ⛓️Complex Text Translatable
    • #️⃣C# code
      • #️⃣String Translatable
      • #️⃣Complex String Translatable
      • #️⃣Change the language
  • Projects with translator
    • 1️Gamedev Life Simulator
    • 2️21st UNIVERSE
Powered by GitBook
On this page
  1. Guides
  2. C# code

String Translatable

PreviousC# codeNextComplex String Translatable

Last updated 2 years ago

StringTranslatable

You can add StringTranslatable field and here is what you will see then:

public class DemoScript : MonoBehaviour
{
    public StringTranslatable StringTranslatable;
}

I prefer add [BoxGroup] attribute to field. It will make your inspector better! (for a better understanding of how Odin Inspector works you can )

How can I use this StringTranslatable in my project???

-You can use it for keeping names and descriptions of any objects!

For example:

[CreateAssetMenu]
public class DemoScriptableObject : ScriptableObject
{
    [BoxGroup("0", false)] public StringTranslatable Name;
    [BoxGroup("1", false)] public StringTranslatable Description;
}

So here how it looks in Unity:

And then you can get a text as string this way:

public TMP_Text DescriptionText;
public DemoScriptableObject DemoScriptableObject;

public void Refresh()
{
    DescriptionText.text = DemoScriptableObject.Description.Text;
}

#️⃣
#️⃣
check their tutorials here