Hello! I’m trying to draw 4 buttons in one loop using array of coordinates, strings and gui styles. All buttons is visible, but there aren’t any text on the buttons. What I am doing wrong?
Help me pls.
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class RandomDate : MonoBehaviour {
public float [] x, y, wight;
public bool debug = false;
public int depth;
public GUIStyle [] style;
public string [] text;
public int [] font;
// Use this for initialization
void Start () {
}
void OnGUI () {
if (Application.isPlaying || debug) {
//GUI.depth = depth;
for (int i = 0; i < style.Length; i++) {
style [i].fontSize = Screen.width / font [i];
style [i].alignment = TextAnchor.MiddleCenter;
if (GUI.Button (new Rect((float)((Screen.width/2)+x[i]*Screen.width-Screen.width*wight[i]/2),
(float)((Screen.height/2)+y[i]*Screen.width-((Screen.width*wight[i]/style[i].normal.background.width)*style[i].normal.background.height)/2),
(float)(Screen.width*wight[i]),
(float)((Screen.width*wight[i]/style[i].normal.background.width)*style[i].normal.background.height)),
text[i], style[i])) {
print (1);
}
//}
}
}
}
// Update is called once per frame
void Update () {
}
}