Are imported model and its prefab coupled? - unity3d

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.

Related

Export GameObject Unity to .fbx or .obj

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.

I still don't understand why is it so hard to copy a simple small prefab from one project to another?

If I just copy the prefab file from folder to folder it won't work.
I will not see the prefab with all the materials textures.
In my original project after made changed to the GameObject in this case a door I dragged it to the Assets and a new prefab created. Now I want to copy and use this prefab in other project/s too.
Screenshot of the prefab in the original project:
Then in my new project after copying the prefab file only 7KB size:
Since it didn't work in the original project I did on the prefab right click and selected Export Package...
If I'm not checking to Include dependencies it will create a package and after importing it in the other new project it will not work again.
But if I check and use the Include dependencies it will make a package of more then 32MB file size with almost everything in my original project not only the door prefab I wanted.
Now it will work fine in the other project but it's crazy that I need to package almost the whole original project just for the door prefab.
In my new project I now so much things that are not connected to the door like scripts prefabs scenes.
And I did right click on the door only. I can't figure out why is it so hard to copy a simple small prefab and use it in another project.
Now in the new project I need to import the package and look in the screenshot the new package contains so much stuff look at the scroll bar on the right how many things it will import. 99.9% not connected in any way to the door prefab:
This is the only way to use the door prefab in another project/s
99.9% not connected in any way to the door prefab
It's wrong, they are relevant.
Scripts
The prefab has user scripts attached, then all the scripts will be included, because if you remove any class, the script may not be successfully compiled.
Models, Materials, Textures, Shaders
It looks like the prefab is created from a model, so all the model files, materials, textures and shaders will be included.
If a model file is a imported model (such as FBX), then the things (generated materials, animations, ...) related to this model will also be included.
Sounds
I see sounds are also in the list, so check your prefab, there may be a AudioSource with it.
So the conclusion is the simple small prefab is not simple in fact.

How to separate object in an imported model from sketchup to unity

I have imported the house model from SketchUp to unity for my AR project. The exporting process went fine but when I tried to apply the texture on each part of the house, it just applied for the whole house. I want to know if there's a way to separate each part of the model so that I can apply the texture for each part not the whole house.
Here is my house model after export. The textures are in the separate folder.
As you can see, the door, windows, floors are all connected.
Thank you in advance!
The whole model most likely came with a single material applied to each and every part of the model.
Since that material is shared, if you apply something to it, it gets applied to all of them.
You need to create more material instances in your project and apply to each part.
Then modifying the material will only affect the part where it is used.

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.

Keep the prefab connection when updating FBX asset

The steps I have perform:
Added an Fbx to Unity Project
FBX added to scene hierarchy
Make the Prefab of the FBX
Some assignment to prefab
Everything is working fine. I did assignment to prefab NOT FBX. Now the problem is when I importing the updated FBX, my scene object didn't updated as it links with prefab not With updated FBX. The connection of my hierarchy game object is now with prefab not with FBX. So, if I replace the FBX then, the hierarchy game object will not be update as it links with prefab not directly with updated FBX.
Is this possible to update my prefab with latest FBX** so I didn't assign again and again to my script.
OR
Any else solution.?
I guess this is the really general question which frequently face by Unity Developers. Please help.
Simplest solution that I've found for this problem is to bypass Unity's asset import system, and directly overwrite the FBX asset in your project's assets directory (eg. Copy/pasting through Windows Explorer).
Note that this will probably not work if your model has a rig/skeleton applied, and you've changed them/their relationship with the model in some way since the last version.
In those cases, I would advise just re-importing the model and setting up your prefabs again, or you'll start encountering some very peculiar behaviours. (Note that only changing animations/keyframes on a model has never created this problem for me, so in those cases you can stick to my original suggestion. Naturally you might have to change the frame ranges over which your animations are defined, though.)
Hope this helps! This is a bit of a workaround, but it has worked well for my workflow when I just want to quickly update and test assets.