Showing posts with label Unity. Show all posts
Showing posts with label Unity. Show all posts

Tuesday, December 10, 2013

Unity3D 2D UI Click-Through Issues

I have message box and dialog box classes for use in Unity3D that need to act 'modally' (but not truly modal) at times, and one of the problems I've had was preventing the mouse-clicks/touches from hitting controls under the controls in the message/dialog boxes.

You'd think that the Unity3D system would already take care of this, but apparently there is some behind the scenes issue that is non-trivial to resolve (otherwise the Unity3D devs would have knocked this out a looooong time ago.)

Anyhow, I found a simple solution today that works for me (until I find it fails on iOS - fingers crossed that it doesn't!)

When my OnGUI call gets to my message/dialog box, the message/dialog box simple creates TWO full screen transparent GUI.Window objects.  The first one calls an empty method, the second one calls the method that draws the controls of the message/dialog box.

I'd tried this previously, but only created one GUI.Window - hoping (vainly) that having the window under the message/dialog box would prevent clicks from making it through.  Oddly enough, it sort of worked, it prevented clicks that were on the message/dialog box controls from going through, but you could still click anywhere on the rest of the screen and cause havoc...

Anywho - I'll have to test have badly this affects performance (it shouldn't really as the both windows entire areas have an alpha of 0.0.)

Monday, December 9, 2013

Sharing C# Source Code With A Unity3D Project

I ran into some issues recently trying to share some common networking and data classes between a client application, a middleware ASP.NET server, and a configuration/server management tool.  All three of them needed to be able to serialize/de-serialize the same XML data; however, Unity3D does not currently support (natively) the ability to reference source code files outside of its project directory structure.

The easy solution to this on Windows is to create a symbolic link, and it works nicely.

I'll be revisiting this problem when I go to build on OSX (I presume that I'll be messing with my samba conf) and there are ways you can trick your source control system into accomplishing this (but it's really hacky) - so this isn't a panacea for the issue.

Hopefully the Unity team will introduce its own linking system that handles this (if Mono doesn't already have it...)

Worst case I'll be writing some file synchronization scripts that trigger the Unity editor to copy from the common direct (which is problematic if I make changes in Unity - but hopefully I can avoid that.)

Sigh...