Firstly I have to say that 2.5 is looking awesome, the new interface totally rocks.
My only grievance is that after upgrading from 2.1 to 2.5, my game is no longer fully functional. I’m on the same computer and OS, so this is different to the Mac/PC issue I noticed others were having. I seem to be getting a lot of “Object reference not set to an instance of an object” errors that weren’t present in my 2.1 project.
I’m wondering if there are any fundamental changes to the scripting in 2.5 that I should be aware of? I tend to use strict typing, but it looks like script in 2.5 has become less forgiving - a bit like the changes between AS2 and AS3 in Flash. It would be good to know this before I spend hours bug hunting.
I have a lot of code (over 15,000 lines) in a fairly complex server/client application, so debugging is probably not going to be a whole lot of fun. I have the added problem that I can’t get my server running in standalone due to its inability to access a MySQL database (some security bug that I haven’t yet resolved). So when I test, I run the server instance in the editor, and a client instance as a standalone - meaning that when errors are thrown in the client they get logged to the player console log, which doesn’t tell me which line in my code is failing.
Not that I know of, certainly nothing that would cause those sorts of things to happen. After backing up your projects, does it happen with any others or just this one project?
My Fractscape program isn’t as complex as 15,000 lines, but it’s more than a few (about half that I think), and didn’t require any changes whatsoever to run in 2.5. Impossible to say without seeing any code, but null references where you didn’t have any before suggests to me that you might have been relying on undefined behavior, such as the ordering of Start() functions or similar.
There’s really only this one project that I’m working on, but I might try digging up some older stuff to see if the same thing happens.
I had thought my code was reasonably solid and didn’t have too many nasty hacks, but you might well be right - or at least it gives me somewhere to start.
It’s simple. Sometimes when you update things like prefabs, the ingame versions of the objects with initialized variables will have all the in-scene initialized variables that aren’t set in the prefab to become null.
That annoys me a lot, but it’s something that just happens sometimes. Probably doesn’t have anything to do with 2.5, just the fact that everything got touched on the way by and something triggered the bug.
2.5 added more strict error checking, so if you were using 2.1 stuff in unsupported ways, 2.5 won’t accept that.
For instance Event.current wasn’t being cleared after OnGUI finished on 2.1 which meant you could use it on Update (with odd behaviour as a result, but apparently some have been using this). In 2.5 Event.current is correctly being set to null after last OnGUI call which means those people are now getting NullReferenceExceptions.
Apart from more strict error checking, I don’t think the runtime API has had any changes in behaviour - only additions. The editor API has received some slight changes - EditorWindow for instance works a bit differently now and it appears some asset pathes are set up differently (haven’t fully investigated yet), but thats about it.
Thats pretty uncommon, there is always something with focus, at very least the window itself.
if you want to remove focus from a textfield just set the focus to something you have declared as nothing (who knows, perhaps you can even focus “” for this purpose)
Never mind, I came up with another (also slightly hackish) way of solving the problem.
Though the purpose was intentional - my game is multiplayer and has a chat window (as well as other less frequently used points where the user can input text), but also uses keys as UI shortcuts (“i” for inventory, “m” for map, etc.). i needed a way for the user to either chat or interact with the game UI, so was trying to take focus away from these textareas when the user clicked outside of it.
Btw, GUI.FocusControl(“”) has no effect, so that isn’t an option. There isn’t a clear way shown in the Unity documentation to get rid of focus on a control. For comparison, JavaScript has the blur() method.