C# Wrapper (Beta) #528
Replies: 2 comments 3 replies
-
First, this is awesome! I had been working on my own wrapper but it wasn't nearly as comprehensive as this, so thank you to everyone who worked on this. Second, I hope this is the right place to raise an issue I found during an initial setup and test. I think some of the functions relating to setting the rotation or quaternion on a PhantomCamera3D object are missing parameters. I wasn't sure if wasn't using these correctly but modifying all three of these setters to take in the relevant values and then pass them through to the GDScript call fixed it for me. Here is the diff of my changes.
Hope this helps and I'll raise any other issues I run into as I test things out. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to say that the wrapper is awesome |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
New Features
C#
Wrapper (Beta)Important
This is a pre-release version of the addon, and so will not be available through the addon's updater until it has been fully released.
So try out this pre-release, download the zip file at the bottom of the release document and extract the addon from it and add it to your project.
Following the proposal in #286 and with the stellar work from two contributors, Phantom Camera now has a
C#
wrapper, which should make using the addon in C# files feel a lot more native.Massive thanks to @sircodemane, who initially made a PR for this (#351) and set up pretty much all the work for the structure, system and wrapper codebase, and @GabCoolDude who worked on top of the existing work and got the feature pushed over the finish line (#512).
How to use
Note
The documentation will be added to the documentation site once the wrapper has been added to a stable addon release post-beta.
About the wrapper
PCam
nodes can be referenced using thePhantomCamera
namespace, which then allows for assigning the appropriate types to variables. The property and method names are the same as the GDScript version, but are here Pascal Cased to follow the commonC#
naming convention.Note, that due to some technical constraints with how adding a wrapper to custom GDScript declared nodes like
PhantomCamera2D
andPhantomCameraHost
, referencing the addon nodes works a bit differently than one might initially expect.Example
You may notice the perhaps slightly odd inclusion of
.AsPhantomCamera2D()
and the usage of<GetNode2D>
. What it is doing is essentially casting theNode2D
as aPhantomCamera2D
class, which allows for referencing the various public properties, methods, and signals available from the PhantomCamera GDScript class. Due to how nodes are registered in Godot with GDScript, we could unfortunately not find a way to avoid this without adding compromises in other areas of the developer experience.The same approach is also needed for other addon nodes:
What this also means, is that to change the properties inherited from the
Node2D
class, you would need to explicitly reference theNode2D
class before getting/setting or calling any methods from it.For example, to change the visibility of the
Node2D
property that the_pcam
variable above is based on, you can do that with:Bug reports and Feedback
If you spot anything that is missing or not working as intended, please submit an issue.
Questions
If you have any questions about the C# wrapper, feel free to make a sub-post in the GitHub discussion post for this beta release.
This discussion was created from the release C# Wrapper (Beta).
Beta Was this translation helpful? Give feedback.
All reactions