Keep the prefab connection when updating FBX asset - unity3d

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.

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.

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.

Prefab Connection Lost

I am developing a 2D game which includes different levels. At first I created the prefabs of the objects (enemies and other stuff), which I needed the most and I designed all of my levels by simply using the instances of those prefabs.
But at some point I lost the connection of all those instances of prefabs with the main prefab in the 'PREFAB' folder and now all of those instances are acting as normal gameobjects. Is there any way to make this connection relive? Because now I need to add some extra functionality into my game but as there is no connection of the gameobjects with the prefab, I just can't update the game by just updating the prefab.
First you can go to a Prefab and try to click Apply in the Inspector.
If it is not there at all than it really lost the connection.
In this case you can simply drag the same Object from your Scene onto the prefab in your Project View => The result should be that Unity replaces the existing "old" prefab with the current version you dropped on it and links them again.
However unfortunately this will not update all other objects in your Scene that also where once connected to that prefab so if you don't have any previous version of your project (e.g. using Git as suggested) I'm sorry you'll have to rebuild them using the prefab again.
The cause for that can be multible ones but maybe it is related to this question and there are just some scripts missing you removed / renamed lately.

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.

Unity 3D importing

I used to code in c# using Xna then I saw Unity 3D engine and I downloaded latest version installed correctly started development of my game but suddenly when I was importing my animated character Unity 3d blocked my pc ! I noticed that my keyboard goes off when that happened and I cant move arrow or call task menager I can only restart pc ! So brother and sisters help me on my way .
Model files that are placed in the Assets folder in your Unity project are automatically imported and stored as Unity assets.
A model file may contain a 3D model, such as a character, a building, or a piece of furniture. The model is imported as multiple assets. In the Project view the main imported object is a Model Prefab. Usually there are also up to several Mesh objects that are referenced by the Model Prefab.
A model file may also contain animation data which can be used to animate this model or other models. The animation data is imported as one or more Animation Clips.
What I understand in your question is that whenever you try to import assets into unity it makes trouble.
Try to place them in the folder in your drive and then run the project in Unity.
The normal path of Unity project is C:\Users\Public\Documents\Unity Projects
From what I understand; Your computer is spazzing out when you're trying to import Animated 3D characters into Unity 3D
I have faced a similar problem.
The solution I believe might work is :
Create the appropriate folders inside of unity. Assets > Models
Outside of unity, place the OBJ file for the models into your c:\Users\Public\Documents\Unity Projects\Your Project or wherever it might be, in the Assets\Models folder.
Then when you're inside unity, it should be in there without any issues.
That should do the trick.