Setup Canvas
In local multiplayer games, each player often needs their own UI elements. The Setup Local Player Canvas instruction facilitates this by instantiating and configuring player-specific UI canvases.
Setup Local Player Canvas Instruction
This Game Creator 2 instruction manages canvas creation and configuration for individual players.
Parameters
Required Settings
- Canvas Prefab: GameObject prefab containing a Canvas component and player-specific UI elements
- Local Player: The Local Player to associate with this canvas
Optional Settings
- Parent: Target GameObject to parent the new canvas to (optional)
- Update Event System: When enabled, assigns the Local Player's Multiplayer Event System to the canvas
- Save: Store a reference to the instantiated canvas in a variable for later use
Canvas Creation Guide
Prefab Setup
- Create a new GameObject with a Canvas component
- Add your player-specific UI elements
- Configure canvas settings (render mode, scaling, etc.)
- Create a prefab from the configured canvas
Player Reference
The Local Player associated with a canvas can be easily referenced in scripts and components using the Local Player from Canvas property.
Canvas References
When designing your canvas prefab, you can use the Local Player from Canvas property to easily access the associated player's information and state.
Best Practices
Organization
- Keep player-specific UI elements organized within the canvas hierarchy
- Use clear naming conventions for UI elements
- Consider creating UI element prefabs for reusability
Performance
- Minimize canvas rebuilds
- Use object pooling for frequently changed UI elements
- Configure appropriate canvas update modes
Split Screen Considerations
- Design UI elements to work in both full-screen and split-screen modes
- Account for different screen orientations
- Test UI visibility in various split-screen configurations
Canvas Scaling
Ensure your canvas scaling settings work properly in both single-player and split-screen scenarios.