[C#] Are there defined symbos with the godot version?

I have an addon for Godot 3 and I'd like to update it to work on Godot 4 without losing compatibility with Godot 3, I've done this in Unity using defined symbos (with #if UNITY_X_Y_OR_NEWER) I haven't found a way to do this, anyone have any idea?

13 points · 3 comments · view on lemmy.world

3 Comments

Ategon@programming.dev · 2 pts · 3y (2 replies)

The get_version_info() function in Engine tells you what version of the engine is being used. I personally havent used it since I dont deal with addon building much but it should work

docs: https://docs.godotengine.org/en/stable/classes/class_engine.html#class-engine-method-get-version-info

freakrho@programming.dev · 2 pts · 3y (1 reply)

the thing is the code won't compile, I might get around it with reflection but it's gonna be tedious

Ategon@programming.dev · 1 pts · 3y

Ah yeah dont know how you would do it then. When im using addons ive mostly seen two different versions of the addons being made (one for 3 one for 4)