Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by niraj · Feb 28, 2014 at 12:54 PM · guiguiscript

How to Load Dynamic Form Based on User Choice Selection

Hello Developers,

Please have a look at the snapshot below for getting idea what i wanted.

alt text

I want to create form using unity GUI where there will be 3 choices for sign up process:

  1. Teacher

  2. Student

  3. Parent

I want these 3 options to be present in form of toggle choices(only any one can be selected). After selecting any choice among the three respective sign-up form will be loaded dynamically in the same scene. I am trying to achieve this in C#.

Looking for possible help from you all developers. Any help would be much appreciated.

Thanks in Advance.

need help.jpg (36.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ArkaneX · Feb 28, 2014 at 01:39 PM

The easiest option would be creating a UserType enum in your class and three methods for drawing custom forms for user types. And depending on userType value, you should call specific method.

Some basic code mixed with pseudocode:

 enum UserType
 {
     Teacher,
     Student,
     Parent
 }
 
 private UserType _userType;
 
 void OnGUI()
 {
     if(teacher button activated)
     {
         _userType = UserType.Teacher;
     }
     if(student button activated)
     {
         _userType = UserType.Student;
     }
     if(parent button activated)
     {
         _userType = UserType.Parent;
     }
 
     switch(_userType)
     {
         case UserType.Teacher:
             ShowTeacherForm();
             break;
         case UserType.Student:
             ShowStudentForm();
             break;
         case UserType.Parent:
             ShowParentForm();
             break;
     }
 }

For hint of how to create radio buttons in Unity GUI, please check this question.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image poncho · Feb 28, 2014 at 01:59 PM 0
Share

this is a valid answer, it works

avatar image niraj · Feb 28, 2014 at 03:53 PM 0
Share

Thank you very much. I got idea finally from your answer. Thank you very much ArkaneX.

avatar image
1

Answer by RickyAh · Feb 28, 2014 at 01:41 PM

What you are looking for is something like a .NET RadioButton. There's no such component on Unity.

A selection grid provides a similar functionality

But if you need something that look like buttons, you'll need to use multiple EditorGUI.Toggle and store yourself the selected option when the user clicks an option.

Once you know which selection the user has made, drawing different things based on that selection should be easy.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image niraj · Mar 01, 2014 at 10:27 AM 0
Share

Thanks RickAh, your idea is also good.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

using GUI scrollView for multiple onGUI functions 0 Answers

GUI Table View In Unity 5 Answers

Deselecting Textarea when button pressed 1 Answer

Gui Playing Audio Trouble 1 Answer

How can I view a gameObject through every other gameObject? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges