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 Potatobob · Apr 08, 2014 at 01:12 AM · c#variables

Creating Dropdown menue for variables in the Inspector using C#

Hi , I am trying to get create a dropdown menue for my variables to get something like

Hero stats:-hp -mp ... Gear stats:-weapon damage -dmg reduction ...

The thing is that I already have a tons of variable to play with but I need to add at least 300 more as I am making a reference script that contains all the variables for my hero. So I need to make some order in there .

Ive read about the possibility of creating a dropdown as the clickable arrows in the inspector (we see it in many scrips that comes with unity) and that is what I look for.

After many tryes I still cant get this to work and everytime I read a post they aren't using the same procedure at all. This get verry confusing.

Here is the script I have so far , it displays a couple variables and they are divided in the class I would like.

 using UnityEngine;
 using System.Collections;
 public class Test : MonoBehaviour
 
 {
     //All the booleans that declare a state like : hero is fighting
     public bool isFighting = false;
     public bool isInAction = false;
     public bool isTakingDamage = false;
     public bool isDead = false;
     public bool isLevelingUp = false;
     public bool isSettingLevelUp =false;
 
     //The hero stats example : the Hero health points
     public int healthPoints = 100;
     public int manaPoints = 100;
     public int spellEfficiency = 3;
     public int meleeEfficiency = 3;
     public int dodgePercent = 3;
     public int blockPercent = 3;
     public int level = 1;
     public int actualXP = 100;
     public int neededXP = 1000;
     public int money = 0;
 
     //The hero GEAR stats , example : The hero weapon damage
     public int weaponDamage = 5;
     public int weaponSpellDamage = 0;
     public int meleeDamageReduction = 0;
     public int spellDamageReduction = 0;
 
     //Elemental resistances , example : Lightning damage reduction in percent
     public int lightningReduction = 0;
     public int fireReduction = 0;
     public int iceReduction = 0;
     public int chaosReduction = 0;
     public int lightReduction = 0;
     public int massReduction = 0;
 
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Apr 08, 2014 at 01:20 AM

You basically want to write an Editor that has a dropdown on the left and a value to be entered on the right? Well you would need to use Reflection to get a list of the names and the types of the variables and then create a Popup with the variable names you found and when one is selected you would use the field type from the reflection to create the desired editor. It's quite a bit of work.

Other points - your isXXXXX variables look like a state to me, if they are you'd be better off using an enum to describe - unless you can be in multiple of those at once. I'd consider putting all of this in a utility class rather than a MonoBehaviour and perhaps consider things like weapons to be a further class so that you could swap in new details when the hero collects things. Certainly I guess you will need functions or properties to lookup the final value of things like fireReduction and weaponDamage if you have items that might positively or negatively influence them.

Comment
Add comment · 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

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Trying to access a variable from another script attached to same object. 1 Answer

Distribute terrain in zones 3 Answers

How to access variables from another script on collision ? 1 Answer

How to pass variables from one object in one scene to another object in another scene? 3 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