I've been experimenting with the Vuforia Augmented Reality plugin for Unity3D. It works very well! In the below image, I have a teeny little animated character which appears whenever I view my business card. And those little blue things buzzing around are butterflies! Next thing to do... give her a can of bug spray and a fly swat! :-)
Saturday, July 28, 2012
Thursday, July 12, 2012
UnityGUI: Tip and Tricks
I suspect I am alone when it comes to praising UnityGUI. I was rather pleased to hear that more work has gone into UnityGUI in the Unity3D 4 Release. I know that most people don't like it for one reason or another, but I believe there are a few reasons to LIKE it that most people don't consider.
1. Text Editing. Have you tried to implement a reasonable text field widget using other toolkits? UnityGUI already does it perfectly, on all platforms. No third party GUI toolkits have the same capability. If you want your home and end keys to work, or allow the user to use a mouse to select text... UnityGUI is the best (and only?) solution.
2. Customisation. It is trivial for a programmer to create compound widgets which can be reused all over the place. Eg, grids, table views, validated text fields, etc.
3. Skinning. It is so simple to apply a different skin to your GUI, and to get artists to build a custom skin for you.
4. It's standard. You know you can use it anywhere and it will work the same. You know you can take someone else's GUI code and make it work for you without major changes. We need a standard to allow interoperability.
There are still some valid issues with UnityGUI.
It's hard for non-programmers to use, and it's hard for programmers to make nice looking interfaces. This is primarily a tool and workflow issue, and solvable. To get started with your own solution, make your GUI scripts run at edit time using [ExecuteInEditMode], so you can visualize changes. Expose all your variables in the inspector so they can be tweaked and visualised.
The performance issue is harder to solve, but I would posit that if you're experiencing major performance problems and you blame UnityGUI, then you're just Doing It Wrong. The path to UnityGUI enlightenment starts with using only one OnGUI call per scene. Next, remove your GUILayout calls, and write some layout manager code which can size and position your widgets just once, or when needed at runtime. Set your GUI.skin variable once, and don't use GUIStyle instances, just refer to a custom style in your skin. This will help you get the best performance out of your GUI code. It also helps to remember that while people are staring at your GUI, they're probably not worried about dropping to 60 instead of the usual 200 or more! :)
Finally, do yourself a big favour and learn how the event system in Unity3D works. You can get the current event using Event.current. Once you have that information, your code can make smart decisions about which methods to call and which events can be short-circuited.
1. Text Editing. Have you tried to implement a reasonable text field widget using other toolkits? UnityGUI already does it perfectly, on all platforms. No third party GUI toolkits have the same capability. If you want your home and end keys to work, or allow the user to use a mouse to select text... UnityGUI is the best (and only?) solution.
2. Customisation. It is trivial for a programmer to create compound widgets which can be reused all over the place. Eg, grids, table views, validated text fields, etc.
3. Skinning. It is so simple to apply a different skin to your GUI, and to get artists to build a custom skin for you.
4. It's standard. You know you can use it anywhere and it will work the same. You know you can take someone else's GUI code and make it work for you without major changes. We need a standard to allow interoperability.
There are still some valid issues with UnityGUI.
It's hard for non-programmers to use, and it's hard for programmers to make nice looking interfaces. This is primarily a tool and workflow issue, and solvable. To get started with your own solution, make your GUI scripts run at edit time using [ExecuteInEditMode], so you can visualize changes. Expose all your variables in the inspector so they can be tweaked and visualised.
The performance issue is harder to solve, but I would posit that if you're experiencing major performance problems and you blame UnityGUI, then you're just Doing It Wrong. The path to UnityGUI enlightenment starts with using only one OnGUI call per scene. Next, remove your GUILayout calls, and write some layout manager code which can size and position your widgets just once, or when needed at runtime. Set your GUI.skin variable once, and don't use GUIStyle instances, just refer to a custom style in your skin. This will help you get the best performance out of your GUI code. It also helps to remember that while people are staring at your GUI, they're probably not worried about dropping to 60 instead of the usual 200 or more! :)
Finally, do yourself a big favour and learn how the event system in Unity3D works. You can get the current event using Event.current. Once you have that information, your code can make smart decisions about which methods to call and which events can be short-circuited.
Subscribe to:
Posts (Atom)
Popular Posts
-
These are the robots I've been working on for the last 12 months. They each weigh about 11 tonnes and have a 17 meter reach. The control...
-
This hard-to-see screenshot is a Generic Node Graph Editing framework I'm building. I'm hoping it can be used for any kind of node...
-
So, you've created a car prefab using WheelCollider components, and now you can apply a motorTorque to make the whole thing move along. ...
-
MiddleMan: A Pub/Sub and Request/Response server in Go. This is my first Go project. It is a rewrite of an existing Python server, based o...
-
Why would I ask that question? Python 3 has been available for some time now, yet uptake is slow. There aren't a whole lot of packages i...
-
It is about 8 degrees C this morning. So cold, especially when last week we had high twenties. To help solve the problem, a friend suggeste...
-
After my last post, I decided to benchmark the scaling properties of Stackless, Kamaelia, Fibra using the same hackysack algorithm. Left axi...
-
I'm now using bzr instead of svn. I'm pushing my repositories to: http://exactlysimilar.org/bzr/ I'm also auto publishing docume...
-
Possibly slightly more correct lighting. The rim light is now only applied in the direction of the sun, rather than being purely based on vi...
-
I've just read a newspaper article (courtesy of Kranzky ) from WA Business News documenting the malfeasance, gross negligence and misc...