Some questions about auto-generated c# class

I created a input action titled “PlayerControl” and pressed auto-generated c#class.

So you will see a class like:

{
}
  1. I am just wonder why there is a @ in front of the class name and what is its function?

Also you have this function:

{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
  1. Just wonder what does this bit “InputBinding? bindingMask” mean?

Many thanks for answering!

It protects against compilation failing if C# reserved words are used for names (e.g. “return”). The code could check whether the identifier is indeed a reserved word and only use @ then. The current code just always appends the @.

The ? is for a “nullable” type. InputBinding is a struct so it’s not possible to tell the difference between a default-initialized value (default(InputBinding)) and a value that has not been set. Thus the “nullable” thing. The default value is null and thus different from default(InputBinding) so it’s possible to tell a mask that hasn’t been set to one that has been set to default values.

1 Like