Open AvarianKnight opened 4 months ago
I read the conversation that led to this issue and to that the answer is: yep [EnableOnLoad(false)]
implies not activating all instances' ticks, events, etc. at construction. So this is indeed a bug due to an oversight.
This'll need to be fixed/tweaked
What happened?
If a class inherits from
BaseClass
and has the attribute[EnableOnLoad(false)]
calling register functionsTick +=
orEventHandlers[eventName] +=
will still schedule the tick & will still bind the event handler.I would assume this works the same for exports but I couldn't figure out how to register them via
Exports.Add
in mono_rt2Expected result
The class class inheriting BaseClass should only add Event/Tick/Nui whenever
script.Enable()
is calledReproduction steps
Client.cs
index.html
Importancy
There's a workaround
Area(s)
ScRT: C#
Specific version(s)
N/A
Additional information
A simple fix for this would probably be to remove the
Schedule()
call for Ticks and remove theEventsManager.AddEventhandler
call, and returning afterm_nuiCallbacks
if the script is not enabled.Initialize()
should probably only set the state toState.Initialized
and callEnable()
again after it finishes initializing attribute values and letEnable()
handle scheduling the Tick/Nui/Event/Export/Commands.