Search Results for

    Show / Hide Table of Contents

    Samples

    To import samples, use the Package Manager window:

    1. Go to Window > Package Manager and, in the packages list view, select Global Message.
    2. In the package details view, find the Samples section.
    3. 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: ClickedBallLogic component on the Ball Base Prefab in the Prefabs folder.
    • 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: Jump component on ball prefabs in the Prefabs folder.
    • Receiving in code only: Fallen Ball Counter showing off Send from Editor

    Test sending a Message directly from the Editor:

    1. Enter Play Mode.
    2. Open the Overview Window (Windows > Global Message).
    3. Double-click the SpawnGenericMsg Message to open its Info Window.
    4. Drag a prefab into its Spawned Prefab field. You could use the Ball Blue prefab from the Prefabs folder.
    5. Adjust the Spawn Count field to spawn multiple prefabs at once.
    6. Click the Send from Editor button to directly send the SpawnGenericMsg Message with your selected parameters from the Editor (this can be very helpful for testing).

    Using the Info Window to send the SpawnGenericMsg directly from the Editor.

    In This Article
    Back to top Malte HusungLeave a ReviewLegal Noticethank you ❤️