Samples
To import samples, use the Package Manager window:
- Go to
Window > Package Managerand, in the packages list view, select Global Message. - In the package details view, find the Samples section.
- Find the sample you want to import and click the Import button next to it. Unity imports the samples into
Assets/Samples/Global Message/<package version>/<sample name>.
Overview 101
This sample is intended as a practical addition to the documentation as it shows off most topics in one scene. However, it is not meant as a guide on how to correctly structure your game using GlobalMessage.
The scene is located inside the samples folder under Overview 101/Scenes/Overview 101.
Play the Sample
Enter Play Mode to interact with the scene:
- Spawn different colored balls using the buttons.
- Make all balls of one color jump using the buttons.
- Delete balls by clicking on them.
- Clicked balls count is visible in UI.
- Balls that fell off the edge are counted in the UI.
Understand the Sample
Investigate the scene hierarchy to find the following use cases:
- Sending via component without parameter: Spawn Blue ui button (child of Canvas)
- Sending via component with parameter: Spawn (Multiple) Pinks ui buttons (children of Canvas)
- Sending from code via obj field:
ClickedBallLogiccomponent on theBall Base Prefabin thePrefabsfolder. - Sending from code only: Fallen Ball Counter
- Receiving via component with and without param: Simple/Generic Spawner (children of Ball Spawners)
- Receiving in code via obj field:
Jumpcomponent on ball prefabs in thePrefabsfolder. - Receiving in code only: Fallen Ball Counter showing off Send from Editor
Test sending a Message directly from the Editor:
- Enter Play Mode.
- Open the Overview Window (
Windows > Global Message). - Double-click the
SpawnGenericMsgMessage to open its Info Window. - Drag a prefab into its
Spawned Prefabfield. You could use theBall Blueprefab from thePrefabsfolder. - Adjust the
Spawn Countfield to spawn multiple prefabs at once. - Click the
Send from Editorbutton to directly send theSpawnGenericMsgMessage with your selected parameters from the Editor (this can be very helpful for testing).