BoltEngine / Bolt-Tracker

New issue tracker for Photon Bolt
10 stars 2 forks source link

GlobalEventListener has not virtual OnEnable, OnDisable #119

Closed M1raclee closed 5 years ago

M1raclee commented 5 years ago

How to reproduce issue

  1. Create script, inherited from GlobalEventListener
  2. Declare method void OnEnable() or OnDisable()

Expected Behavior

Declare OnEnable/OnDisable as public virtual void OnEnable/OnDisable

Actual behavior

Warning: 'NetworkManager.OnEnable()' hides inherited member 'GlobalEventListenerBase.OnEnable()'. Use the new keyword if hiding was intended. (CS0108) [Assembly-CSharp]

ramonmelo commented 5 years ago

Hello @ByvDeveloper,

On the GlobalEventListener we use the OnEnable and OnDisable callbacks to setup the internal events for a particular instance of this class. This way, you only need to call the base method in order to maintain Bolt working as expected, as shown below:

public class NetworkCallbacks : Bolt.GlobalEventListener
{
    new void OnEnable()
    {
        base.OnEnable();
        // My custom code
    }

    new void OnDisable()
    {
        base.OnDisable();
        // My custom code
    }
}