Skip to content

How to create a CheckBox, a RadioButton and a TextBox in Unity.

Notifications You must be signed in to change notification settings

Normandy72/Unity-CB-RB-TB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions

Checkbox

  1. Create a Canvas, change its color if you need.
  2. Add a Toggle (UI -> Toggle). Change font size, checkmark size if needed.
  3. In Toggle in OnValueChanged component add new item, drop a Title, select GameObject -> SetActive.

Radio Button

  1. Create a Canvas, change its color if you need.
  2. (not necessary) Add a Panel, change its size and color.
  3. Add some Text (may be Question).
  4. Create Empty GameObject (rename it to Options) for all answers.
  5. Inside the Options create a Toggle (UI -> Toggle), rename it, change Label Text, font size, position, etc.
  6. Dublicate first option as many times as you need. Change info.
  7. Add a Toggle Group component to Options.
  8. Select ALL toggles, in Toggle component change Group to "Options".
  9. Inside the Panel create a Button (rename to Submit Button).
  10. Create a new Script. Add it to Options.
  11. Create a Submit method. Inside a OnClick() component of SubmitButton add Options and check its Submit method.
  12. You can also create a new Sprite (2d objects -> sprites -> circle), and set it as a source image in toggle's background.

Switch Toggle

  1. Create a Canvas, change its color, size, etc.
  2. Create an empty GameObject (rename to SwitchToggle). Add an Image inside (rename to Background), change its size and color.
  3. In source image add a bg1 sprite.
  4. Inside of Background add a new Image (rename to Handle), in source image add a handle1 sprite.
  5. Add text field if needed.
  6. In SwitchToggle add a new component Toggle.
  7. In Toggle component drop SwitchToggle background image into Target Graphic.
  8. Create a new C# script (SwitchToggle). Add logic. Add this script to SwitchToggle.
  9. For animation: download DoTween asset from Asset Store, import it. Add library in script. Add logic in script.

Registration

Scene with TextBox, CheckBox and Button

  1. Create a Canvas, change its color, size, etc.
  2. Create text fields (in this case - for name, surname and age).
  3. Add an Imput Field for each text field (UI -> ImputField), change its size, color, placeholder, etc.
  4. Add a Toggle, change its label, size, etc. In Toggle component uncheck IsOn.
  5. Add a Button, rename it to SubmitButton.
  6. Add text fields for messages.
  7. Create an empty GameObject (rename to CheckErrorController).
  8. Create a new script and attach it to CheckErrorController, add logic.
  9. Create a text field for erroe message.

About

How to create a CheckBox, a RadioButton and a TextBox in Unity.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published