StringName instead of const

Instead of using const I used this approach:

public class Constant
{
    public static class Animation
    {
        public static readonly StringName Idle = new ("Idle");
        public static readonly StringName Move = new ("Move");
    }
    
    public static class Input
    {
        public static readonly StringName MoveLeft = new ("MoveLeft");
        public static readonly StringName MoveRight = new ("MoveRight");
        public static readonly StringName MoveForward = new ("MoveForward");
        public static readonly StringName MoveBackward = new ("MoveBackward");
    }
}

StringName comparisions should be faster, regarding to the Godot documentation. And also all upper case looks ugly imho :smiley:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms