BaseClass with EnableOnLoad(false) still loads ticks, events, etc. by registering them without the attributes #2476
Labels
bug
ScRT: C#
Issues/PRs related to either C# scripting runtimes
status:fix-pending
Issue has been triaged and ready to be picked up to be fixed
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.The text was updated successfully, but these errors were encountered: