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 AozakiKyuuji · Jan 06, 2014 at 10:29 AM · c#playerprefssave

Saving skill allocations for characters

Hi guys, I'm stuck here trying to figure out if there's an efficient way to save skill allocations.

My situation is, I have 5 characters, and 5 job classes which are interchangeable between the characters. Each job has their own set of skills.

This is the best that I could muster up.

 public string        char;
 public string        job;

 // job 1
 public bool     crush;       // if equipped, gets true
 public bool     parry;       // if equipped, gets true
 public bool     slam;        // if equipped, gets true

 // job 2
 public bool     magic;       // if equipped, gets true
 public bool     evadeUp;     // if equipped, gets true
 
 void SaveSkill ()
 {
      if (char == "FirstChar" && job == "Warrior")
      {
          if (crush == true)
             PlayerPrefs.setInt("FirstcharWarriorCrush", 1);
      }
 }


This means I have to go through all characters paired up with each job and its skills. I'll probably need to write like a hundred of these PlayerPrefs...

Any efficient method here? Please do tell.

Thanks!

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 YoungDeveloper · Jan 06, 2014 at 10:37 AM

You could create one class which would represent what is job itself, with all possible variations what is possible.

 //C#
 [System.Serializable]
 public class Job{
     public string name;
 
     public bool crush;
     public bool parry;
     public bool slam;
     public bool magic;
     public bool evadeUp;
 }
 
 public Job[] allJobs;

Now, in inspector, you can create max job amount itself, and for each set what exactly you want.

Comment
Add comment · Show 6 · 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 AozakiKyuuji · Jan 06, 2014 at 10:55 AM 0
Share

oh.. cool! but how do i save this type of Job[] array? or recall it

avatar image YoungDeveloper · Jan 06, 2014 at 11:02 AM 0
Share

You input values in inspector and they are saved?

avatar image AozakiKyuuji · Jan 06, 2014 at 11:05 AM 0
Share

i mean, how do i recall it from another scene file.

because they're equipped from one scene, and called up in another

avatar image AozakiKyuuji · Jan 06, 2014 at 12:30 PM 0
Share

um... anyone?

avatar image YoungDeveloper · Jan 06, 2014 at 06:46 PM 0
Share

http://answers.unity3d.com/questions/13130/scene-to-scene-variables.html

Show more comments

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

19 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

Related Questions

How do I save a custom class of variables to playerprefs? 2 Answers

C# Issues with either PlayerPrefs.SetVariable or UnityEvent.Invoke 1 Answer

Multiple Cars not working 1 Answer

Unable to get save score between levels working 1 Answer

How to create log by PlayerPrefs? 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