Mixspace Lexicon logo Mixspace Lexicon

Lexicon automatically generates string constants for each of your intents. These constants are updated any time you change the intent, or change any of the entities tied to the intent. The generated script lives next to your intent asset, and looks like this:

namespace Mixspace.Lexicon.Actions
{
    public class CreatePrimitiveStrings
    {
        public const string Primitive = "Primitive";
        public const string Color = "Color";
        public const string Position = "Position";
        
        public class PrimitiveValues
        {
            public const string Cube = "cube";
            public const string Sphere = "sphere";
            public const string Cylinder = "cylinder";
        }
        
        public class ColorValues
        {
            public const string Red = "red";
            public const string Green = "green";
            public const string Blue = "blue";
            public const string Yellow = "yellow";
            public const string Cyan = "cyan";
            public const string Magenta = "magenta";
            public const string Purple = "purple";
            public const string White = "white";
            public const string Black = "black";
        }
        
        public class PositionValues
        {
            public const string Here = "here";
        }
    }
}

Use these constants to refer to entities and entity values in your code. This prevents typographical errors that can lead to bugs. Also, if you change an entity name or value in the Inspector, code that references the old value will now generate a compilation error.

The generated action scripts include a shortcut to this strings class:

using Strings = Mixspace.Lexicon.Actions.CreatePrimitiveStrings;

// Now you can use Strings.Primitive, Strings.PrimitiveValues.Cube, etc.

Note that C# allows string constants in switch statements:

LexiconEntityMatch primitive = runtimeResult.GetEntityMatch(Strings.Primitive);

switch (primitive.EntityValue.ValueName)
{
    case Strings.PrimitiveValues.Cube:
        ...
        break;
    case Strings.PrimitiveValues.Sphere:
        ...
        break;
    case Strings.PrimitiveValues.Cylinder:
        ...
        break;
}