🎨
UVC
  • Introduction
  • Installation
    • Installing in New Project
    • Installing in Existing Project - SCK
    • Installing in Existing Project - MCK
  • Space Combat Kit Tour
  • Mech Combat Kit Tour
  • Player Setup
  • Vehicle Framework
    • Game Agents
    • Vehicles
    • Modules
      • Module Mounts
      • Modules
      • Module Types
      • Module Attachments
      • Display Module On UI
      • Module Managers
  • Input
    • General Input
    • Vehicle Input
    • Rewired Integration
  • Player/AI
  • Spaceships
    • Speed UI
    • Space Fighters
    • Capital Ships
  • Mechs
    • Speed UI
  • Vehicle Control Animations
  • Character Enter/Exit
  • Camera
    • Camera Setup
    • Vehicle Setup
    • Secondary Cameras
    • Death Camera
  • Weapons
    • Framework
      • Triggerables System
      • Weapon System
    • Vehicle Setup
      • Vehicle Weapons
      • Cursor Aiming
    • Projectile Weapons
    • Beam Weapons
    • Missile Weapons
    • Resource Handling (Ammo/Heat)
    • Turrets
    • HUD Weapon Info
    • Health Modifier Volumes
  • Radar
    • Radar Setup
    • Target Setup
    • Target Selectors
    • Trackable Types
    • Improving Radar Performance
    • Target Notification
    • Radar Audio
  • Health
    • Health Framework
      • Health
      • Damageable
      • Damage Receiver
      • Health Modifier
      • Health Types
      • Health Modifier Types
      • Surface Types
    • Vehicle Setup
    • Damageable Object Setup
    • Detonators
    • Health Recharge
    • Health UI
    • Energy Shield
    • Damageable Module Linkers
  • HUD
    • HUD Basics
    • HUD Manager Setup
    • Custom HUD Components
    • HUD Module Display
    • Camera View Management
    • HUD Cursor / Reticle
    • Weapon UI
    • Resource Container UI
    • 2D Radar
    • 3D Radar
    • Target Boxes
    • Target Holograms
    • Minimaps
    • HUD Distance Lookup
  • Loadout
  • AI - Space Combat Kit
    • AI Setup
    • AI Spaceship Behaviours
  • AI - Mech Combat Kit
  • Game States
  • Teams
  • Floating Origin
  • Object Pooling
  • Menus
    • Creating Menus
    • Button Controllers
  • Rumbles
  • Rigidbody Characters [WIP]
  • Utilities [WIP]
    • Object Triggers
    • Shadow Caster Doubles
    • Gimbals
    • Game State Post Process Enabler
  • Objectives
  • Resources System
    • Resource Containers
    • Resource Handlers
    • Resource Container Triggers
    • Module/Vehicle Resource Usage
    • UI
  • Cutscenes
  • URP Upgrading
Powered by GitBook
On this page
  • Creating a Button List
  • Creating a Button
  • Using The Buttons List

Was this helpful?

  1. Menus

Button Controllers

PreviousCreating MenusNextRumbles

Last updated 2 years ago

Was this helpful?

While Unity's UI provides a lot of very useful features, it usually requires some scripting to make the most of it. To reduce the amount of coding you have to do, a button controller system has been provided that is used throughout the Vehicle Combat Kits, and you can use it too when building your own menus.

The two key parts of this system are the Buttons List Controller and the Button Controller components.

Creating a Button List

To create a list of buttons, add a Buttons List Controller to a gameobject in your scene.

In the inspector, you can set the button controller prefab (see the next section), as well as the audio that the buttons should use. You can also set the parent for the buttons when they are created (which will usually be a ).

Creating a Button

To create a new button:

  1. Create the button with Unity's UI and add a Button Controller component to it

  2. Customize the inspector settings

  3. Drag it into the Project view to create a prefab

  4. Set the prefab as the Button Prefab in the inspector of the Buttons List Controller you set up in the previous section

In the inspector of the Buttons List Controller component, you have a huge range of options for controlling the way that images, icons and texts on the button are shown, their color, and what to show when a button is 'deep selected' - that is, when it is the chosen option but something else was clicked for whatever reason.

Using The Buttons List

The Buttons List Controller is a component that manages a set of buttons in a menu. You can utilize it with the following code:

// Set the number of buttons dynamically
myButtonsListController.SetNumButtons(someNumber);

// Set a specific button as selected
myButtonsListController.SetButtonSelected(someNumber);

You can also add a function to the On Button Clicked event to be notified when a specific button is pressed.

Horizontal or Vertical Layout Group