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
1
Question by Vaelex16 · Apr 24, 2015 at 05:55 AM · serializationclass

How to show the instance of a class's variables in the inspector.

Hi, I'm attempting to allow myself to view the variables of one class as an instance in another class. Currently here is what my inspector is showing alt text

This is my stats script( some functions are omitted just to save space):

     using UnityEngine;
     using System.Collections;
     using System;
     
     [Serializable]
     public class Stats : MonoBehaviour {
     
         //Base Stats
         public Character CharacterName;
         public int Strength;
         public int Dexterity;
         public int Intellect;
         public int Mind;
         public int MaxHealth;
         public int Health;
         public int MaxMP;
         public int MP;
         
         //Charater Development
         public int Level;
         public int Experience;
         public int LevelUpExp;
     
     }


And here is my PartyInfo script that has the instance of the Stats class. ( again functions omitted to save space)

 using UnityEngine;
 using System.Collections;
 using System;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.IO;
 
 [Serializable]
 public class PartyInfo : MonoBehaviour {
 
     public static PartyInfo partyInfo;
     public Stats[] characterStats = new Stats[7];
     public Inventory playerInventory;
     public EquipmentInventory[] characterEquipment = new EquipmentInventory[7];    
     
     // Databases
     public ItemDatabase itemDatabase;
     public SkillDatabase skillDatabase;
     
     // Happens before start
     void Awake(){
         // if we don't have a control
         if(partyInfo == null)
         {
             DontDestroyOnLoad(gameObject);
             partyInfo = this;
         }
         else if(partyInfo != this)
         {
             Destroy(gameObject);
         }
     }
 }


As far as I've been able to tell, it should work.. It's public, it's serializeable... and to top it off, if I attach the Stats script to something in the scene I am able to see it's info, but when I attach the partyInfo it just shows that it should be holding a stats script..

Any ideas? I'm banging my head against the wall here.

untitled.png (20.2 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

1 Reply

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

Answer by Noob_Vulcan · Apr 24, 2015 at 06:04 AM

Don't Derive your Stats Class by MonoBehaviour.

 public class Stats  {
 
 ......//variables
 
 }
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 Vaelex16 · Apr 24, 2015 at 04:54 PM 0
Share

Oh my goodness! You're my hero. I'm glad is was something simple. Thanks so much!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Renaming Serialized Classes 1 Answer

How to get a List of all Variables in a Class 1 Answer

Null Reference When Setting a Class? 1 Answer

Getting any type in Unity Inspector 1 Answer

Custom Class Array Serialization Problem 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