The question is answered, right answer was accepted
Entire contents of public void skipped except for one line
As the title says, this only happens in build, works fine in editor. I have this character, that has a script which has a bunch of public floats that i'm using as stats (attack, defence, etc). You can go to this status menu, and it'll copy over the stats from the character to the status screen's internal script (this works fine), where you can then allocate stat points (also works fine).
Here's where things go wrong. I have this public void that's called whenever you go off the status screen that copies all the internal values back to the character's script, and writes them also to a text file which i'm using as a rudimentary save file (this works fine elsewhere), and then it disables the status screen object. that object.gameObject.SetActive(false); line is within an if statement that only becomes true at the end of the last instance of a for loop (which also runs the code for saving to the text file), and this for loop is at the end of the void.
ONLY THAT LINE RUNS!! WHY!?!?!?
I don't get any errors or anything, but the values aren't copied over to the character or into the text file, and I have not a single clue why.
I did some more digging, and it's saying now that the object reference isn't set to an instance of an object... except it is. I've even tried putting some GameObject.Find("objectName"); to replace the drag and drop thing in the editor, but that seemed to just break everything.
Answer by jinxs2011 · Jun 01, 2018 at 11:15 AM
fixed my problem... no thanks to the unity community. I pretty much wrote the same code out outside the void and it worked. What's with that?
Follow this Question
Related Questions
C# | What void do I put in if I want to do something once each click? 2 Answers
How to instantiate (MonoBehaviour) script multiple times and call void? 1 Answer
How can I add a toggle to this FPS counter script? 1 Answer
Generating random points and instantiating prefabs with a set distance 0 Answers
How to set a variable of a non-monobehavior script from a monobehaviour script 0 Answers