Hello guys, I’m making game for Android and I using the Android Device Monitor to get the log of the application on runtime. After finding a strange error happening only in runtime, I find these error logs:
After check my code many times and even re-importing the project I don’t have any Idea what is happening.
My code of GameManager.Start() :
using System.Collections;
using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public float score;
public float bestScore;
public float buildVelocity;
public bool start = false;
public bool isAlive = true;
public bool enabledTutorial = true;
public bool oneTime = true;
public bool droneIsDestroyed;
public bool online = true;
bool preStart;
bool isPause;
GameObject UI;
GameObject dialogBox;
GameObject smallDialogBox;
GameObject tutorial;
GameObject gameOver;
GameObject pressStart;
GameObject placar;
GameObject btnPlay;
GameObject btnPause;
GameObject btnReturn;
GameObject btnRestart;
GameObject btnAd;
GameObject btnMenu;
GameObject btnYes;
GameObject btnNot;
GameObject btnSad;
GameObject telaPreta;
Text txtScore;
Text txtBestScore;
Text txtRestart;
Text txtMenu;
Text txtAd;
Text txtPause;
Text txtWantAd;
Vector3 pos;
Collider2D hitCollider;
// Start is called before the first frame update
void Start()
{
try
{
PlayerPrefs.LoadData();
UI = GameObject.Find("Canvas");
tutorial = UI.transform.Find("Tutorial").gameObject;
dialogBox = UI.transform.Find("CaixaGrande").gameObject;
btnPlay = UI.transform.Find("btnPlay").gameObject;
pressStart = UI.transform.Find("PressToStart").gameObject;
placar = UI.transform.Find("Placar").gameObject;
btnPause = UI.transform.Find("btnPause").gameObject;
gameOver = UI.transform.Find("GameOver").gameObject;
btnReturn = UI.transform.Find("btnReturn").gameObject;
telaPreta = UI.transform.Find("TelaPreta").gameObject;
smallDialogBox = UI.transform.Find("CaixaPequena").gameObject;
btnRestart = gameOver.transform.Find("Recomecar").gameObject;
btnMenu = gameOver.transform.Find("menu").gameObject;
btnAd = gameOver.transform.Find("anuncio").gameObject;
btnYes = smallDialogBox.transform.Find("btnSim").gameObject;
btnNot = smallDialogBox.transform.Find("btnNao").gameObject;
btnSad = smallDialogBox.transform.Find("btnSad").gameObject;
txtScore = placar.transform.Find("Pontos").gameObject.GetComponent<Text>();
txtBestScore = gameOver.transform.Find("MelhorPontuacao").GetComponent<Text>();
txtRestart = btnRestart.transform.Find("txtRecomecar").GetComponent<Text>();
txtMenu = btnMenu.transform.Find("txtMenu").GetComponent<Text>();
txtAd = btnAd.transform.Find("txtAnuncio").GetComponent<Text>();
txtPause = telaPreta.transform.Find("Canvas").Find("txtAnuncio").GetComponent<Text>();
txtWantAd = smallDialogBox.transform.Find("Canvas").Find("txtAd").GetComponent<Text>();
txtBestScore.text = Strings.bestScore;
txtRestart.text = Strings.restart;
txtMenu.text = Strings.menu;
txtAd.text = Strings.ad;
txtPause.text = Strings.pause;
//txtWantAd.text = Strings.wantAd;
if (enabledTutorial)
{
tutorial.transform.GetChild(0).gameObject.GetComponent<Text>().text = Strings.tutorial;
tutorial.GetComponent<MoveObject>().isMoving = true;
dialogBox.GetComponent<MoveObject>().isMoving = true;
btnPlay.GetComponent<MoveObject>().isMoving = true;
}
bestScore = Convert.ToInt32(PlayerPrefs.statistics[0]);
}
catch (NullReferenceException ex)
{
Debug.LogError(ex.StackTrace);
}
}
(well, I have many transform.Find() calls, have any chance of being that?)
and my DayNight.Start() :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DayNight : MonoBehaviour
{
public string currentAnimation;
bool isNight;
bool oneTime = true;
Animator anim;
SpriteRenderer sprRender;
public Sprite nightSprite;
public Sprite daySprite;
GameManager game;
// Start is called before the first frame update
void Start()
{
if (tag == "Animated")
{
anim = GetComponent<Animator>();
anim.Play(currentAnimation,0,1);
}
else if (tag == "SpriteChange")
{
sprRender = GetComponent<SpriteRenderer>();
}
game = GameObject.Find("GameManager").GetComponent<GameManager>();
}
Can anyone help me??