Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | plyr0 |
Hi, I cannot use the following syntax with is operator type pattern matching. It is just annoyance, but I would like to know official plans, if it will be supported:
public override void _Input(InputEvent event0){
if(event0 is InputEventMouseButton mbe){ //HERE
if(mbe.Pressed && mbe.ButtonIndex == (int)ButtonList.Left){
GD.Print("Click!");
}}}
Errors:
Scripts\Paddle.cs(16,44): error CS1026: ) expected
Scripts\Paddle.cs(16,47): error CS1002: ; expected
Scripts\Paddle.cs(16,47): error CS1513: } expected
Env:
Windows 10 x64
Godot_v3.1.1-stable_mono
Microsoft (R) Build Engine version 14.0.23107.0
Mono version 5.20.1.19
This works:
if(event0 is InputEventMouseButton){
var mbe = event0 as InputEventMouseButton;
This too:
var mbe = event0 as InputEventMouseButton;
if(mbe != null){
C# style guide says I need to stick with C# 6.0
But in official docs it is used type pattern matching
I created an issue in the documentation repository about this: "Mouse and input coordinates" example doesn't follow the C# style guide · Issue #2540 · godotengine/godot-docs · GitHub
Calinou | 2019-06-17 13:10
Installed Visual Studio 2019 Community, and it works great. Probably MSBuild 15/19 alone would be also fine. Thanks for help.
plyr0 | 2019-06-20 08:32