This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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
Godotv3.1.1-stablemono
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

in Engine by (12 points)

I created an issue in the documentation repository about this: https://github.com/godotengine/godot-docs/issues/2540

Installed Visual Studio 2019 Community, and it works great. Probably MSBuild 15/19 alone would be also fine. Thanks for help.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.