API reference
API reference
Select your platform
No SDKs available
No versions available

StringReference Class

A serializable reference wrapper that allows fields to either use an inline string value or reference a reusable ScriptableObject asset that implements IStringReference. This pattern enables Unity Inspector workflows where values can be edited inline or shared across multiple components via ScriptableObject assets.
Usage example:
// Create a custom ScriptableObject type
[CreateAssetMenu(menuName = "My Game/Dialog String")]
public class DialogString : ScriptableObject, IStringReference
{
    [SerializeField] private string _value;
    public string Value
    {
        get => _value;
        set => _value = value;
    }
}

// Use in a MonoBehaviour
public class DialogDisplay : MonoBehaviour
{
    [SerializeField] private StringReference<DialogString> dialogText;

    void Start()
    {
        // Access the value - works with both inline strings and asset references
        Debug.Log(dialogText.Value);
    }
}
In the Inspector, you can either:
  • Type a string directly (inline value)
  • Drag a DialogString asset to reference a reusable string asset If both are set, the asset reference takes precedence over the inline value.

Properties

Value : string
[Get][Set]
Gets the string value from the referenced asset if set, otherwise returns the inline string value. Setting a value clears any asset reference and stores the value inline.
Signature
string Meta.WitAi.Data.ValueReferences.StringReference< T >.Value