ObjectNet provides a special class that can be extended to provide a bunch of events and methods, this class is NetworkBehaviour.


The NetworkBehaviour is a class that replaces Unity MonoBehaviour class and provides a lot of embedded methods and events.


NetworkBehavour can be used even if your game doesn't implement MultiPlayer features, this means if your game must work on the single-player mode you can keep this inheritance without affecting your single-player mode behavior.


This is pretty useful since the developer can create your game to run in Single-player mode and multi-player while keeping the same code base.


This section will cover the main aspects of NetworkBehaviour.


To extend your MonoBehaviour script from NetworkBehaviour it's just change inheritance.



        public class MyGameScript : NetworkBehaviour {


                   // Your class code


        }



Once inherited, you can implement some special method to handle your multiplayer game, the following script will illustrate the main methods:


OnNetworkStarted : This event is called once when Network is available to this object.



       /// <summary>
       /// This event is called when Network features starts
       ///
       /// Note : This event is controlled internally by framework and ensure that
       ///        network is up and running
       /// </summary>
       public override void OnNetworkStarted() { 
               // Here you can do any that you need after ensure that Network is initialized
       }



ActiveAwake : This event is the Awake execute only when object is running on Active Mode.



       /// <summary>
       /// Active Awake is executed when objects on Active mode Awake
       /// </summary>
       public void ActiveAwake() {
       }



PassiveAwake : This event is the Awake execute only when object is running on Passive Mode.



       /// <summary>
      /// Active Awake is executed when objects on Passive mode Awake
      /// </summary>
      public void PassiveAwake() {
      }



ActiveStart : This event is the Start execute only when object is running on Active Mode.



       /// <summary>
       /// Active Start is executed when objects on Active mode Start
       /// </summary>
       public void ActiveStart() {
       }



PassiveStart : This event is the Start execute only when object is running on Passive Mode.



       /// <summary>
       /// Passive Start is executed when objects on Passive mode Start
       /// </summary>
       public void PassiveStart() {
       }



ActiveUpdate : This event is the Update execute only when object is running on Active Mode.



       /// <summary>
       /// Active Update is executed every frame for Active object
       /// </summary>
       public void ActiveUpdate() {
       }



PassiveUpdate : This event is the Update execute only when object is running on Passive Mode.



       /// <summary>
       /// Passive Update is executed every frame for Passive object
       /// </summary>
       public void PassiveUpdate() {
       }



ActiveFixedUpdate : This event is the FixedUpdate execute only when object is running on Active Mode.



       /// <summary>
       /// Active FixedUpdate is executed every physics frame for Active object
       /// </summary>
       public void ActiveFixedUpdate() {
       }



PassiveFixedUpdate : This event is the FixedUpdate execute only when object is running on Passive Mode.



       /// <summary>
       /// Passive FixedUpdate is executed every physics frame for Passive object
       /// </summary>
       public void PassiveFixedUpdate() {
       }



ActiveLateUpdate : This event is the LateUpdate execute only when object is running on Active Mode.



       /// <summary>
       /// Active LateUpdate is executed every frame after Update for Active object
       /// </summary>
       public void ActiveLateUpdate() {
       }



PassiveLateUpdate : This event is the LateUpdate execute only when object is running on Passive Mode.



       /// <summary>
       /// Passive LateUpdate is executed every frame after Update for Passive object
       /// </summary>
       public void PassiveLateUpdate() {
       }