Can't call methods in other scripts in Build
Everything works perfectly in the Unity Editor, but when I push to a build version, everything that involves calling methods in other scripts breaks.
I've been using the method of:
public GameObject goalTrackingEmpty;
goalTrackingEmpty.GetComponent<GoalTracking>().orangeScores();
where goalTrackingEmpty is an empty GameObject with GoalTracking.cs attached to it. I did it this way because I didn't want to make everything static, but for some reason it's just refusing to work in the build version of the game. I checked the error logs and I see this:
NullReferenceException: Object reference not set to an instance of an object
at GoalTracking.orangeScores () [0x00000] in <filename unknown>:0
at BlueGoalDetection.OnCollisionEnter2D (UnityEngine.Collision2D collision) [0x00000] in <filename unknown>:0
(Filename: Line: -1)
which doesn't really tell me much.
Answer by dacoja · Apr 10, 2017 at 07:17 PM
No idea why, but it's fixed now. I think it was something to do with a missing link to an AudioSource object on one of the GameObjects in the scene ¯\_(ツ)_/¯
I apologize to anyone who stumbles upon this thread hoping for a better answer.
Your answer
Follow this Question
Related Questions
Next scene is loading in the Engine, but not in the Build! Help please 1 Answer
Unity 5 use PushAssetDependencies and PopAssetDependencies 0 Answers
I can't build my project, how can I fix it? 3 Answers
Post Processing Layer Script won't work after running build 1 Answer
error CS1525: Unexpected symbol `' 2 Answers