Useful Unity3D Stuff
I work quite extensively with Unity3D and over these past few years I've come across a ton of problems. Usually I managed to find a solution for them, but I don't always keep a record of those solutions. If I do, it ends up being a bookmark or a note somewhere. So I decided to make a post to keep track of useful stuff for Unity3D. I can finally clean up my mess! And who knows. It might help other people as well.
Unity3D Useful Tools, Scripts, Shaders
- Invert/Reverse Mask Shader
- Create Bitmap Fonts for Unity3D
- Open Source Unity3D UI Extensions. A bunch of scripts with more advanced and super useful UI features and effects for your Unity projects, such as Accordion, Scroll Snap, Re-orderable Lists, Curved Text, etc. Best of all... it's FREE!
- Copy to Clipboard Script for iOS & Android
Unity3D Fixes and Workarounds for Bugs and Other Wacky Things
- Allow Animator Triggering Same State
- Unity3D 4.5 Hierarchy Sorting By Name
- Black Screen on iOS Devices
- Animation Must be marked as Legacy Warning
- Canvas Component - Override Sorting disables Blocks Raycasts
- Rigidbody 2D has velocity but isn't moving after Unity 5 upgrade
- iTween.MoveTo is tweening the button to the wrong position in the Rect Transform position
- More advanced ScrollRect usage to add and expand items
- Android Keyboard White Text on White Background
- Android - Unable to List Target Platforms
Unity3D Features & C# Explanations
Articles and links that explain how certain features and coding principles actually work.
- SendMessage and BroadcastMessage
- Why float comparison doesn't work
- Designing UI for Multiple Resolutions
[FIX] Unity3D - Allow Animator Triggering Same State
For a recent project, I was trying to trigger the same state from the Any State in the Mecanim Animator in Unity. When doing so, the transition did trigger, but it failed to flag the trigger back to "false". This was causing some animation bugs, since the game was setup so the user can replay that level. Upon replay, the animation would get triggered twice or since the trigger was still flagged "true" before it could reset back to the original state. To fix this problem, there's a check box called "Can Transition To Self" in the inspector which you need to turn on (it's unchecked by default). Check it and you're done!
Source: http://answers.unity3d.com/questions/877897/trigger-the-same-state-again.html
[FIX] Unity3D - 4.5 Hierarchy Sorting By Name
Ever since the release of Unity3D 4.5 they changed the sorting of the GameObjects in the Hierarchy window to be based on the based on transform order instead of object's name. Although I do see some some causes where sorting it by transform order might be useful, but generally I would prefer to find my GameObjects based on the name. In Unity3D 4.5, there's no option anymore to sort it by name by default. You can use the search at the top of the hierarchy window, but it's a pain in the ass in my opinion.
There's actually a way to re-enable the alphanumerical sorting again. Simply download this little script (Unity3D-AlphaNumericSort) and place it in the Assets>Editor folder and you're done! An option will appear in the hierarchy window where you can switch between sorting it by transform order or by name.
Source: http://forum.unity3d.com/threads/unity-4-5-new-hierarchy-window-sorting.248298/
[FIX] Unity3D Black Screen on iOS Devices
We were trying to run a build of Puzzle Football on iPad yesterday to see how the game would look from an iPhone5 aspect ratio (16:9) to an iPad aspect ratio (4:3). But when we tried to run it the screen goes black. The game launches and the buttons were working so the game wasn't stuck. The weird thing was that it runs fine on the iPad2, but it shows a black screen on the iPad Mini.
I found a fix on the Unity forum which mentions changing the Clear Flags property on the Camera object by setting it to "Solid Color" (it was on "Don't Clear" before). Not sure why it needs to be on Solid Color, but it's working now! No more black screen on the iPad Mini!
[FIX] Unity3D - Animation Must be marked as Legacy Warning
I ran into this warning the other day when I tried adding an animation clip to an object "Animation Component must be marked as legacy", and there was no obvious way to find and fix the legacy problem... After searching a little bit on the internet, I found this solution to fix the warning:
Select the animation clip in your Project > Go to the Inspector tab and clip on the "hamburger" button > Then select "Debug".
The inspector options will change into debugging mode and there set the "Animation Type" from 2 to 1. Set the inspector mode back to "Normal" through the hamburger button and it's fixed! No more legacy warnings!
Create Bitmap Fonts for Unity3D
I used to use BMFont to generate bitmap fonts for Unity3D when my Windows laptop was still working. It's still out at the repair center waiting to be fixed, so I've been working on a Macbook ever since. Unfortunately, BMFont is only available for Windows, but I found a great alternative called Littera. It's a web application to generate bitmap fonts and it has numerous awesome extra features such as adding gradient, stroke, shadow, bevel, etc. Generating a bitmap font is very straightforward. You just upload a font set the desired size, resolution and format, and export it!
Testing Substance Designer 3.5
I found out recently that my Digital Tutors account from the ETC is still active, so I decided to do some tutorials on Unity3D and 3dsMax while I'm sitting here at home. It's going pretty well. Nothing to really show yet on Unity or 3dsMax, but I stumbled upon the Substance Designer software when I was browsing the tutorial list and decided to check it out. Substance Designer is a texturing tool which allows you to create high quality textures using nodes. It comes with a bunch patterns and filters and the software allows you to pack all your texture maps (diffuse, normal, specular etc.) into a single Substance texture file. On top of that you can connect the Substance textures with Unity3D or UDK and dynamically change parameters of your texture within the game engine. The software is really awesome so far. I can't wait to get more proficient with modeling, so can create kick ass textures for them :D
Below you can see a quick test using Substance Designer. I made a brick texture within Substance Designer with a normal and specular map and added a sketch of mine on top of everything.