How can I access an Enum located on a Non Monobehaviour script in another script

Hi,

Been trying to find a solution for this issue for sometime now.

The below script has an enum Language, which I need to access from the “public class TextLocaliserUI : MonoBehaviour” I would like to basically switch languages.

Assistance would be appreciated.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LocalisationSystem
{
    public enum Language
    {
        English,
        French
    }

    public static Language language = Language.English;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(Text))]
public class TextLocaliserUI : MonoBehaviour
{
    public Text textField;
    public string key;

    public bool english;
    public bool french;

    void Start()
    {
        string value = LocalisationSystem.GetLocalisedValue(key);
        textField.text = value;
    }

If you want to use the enum in another script it would just be public LocalisationSystem.Language Language;
If you are wanting to use code based on the setting of the enum declaration in the LocalisationSystem class, it would be LocalisationSystem.languagefor example

switch (LocalisationSystem.language)
{
     case LocalisationSystem.Language.English:
         break;
     case LocalisationSystem.Language.French:
         break;
}
1 Like

Much appreciated, thank you. I was able to get the code working!