Export GameObject Unity to .fbx or .obj - unity3d

I have built a building in unity, with cubes, etcetera. Now I want to use it as a single object (since using it with so many objects makes it difficult to move it from the scripts). Is it possible to export this to fbx and then have it in assets?

Not as fbx but yes and it's possible to have that item as prefab. If you want to have this building in your assets and use it whenever you want, just put all your shapes in an empty gameobject (to move it via just one container) and drag and drop that gameobject into your project window. Thus you'll have the prefab of that whole building mesh and you could reach it from editor or by script anytime you want.

Related

Are imported model and its prefab coupled?

I import models from Blender into Unity, then make prefabs from them. But can't delete the original imported models without affecting prefabs.
This is the step by step discription:
I create a simple model in Blender. Just meshes, without textures, lights and other things.
Export it as (Collada .dae) - that is not important, which exact format.
Import it into Unity's Project window (drag and drop from file explorer).
Drag it into scene.
Drag it from the scene into Project window - create prefab through "create original prefab" option. Now I have an Unity prefab and original imported file - two "Body" objects for example:
The first "Body" is .dae file, the second one is Unity prefab constructed from it.
As far as I understood, at this point two these objects are tightly coupled. I can't delete .dae file, because all the models from Unity prefab will be deleted too, so I became just an empty object.
Is it just as normal? Have I keep duplicates in the project to use just the Unity's prefab, not original .dae file? Or is there a way to decouple them?
Another example of such a case. He also created prefab from imported model, but at the end he has two same objects in his project: Unity prefab and original imported model.
Yes of course they are!
Your prefab uses the imported model asset(s) as meshes and materials etc.
Is it just as normal?
Yes it is absolutely normal ;)
Prefabs themselves almost don't need any disk memory since they are basically only serialized hierarchy templates and only store serialized values and references. You can open a prefab in a text editor and will see it is jut some serialized YAML text.
It is rather the according imported models and other assets (meshes/materials/textures/etc) these prefabs reference and which are actually storing the "heavy" data.
So deleting the meshes/imported models doesn't make any sense.

Unity - player falls through objects imported from blender

I made a simple 3d map with blocks in blender and imported it into unity. But when I put Player on it, always falls. I want to use gravity, but I don't know what components should be added to imported objects to make the player able to move on them, not falling through them.
Now I need to manually add box collider to every component which is quite annoying. Can it be done smarter and faster?
On the model asset in the project assets list, make sure you've checked "Generate Collider" (or similar), and apply.

How to replace model without a prefab file?

I'm new to ARCore and followed this article: https://haptic.al/arcore-101-fa6f93d4c003 to add a model with animation and see it with my phone camera.
I switched the model from the article (kitty) with a ball that I downloaded from Unity assets store, I just replaced the previous prefab object with the new one from the ball package that I imported.
Everything works fine, but now I want to download other model from the Unity store and I see that some models don't include the prefabs folder or a prefab file inside the the model package.
Is there another way to switch my current model with a new one without being use the prefab file?
Thank you.
Even if the downloaded file doesn't contain a prefab you can still create your own prefab by placing the object in the scene (.fbx, .obj files etc.) adding whatever materials you want it to have, and then dragging the name from the Hierarchy panel into the Project panel. The name in the hierarchy panel should turn blue if you've made a prefab successfully.
Note: you don't need a prefab to put something in the scene, a prefab represents an object that has a particular state saved instead of the defaults (transform rotation, materials, colliders, etc.). If you add things to an object and save that object as a prefab then whenever you place that prefab into the scene it will have those components still attached.

Inspector is disabled in unity

I added a blender file to my assets, and when I click on this file in assets I can't add a component such as SkinnedMeshRenderer to the imported asset as shown in this screenshot. How I can add it?
A SkinnedMeshRenderer is not something you can just add in Unity.
As said in the documentation:
Unity uses the Skinned Mesh Renderer component to render Bone animations, where the shape of the mesh is deformed by predefined animation sequences.
A SkinnedMeshRenderer is automatically added when a skeleton is found in your asset. To have a SkinnedMeshRenderer you must export a skeleton from blender. If you don't have a skeleton, it means that a SkinnedMeshRenderer is not required.
The "Imported Object" is a Unity asset that doesn't accept additional components. Try creating a prefab (right click in Project folder and select Create -> Prefab), give it a unique name, and then drag the "Imported Object" mentioned above, from the Project panel not from the inspector, onto the newly created prefab object in the Project panel. Components can now be added to the prefab. Whenever referencing blender models access them through prefabs in such a way. Prefab copies can be added to the scene by clicking and dragging the prefab into the scene or by using GameObject.Instantiate with scripts.

Unity3d saved as prefab, readding removes meshes

In Unity3d I found the feature of saving GameObjects through dragging them from the Hierarchy into the Assets Folder. I'm using this to test stuff in a different scene.
Strangely, I it doesn't work with this one properly:
after readding it, all meshes are missing:
Do you know how to fix this?
Is there a possibility to move gameObjects, maybe through code, from one scene to another one(in editor)?
It is possible to move GameObject from one scene to another by using DontDestroyOnLoad, if you need to do so in runtime.