Hey guys, I have made several builds of the game, namely on Windows, Mac, iOS, WebGL and Webplayer. So far Windows, Mac and WebGL are working fine. Webplayer has a different problem and finally I have iOS that is being all weird on me.
I get the following error in XCODE (Check attached image)
I keep getting a Unhandled exception: System.NullReferenceException: A null value was found where an object instance was required. at LoadingView.Start() [0x00000] in : 0
I am not sure if I am looking at it wrong but I get this idea that there is something null in that Start() function, But I have nothing null in there! When I test it on the Editor, it works fine, but as soon as it hits XCODE and tested on a iPAD device, I get this error.
Does anyone have an idea or a clue on what this could be?
For reference, here is the code to LoadView
using UnityEngine;
using UnityEngine.UI;
public class LoadingView : MonoBehaviour
{
//public HUD hud;
public LoadingAnimation loadingAnimation;
public string foregroundStyle;
public bool showForeground = true;
public bool stretchForeground = true, stretchLogo = false;
public Texture2D logo, white;
private bool isOpen = false;
private const float loadingIconSizeFract = 0.075f;
private const float loadingMarginFract = 0.05f;
private const float logoSizeFraction = 1.085f;
private GameObject myScreen;
private Text[] loaderTexts;
private Image[] loaderImages;
private bool startgame = true;
public bool IsOverView(float x, float y) {
return false;
}
void Start() {
//Assertions.Assert(hud != null);
//hud.AddElement(this, int.MaxValue - 2);
myScreen = GameObject.FindGameObjectWithTag("LoadingScreen");
// 0 = percentage
// 1 = Detal text
// 2 = title
loaderTexts = myScreen.GetComponentsInChildren<Text>();
// 0 = loaderScreen
// 1 = loaderContainer
// 2 = separator
// 3 = loader
// 4 = logo
loaderImages = myScreen.GetComponentsInChildren<Image>();
myScreen.SetActive(false);
}
void OnDestroy() {
/*if(hud != null) {
hud.RemoveElement(this);
}*/
}
void Update(){
if(isOpen) {
if(PlayerPrefs.GetString("selectedlanguage") == "EN"){
loaderTexts[2].text = "Please wait";
loaderTexts[1].text = "One moment please. \n Your game is loading.";
}
if(PlayerPrefs.GetString("selectedlanguage") == "NL"){
loaderTexts[2].text = "Even geduld a.u.b.";
loaderTexts[1].text = "Een moment geduld alsjeblieft. \n Je game wordt geladen.";
}
loaderTexts[0].text = loadingAnimation.getPercentage().ToString();
loaderImages[3].transform.Rotate(0,0,-5);
}
}
public void Open(bool drawPercentage) {
if(loadingAnimation != null) {
loadingAnimation.drawPercentageInCenter = drawPercentage;
}
loaderTexts[0].text = "0";
isOpen = true;
myScreen.SetActive(true);
}
public void Close() {
loaderTexts[0].text = "0";
isOpen = false;
myScreen.SetActive(false);
if(startgame){
startgame = false;
GameObject.FindGameObjectWithTag("startgame").SetActive(false);
}
}
public void SetPercentage(int percentage) {
if(loadingAnimation != null) {
loadingAnimation.SetPercentage(percentage);
}
}
private Vector2 GetConstantAspectSize(Texture texture, float width) {
return new Vector2(width, width / ((float)texture.width / (float)texture.height));
}
}
