Join Jesse Freeman for an in-depth discussion in this video Working with toggle groups in scripts, part of Unity 5: UI.
- So, now that we have our basic toggle group,…let's look at how to control this with some code.…In our Project folder, let's go to the…Scripts folder and create a new C# Script.…And, we're going to call this Toggle Test.…Then on our toggle group,…let's add the toggle test component.…Next, we'll open this up in MonoDevelop.…In order to access the toggle group,…we're gonna need to include…Unity's new UI components.…
So, let's add using UnityEngine.UI.…Next, let's add a private field to store…a reference to the toggle group instance.…Now, in our start method,…let's get a reference to the toggle group instance.…Here we'll set its value to…GetComponent ToggleGroup.…Now, the toggle group doesn't actually…have an easy way to get the item…that's already selected.…
We're going to create a new getter that'll make…it a little easier for us to find the currently…selected item inside of the toggle group.…In order to that, we're going to need to…bring in a library called Linq.…At the top of our class,…let's add using System Linq.…
- Adding new components to the Canvas
- Working with RectTransforms
- Nesting UI elements
- Adding rich text and effects to the UI
- Creating images
- Styling UI buttons
- Handling input
- Creating sliders
- Controlling the layout of the screen
- Adding toggles and dropdowns
Skill Level Intermediate
1. The Canvas
2. Working with the RectTransform
3. Working with Text
4. Working with Images
5. Working with Buttons
6. Handling UI Input
7. Working with a Slider
8. Controlling Layout
9. Toggles, Dropdowns, and the Input Field
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.