So i basically have 2 classes: Menu and BtnTest.
Now i want a public variable from BtnTest to be showed in the Menu inspector, if that is even possible. The variable i speaking of is BtnTest.marginXXX
Hopefully i made my answer clear enough.
My code:
Menu.cs
public class Menu : MonoBehaviour {
BtnTest btntest;
// Use this for initialization
void Start () {
loadButtons ();
}
// Update is called once per frame
void Update () {
}
void loadButtons() {
//Create monster button
btntest = this.gameObject.AddComponent<BtnTest> ();
btntest.setButton (new Rect (this.camera.pixelWidth - 115, 50, 100, 50), "Monsters");
}
}
BtnTest.cs
public class BtnTest: MonoBehaviour {
Rect btnRect;
string btnText;
public int marginLeft, marginTop, marginRight, marginBottom;
// Use this for initialization
void Start () {
Window = new Rect (this.camera.pixelWidth/2 - marginLeft, this.camera.pixelHeight/2 - marginTop, this.camera.pixelWidth - marginRight, this.camera.pixelHeight - marginBottom);
}
// Update is called once per frame
void Update () {
}
public void setButton(Rect btnRect, string btnText) {
this.btnRect = btnRect;
this.btnText = btnText;
}
}