Wednesday, December 14, 2011

Alpa Transparency and Unity

I ran into a problem when I tried to create a material with a transparent texture in Unity.
The image (texture) would always show with a black background on my model. I had saved it as a PNG so it should have worked. The solution was to change the shader on the material to Decal and place the transparent texture image in the RBGA slot (the second one).
Also you can set the shader to Transparent-Diffuse or something similar within the Transparent option. Don't forget to set the image as the texture.
Shader options can be found by selecting the material in the Project panel, then choosing options in the Inspector panel.
link: How do I use Material/Texture alpha on a plane?

Importing FBX files from Blender to Unity

First off, here are two good video to watch:
Importing Blender 2.5 Objects into Unity 3
Exporting a Lowpoly Model to Unity 3D

I had so much trouble with this that its not even funny (well it sort of is now) but it took me an incredibly long time to figure out how to get my lovely models from Blender into the Unity game engine.

Here is a checklist of things you must do and problems you may run into (I'm sure I ran into ALL possible problems):


 "You need to have Blender version 2.45-2.49 or 2.56 or later (versions 2.50-2.55 do not work, because FBX export was changed/broken in Blender)." According to the Unity Manual.
Fix: Get the newest version (2.56a) which seems to be working fine for me.

You may get an error that says: "Object '...' has a scale of ..., Armature deformation will not work as expected. (Apply scale to fix). This is because the model was scaled, rotated, or moved around in object mode. If you don't fix this, you won't be able to save the .fbx file.
Fix: While in object mode with your model selected, click Object > Apply > Rotation (as well as Location and Scale). Be sure to set the origin to (0,0,0) Object > Transform > Geometry to Origin.
link to answer:
BlenderArtists.org: wont export to .FBX

You may succeed in saving the .fbx but find that there is nothing visible when you get into Unity. Also, you may have imported unwanted objects like camera or lights. Or you may have not been able to import animations.
Fix: The first video up top has the answer to that, so watch it for more detail, but basically you have to select the item(s) in Blender that you want to export before you save your .fbx file.
link to answer:
Importing Blender 2.5 Objects into Unity 3

Model imports to Unity VERY small! This problem has to do with Unity - it defaults to import fbx at .01 scale (sort of dumb).
Fix: in the Project panel, click on your imported model > look in the Inspector panel for the FBXImporter section > set Scale Factor option to "1". Then click somewhere else for it to take effect, some message will pop up - just click okay.
link to answer:
Objects from Blender (FBX Exported) are scaled wrong

For a while, my objects were showing up just fine in Unity, but when I pressed play, the model would "disappear"! If this is happening, your object is not disappearing from the scene, it is just jumping its location from where you put it to (0,0,0) the origin of the scene. I was so mad, but I realized that I had missed an important step.
Fix: You have to place a prefab of your object into an Empty Game Object. Click up top on Game Object > Create Empty. Shortcut (ctrl + shift + N). In the Hierarchy panel, the new Game Object will appear. Drag your prefab model object into this Game Object. Rename it to whatever you want.
links to answer:
3d Studio MAX FBX Export question
extreme newb - importing keyframed maya mesh

I highly suggest going to all of the links listed and reading the posts, because they were very helpful to me - they could give you a better idea of what you should do.


While trying to paint trees on a terrain I got this error : "Tree...couldn't be instanced because the prefab contains no valid mesh renderer".
Fix: Be sure to import a single mesh, object, or model or it may break Unity. I had my tree's Trunk and Leaves as different meshes in the saved .fbx file. After I went back in and joined the meshes in Blender and re-exported to .fbx as one mesh, the problem was solved.