C# Inheritance Problems (523747)

Hi,

I’d like to say that I don’t have experience with unity, so I was looking at the forums for something like that but I couldn’t find any answer.
I have four classes, TextureGUI class, SwitchGUI Class which is inherited from TextureGUI, another classes TextureLocation and BackgroundGUI. when I applied SwitchGUI Class to any game Object. all public variables of TextureGUI class show in inspector window. I created object of switchGUI class and TextureLocation Class in my BackgroundGUI class. i can access all the variables of these classes but variables don’t show in my inspector window. i want all the public variables of TextureGUI, SwitchGUI and TextureLocation class show in inspector window when i apply BackgroundGUI class to game object.

Any help would be appreciated, Thanks

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TextureGUI {
public Texture texture;
public Vector2 offset;
private Vector2 originalOffset;
}

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SwitchGUI : TextureGUI
{
public List switchTextures = new List();
public int currentTexture = 0;
}

public class TextureLocation
{
public enum Point { TopLeft, TopRight, BottomLeft, BottomRight, Center}
public Point pointLocation = Point.TopLeft;
public Vector2 offset;
}

using UnityEngine;
using System.Collections;
public class BackgroundGUI : MonoBehaviour
{
Public SwitchGUI background = new SwitchGUI ();
public TextureLocation location = new TextureLocation ();
}

Creating an instance of SwitchGUI and TextureLocation will not expose their fields and properties in the inspector for BackgroundGUI

Either you can build a custom inspector class and have multiple SerializedObjects with properties been handled at once or

You can make your TextureGUI , SwitchGUI and TextureLocation extend MonoBehaviour and then add them as components inside BackgroundGUI eg:

 SwitchGUI background = gameObject.AddComponent<SwitchGUI >();
TextureLocation location = gameObject.AddComponent<TextureLocation> ();