Hi,
First of all, sorry if similar topics exists, but I did not find what I need. I think my case is more specific.
I’m creating a simple RPG and i’m stuck with an issue. I want to have properties in the inspector but not from the main class, i want properties from another class wich is used as a variable in the main class.
Example:
using UnityEngine;
public class Character : MonoBehaviour
{
#region VARIABLES MEMBRES
private string _name;
private string _class;
private Bar _health;//HERE
public enum EnumType { Ally, Neutral, Ennemy };
public EnumType characterType;
#endregion
#region PROPRIETES
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Class
{
get { return _class; }
set { _class = value; }
}
public Bar Health//HERE
{
get { return _health; }
set { _health = value; }
}
#endregion
#region CONSTRUCTEUR
public Character(string n)
{
Name = n;
Class = "Human";
Health = new Bar();
characterType = EnumType.Neutral;
}
#endregion
}
Here you can see that i use a property “Health” for my _health variable, which is a “Bar”.
Here is the Bar Class:
using UnityEngine;
public class Bar : MonoBehaviour
{
#region VARIABLES MEMBRES
private int _maxValue;//HERE
private int _currentValue;
#endregion
#region PROPRIETES
public int MaxValue//HERE
{
get { return _maxValue; }
set { _maxValue = value; }
}
public int CurrentValue
{
get { return _currentValue; }
set { _currentValue = value; }
}
#endregion
#region CONSTRUCTEUR
public Bar()
{
MaxValue = 100;
CurrentValue = MaxValue;
}
public Bar(int v)
{
MaxValue = v;
CurrentValue = MaxValue;
}
#endregion
}
And I want, when i drag my Character script on a GameObject, that my “MaxValue” variable from my “Bar” Class is shown in the inspector.
I have no idea how to do it, i tried so many times last night and I searched a lot online but i found nothing usefull… I really hope you can help me. And I hope I’m understandable.
Thanks for your time folks!
edit: here is a screen shot of what I have (Character) and what I want (Character Test), hope it is usefull.