Overview
The Madder Manager is used to interface between the WebGL build and the Unity game. The Madder Manager is a Singleton class that interacts with the Madder Controller Manager and manages Madder Controller States.Usage
Integrating Madder with Unity
The Madder Starter Pack contains two prefabs called
MadderManager and
MadderControllerManager that must be placed in the scene.RegisterMadderController
TheRegisterMadderController method is called by the WebGL build when a player successfully joins using the room code.
RegisterMadderController registers a Madder Controller with the Unity Input System. The jsonRegisterMadderController
parameter is a MadderPlayer object serialized as a JSON string.
For information on how to set up the Madder Controller with the Unity Input System, see the
Madder Controller class.
You may subscribe to the OnRegisterMadderController event to listen for
when a Madder Controller is registered, for example to spawn a Player GameObject.
MadderManager.cs
UpdateMadderControllerState
TheUpdateMadderControllerState method is called by the WebGL build when a player performs inputs on their device.
UpdateMadderControllerState updates the Unity Input System with the input from the player’s controller. The
jsonUpdateMadderControllerState parameter is a MadderControllerState object serialized as a
JSON string.
If you are not using the Unity Input System, you may listen to the
OnUpdateMadderControllerState event to interact with the Madder
Controller State. This event provides the gamername of the player controller and the Madder Controller State so you can
update your game and players accordingly.
MadderManager.cs
UnregisterMadderController
TheUnregisterMadderController method is called by the WebGL build when a player leaves the lobby.
UnregisterMadderController unregisters a Madder Controller from the Unity Input System. The gamername parameter is
the gamername of the player controller being removed.
You may subscribe to the OnUnregisterMadderController event to listen for
when a Madder Controller is unregistered, for example to remove a Player GameObject.
MadderManager.cs
GetMadderController
TheGetMadderController method is used to retrieve a Madder Controller by gamername. The gamername parameter is the
gamername of the player controller you want to retrieve. This method is likely not necessary but is provided for
your convenience should you find a need for it.
MadderManager.cs