Share same Navmesh with Duplicated Scenes - unity3d

I had a Scene with a map (some buildings and roads) and Baked Navmesh, then I started Duplicating the Same Scene with modifying some objects inside (not the map or the world), so all the Scenes were sharing the same Navmesh somehow, then I deleted the Navmesh accidentally, Now the only way I seem to find is to create a new baked Navmesh for every Scene which will increase the build size too much!, How can I re-share the same baked Navmesh with all Scenes since all have the same map inside ? I am using Latest Unity3D.

Before You Start: if you have a lot of assets in your project changing serialization to Force Text may take a lot of time. So you may want to copy the target scenes to a new project, do the below mentioned steps and paste them back. :)
There is no way to do this from Unity editor, but there is a workaround:
Go to Edit > Project Settings > Editor and change the Asset Serialization to Force Text (default is Mixed) - this makes sure all assets, including your unity scene files are saved as text documents
Now open your scene file (the one with baked NavMesh) in any text editor
CMD+F or CTRL+F to focus on search bar and type "NavMeshSettings". In NavMeshSettings the last entree should be m_NavMeshData:{fileID:1234 //and some more stuff here} - this is reference to your baked NavMesh asset file. Copy the whole line
Now open the second scene that you want to share your NavMesh to (open in text editor again). Find exactly the same line starting with m_NavMeshData, delete it and past the line from the previous scene.
BOOM!
Edit/Tip: You may want to change serialization to Mixed again if you want to. The only downside of texted serialization is bigger files. It is mostly used for version controlling and merging and the scenes and stuff...

Related

Unity, Sprite textures don't load when pushed on github

I'm actually working on a Unity project and I'm using Github.
I decided to do again the menu of the game but when I switch computer to work again on the project I got some issues with it.
As you can see a big part of my Sprites and Fonts don't load. When i set back the menu by putting Sprite textures to Sprite (2D and UI) and adding the component it works well. But when I push the modification and pull to another computer, the same problem happen. The Sprites textures are back to default :
All the other sprites or prefab are working well so I don't understand.
Version : 2021.3.4f1
Make sure you are using VisibleMetaFiles in ProjectSettings -> Version Control -> Mode
Make sure that the metafile for the texture with issues is not corrupted and is under version control (it will be right near your texture with the same name and the .meta extension)
Check the history of this metafile to make sure that it is really pushed to the repo and then downloaded from there
Import settings for the texture are stored in this metafile, so you need to make sure that it shares correctly between two computers

Unity 2020.1.0b12.3931 - Objects from scene 2 are visible in scene 1

I don't know if this is some sort of bug or (which is likely) I'm doing something wrong, but I have two scenes.
menuScene is a starting point and it suppose to have nothing but canvas with some input fields, sliders, labels and a button.
Clicking the button moves to gameScene, which (by default) contains some objects.
This is what I see when I run the project:
What do I need to do to make only menuScene visible on launch?
In general: Unity 2020.1.0b12 is a BETA version and not unlikely to have a lot of bugs. If you are not investigating the most newest features but rather want to implement a serious project you should stick to the latest stable Unity Version (currently 2019.4 LTS).
You have opened both your Scenes in the Editor! In your Hierarchy I can see both scenes menuScene and gameScene.
In this case SceneManager.Load loads your already existing but currently unloaded (disabled) scene (basically only enables it) but keeps the other scene(s) in place.
Note that within the Editor Multi Scene Editing is possible and even if you then start the PlayMode both scenes are still there.
However, in a build later only the top-most scene of the list in the Build Settings is loaded in single mode!
The follow up error you got is due to your scenes not added to the Build Settings. Simply drag & drop your two scenes into the list in the Build Settings.
Then open only the first scene in the Editor (click Remove on the other ones) and then enter PlayMode again. Now it should load your scenes in single mode

Unity deforms every prefab that I create

I have problem with Unity prefabs. Every time I create a nice looking UI in main scene and I want to store it as prefab for later usage if I open this prefab it's deformed(random cliping, moved UI elements in different directions, ... such a mess). If I try to fix this prefab in prefab editor to make it nice looking like before and then if I insert this back to scene it's totally unusable. It creates bigger mess than before in prefab editor... I don't know what to do. Editor throws no errors btw.
In first image is nice looking UI(example already created). In 2nd image is prefab editor. Text is totally out of panel and 3rd is from back in scene (means removed old one UI and place stored prefab from folder) the panel is gone.
Imgur - images are orded by scene to prefab editor and back to scene
On those images you can see a 3 elements... but if I make more complex UI, it's clipping through each other in prefab editor and also back in scene.
Unity version: 2019.1.7f1

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.

Add scene when build Unity project

When I build Unity project I saw that if I add current scene Unity or not the game still run fine.
So what is the purpose of add scene ?
If you have not added any scenes then unity will build with your current opened scene by default. The purpose of adding scene is to handle among multiple scenes like Main Menu, Store, Gameplay, Gameover etc. To get more than one scene, you have to add all the relevant scenes, otherwise unity will not recognise the scene when you want to switch to another scene.
As long as #Hamza Hasan answer is correct, I think that question author means something diffrent.
He asks why he should add scene if it works fine in Editor without this action.
So the answer is, if this scene is not first default one (and it is your case), you wont be able to load it programaticaly, as it wasnt included into build even if it works in Editor. It works in Editor couse it was loaded into memory opening the scene.