Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Is there any chance you can speak more on point 4?

"Don't [...] use C# event Actions - They lead to really helpful single-line error messages like 'modules/mono/managed_callable.cpp:92 - Condition "delegate_handle.value == nullptr"

I'm not specifying any C# events (or even any custom signals) - I've even disabled all references to normal signals - my plugin is throwing this error, and this is the only place where I've found someone tell me what it means 😅

(+2)

Nevermind - I went through and found a bunch of cases where I was violating other rules on your list here, corrected my errors (thankyou for this documentation, it's really been invaluable) and after restarting the editor - no more of those error messages. So that same (or very similar) error *can* be caused by (for example) leaving statics lying around willy-nilly, as far as this anecdote goes.

(+1)

I'm happy my list helped and you could fix your issues! Yeah, making plugins in C# can be really iffy, you can imagine how long it took me to find all that stuff out. :D

(+1)

I haven't seen red text in over 24 hours. I stand perched, albeit precariously, upon the shoulders of a giant.

I just thought I'd come back here to mention - I've made a few discoveries of my own. I'm still trying to pin all of them down, but the big one I've found is that although you can't serialise C# collections using [Export], provided they are initialised as null they're fine to use as a field in a plugin. You can Export access to a cached Godot collection as well - the getter for the Godot collection can instantiate the C# collection, effecting serialisation without throwing an error (unless something else asks for the C# collection *before* the Godot collection is requested, obviously - so this may necessitate some null checks you wouldn't otherwise use). I've used this outside Editor plugins just for the convenience of using C# collections, and was pleasantly surprised to find the same method works in this context.

ohhh, that is very astute, I would have never thought of doing that. Although, I am wondering which C# collection you are using that is worth having all this extra boilerplate code?

I'm self-taught, only ever learnt C# (and a little C/CPP), work alone, and only been programming for 5-6y - so I will often do things in bad, wrong, or stupid ways, depending on what seems to work. Take anything I say with a hefty slab of salt.

My current thingamajig is a node that manages a fairly big queue - not using a Queue collection as a fundament seemed silly, and Queue/Dequeue operations on large collections are very fast compared to the equivalent ops on an array. I don't need serialisation, so all I do is initialise the collection as null, assign it during '_Ready', and I can depend on it being available for the remainder of operations without throwing any untraceable errors. 

It's not *too* onerous in terms of boilerplate if you *do* want serialisation; something like what's below does the majority of the heavy lifting, you've just got to assign cached_Vecs using queue.ToArray() at some point.

[Export] Vector3[] serialised { get{ queue ??= new(cached); return cached; } set{} }
[Export] Vector3[] cached = Array.Empty<Vector3>();
Queue<Vector3> queue = null;