This code works fine in Unity, but when I build it for Mac OSX Universal, the GUI.Label that holds the show[times] variable gets cluttered, as in it renders the label over itself, as in the second one renders over the first, third over second, etc. but in Unity, it renders correctly. first. Then it erases that, then renders second, etc. What’s wrong? Why is it rendering the label over itself in the Build?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[ExecuteInEditMode]
public class Progress : MonoBehaviour {
public float barDisplay; //current progress
public Texture2D emptyTex;
public Texture2D fullTex;
public GUISkin gui;
public Font f;
public int fs;
public float wait;
public List<string> show = new List<string>();
//710,585,500,30
int times;
void OnGUI() {
Rect rect = new Rect((Screen.width / 2)-250,(Screen.height / 2)-60,1000,50);
GUI.skin = gui;
GUI.skin.label.font = f; GUI.skin.label.fontSize = fs;
GUI.Label(rect,""+show[times]);
//set up the rect in rect-to-screen scale.
Rect mr = new Rect((Screen.width / 2)-250,(Screen.height / 2)-15,500,30);
//draw the background:
GUI.BeginGroup(mr);
GUI.DrawTexture(new Rect(0,0, mr.width,mr.height), emptyTex, ScaleMode.StretchToFill,true,0);
//draw the filled-in part:
GUI.BeginGroup(new Rect(0,0, mr.width * barDisplay, mr.height));
GUI.DrawTexture(new Rect(0,0, mr.width, mr.height), fullTex, ScaleMode.StretchToFill,true,0);
GUI.EndGroup();
GUI.EndGroup();
}
public float delay;
void Update() {
delay = Random.Range(0.05f,0.2f);
if(times == show.Count) {
Application.LoadLevel("PreMainMenu");
}
if(barDisplay < 1) barDisplay += Time.deltaTime*delay;
if(barDisplay >= 1) {
times++;
barDisplay = 0;
}
}
}