Super super strange issue here. So I have a list, called ItemList. I can access the objects in it directly, however I cannot assign its entries to variables.
For example. Let’s say I have an item named Apple. The following then works like this:
List Count: 3
List Entry 0 = Apple
List Matches 0
Returning: null
Got to admit… I’m absolutely baffled here. The only thing I can think of is we just upgraded this project to Unity 2017.3.0f3, and something became broken in that version of Unity.
Ah. Figured it out. Had to deal with how Unity handles MonoBehavior derived objects.
HunkItem was derived from MonoBehavior, but was not being attached to a gameObject. It was like that because I refactored the code for better data management, and those were no longer GameObjects, but instead managed within the data. Since HunkItem was still a MonoBehavior, it existed, and it worked, and it stored data, but an object for it didn’t exist because of the way Unity handles GameObjects. I removed the MonoBehavior and just made it a standard .NET class and all works.
Haha ye, when you sit there almost smashing your head against everything and then you’re about to ask someone or complain about it… “[…] I’m not sure why and it’s freaking me out, but this just doesn’t seem to work as expected when I… OH! nevermind, see you”
Then you just walk away and fix it in seconds.
I have a friend I use for this. He doesn’t even know anything about programming, and I’m sure it annoys him, but while explaining the problem I inevitably figure out the solution. Part of me thinks this is why Slack includes a way to talk to yourself.
In the Sherlock television show in the states (Elementary), Sherlock uses a phrenology bust for exactly this. Since I saw that, I call my friend Angus.
Walking in the shoes of giants… or was it standing on the shoulders? Whatever.
It’s actually a technique called rubber duck debugging whereby explaining the problem to a third party helps us find a solution. Pretty neat from a psychological point of view.