- Home /
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
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.
Answer by Noob_Vulcan · Apr 24, 2015 at 06:04 AM
Don't Derive your Stats Class by MonoBehaviour.
public class Stats {
......//variables
}
Oh my goodness! You're my hero. I'm glad is was something simple. Thanks so much!
Your answer
Follow this Question
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