# trouble with custom class

**URL:** https://discussions.unity.com/t/trouble-with-custom-class/601761
**Category:** Scripting
**Tags:** Scripting
**Created:** [October 16, 2015, 7:08pm UTC](https://discussions.unity.com/t/trouble-with-custom-class/601761 "2015-10-16T19:08:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JamesButlerI](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JamesButlerI](https://discussions.unity.com/u/JamesButlerI)
#### Post date: [October 16, 2015, 7:08pm UTC](https://discussions.unity.com/t/trouble-with-custom-class/601761/1 "2015-10-16T19:08:08Z")

</div>

Hi!

So want my hero to have a healthbar, a shield bar and an energy bar (not edible… hehe … sorry for that).  
So i created a class in a script to capsule all the information these 3 bars have.

```csharp
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

namespace customClasses
{
    [System.Serializable]
    public class liquidStat : Component
    {
        public string name;
        public float valMax; //max value
        public float valCurrent; //current value
        public float valReg; //regeneration per sec
        private Slider slider; //UI.Slider
        private Text text;
    }
}

```

now the problems come: in order to give my hero the information i want to be able to set the variables of the class in the inspector, which isnt working.  
in the inspector in the script it sais:  
Health None(liquidStat) instead of a dropdown menue of all public variables.  
is there away to access all the variables in the inspector ?

James Butler

---

<div class="post-metadata">

### Author: ![Stardog](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/stardog/32/910746_2.png) [@Stardog](https://discussions.unity.com/u/Stardog)
#### Post date: [October 16, 2015, 7:31pm UTC](https://discussions.unity.com/t/trouble-with-custom-class/601761/2 "2015-10-16T19:31:08Z")

</div>

Change “Component” to “MonoBehaviour”.

If it’s a class to be included in another component, do this:

```csharp
using UnityEngine;
using System.Collections;
using customClasses;

public class MyComponent : MonoBehaviour {

    public liquidStat stats;

}

```

---

<div class="post-metadata">

### Author: ![JamesButlerI](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JamesButlerI](https://discussions.unity.com/u/JamesButlerI)
#### Post date: [October 17, 2015, 9:59am UTC](https://discussions.unity.com/t/trouble-with-custom-class/601761/3 "2015-10-17T09:59:46Z")

</div>

I changed it and made an instance just like you did, but still no option to access the variables from the inspector.

---

<div class="post-metadata">

### Author: ![hpjohn](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@hpjohn](https://discussions.unity.com/u/hpjohn)
#### Post date: [October 17, 2015, 10:56am UTC](https://discussions.unity.com/t/trouble-with-custom-class/601761/4 "2015-10-17T10:56:03Z")

</div>

Change Component to nothing, it doesn’t need to implement anything if its just a data holder

---

<div class="post-metadata">

### Author: ![JamesButlerI](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JamesButlerI](https://discussions.unity.com/u/JamesButlerI)
#### Post date: [October 17, 2015, 10:57am UTC](https://discussions.unity.com/t/trouble-with-custom-class/601761/5 "2015-10-17T10:57:43Z")

</div>

Now it works fine. Thank you!
