• 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 Tristsin · Mar 06, 2013 at 05:20 AM · javascriptgui

Is it possible to link character skill lists to a GUI, and if so, how?

In our game, characters are able to level up, and when they do they are presented with options of some skills to choose from, but not everyone will end up with the same skills(as the option of w$$anonymous$$ch skills you want to learn is different for each character/player). My question is, how could I display a list of the skills they have unlocked with their character on a GUI, so that they are able to see the available skills in combat.

Currently my GUIs are all built through the OnGUI function.

I'm not an experienced programmer, so if you could, please explain simply, or at least in a way that I can further research

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by enmeii · Mar 06, 2013 at 06:21 AM

I suggest you buy a plugin w$$anonymous$$ch named "NGUI". There are some awesome examples w$$anonymous$$ch is like your idea. Talent tree?

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 Tristsin · Mar 06, 2013 at 06:37 AM 0
Share
avatar image
0

Answer by Chronos-L · Mar 06, 2013 at 05:59 AM

 // I assumed that you have a interface/abstract class called Skill
 // Because you mentioned that not every character has the same skill,
 // so I made t$$anonymous$$s assumption that you are taking t$$anonymous$$s approach.
 public class Skill {
    public string name;

    ...
    ...  
 }
 
 
 public class Example : MonoBehaviour {
    //It doesn't matter as long as it is a collection of skills
    public Skill [] skill;
 
    //You can either leave it as a function or put it in your OnGUI
    private string[] GetSkillName() {
       string [] str = new string[skill.Length];
       
       for( int i = 0; i < skill.Length; i++ ) {
          str[i] = skill[i].name;
       }      
    }
 
    void OnGUI() {
    
       string [] skillName = GetSkillName();
 
       //Display the skills
    
    }
 }

T$$anonymous$$s is a very basic solution, much more work are needed if you need more than displaying a list of skill.

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 Tristsin · Mar 06, 2013 at 06:35 AM 0
Share
avatar image Chronos-L · Mar 06, 2013 at 10:38 AM 0
Share
avatar image
0

Answer by gfvfubb · Mar 06, 2013 at 06:13 AM

So how is it you are storing your skills? In a Dictioary? An Array? What? When the user is presented with the option to level up a skill, what is he doing?

The simplest way to do t$$anonymous$$s is to have a generic skill dictionary or hashtable look up where you save indexes of w$$anonymous$$ch skills the player has and then print those indexes out later in the GUI label showing active skills. Or you could just push the skill names to an array if you are really lazy and use .ToString() on the Array.

If you have unique skill objects you can also use dictionary index lookups for them as well instead of having to assign them and call a GetName function as in the other answer.

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 Tristsin · Mar 06, 2013 at 06:27 AM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

13 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

Related Questions

Multiple Cars not working 1 Answer

Setting Scroll View Width GUILayout 1 Answer

editor script makes editor crash 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

I need help with an array 1 Answer


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