Unity3d saved as prefab, readding removes meshes - unity3d

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.

Related

The object I prefabs in Unity does not work

I'm making an online game with Photon in unity, everything is going well, but at the last moment I faced an unexpected problem.
I have a prefab object (tank) and I throw other prefab objects into this object, but it doesn't work, but it works when I put my object (tank) in the hierarchy as prefab and throw my other objects into my object (tank) as they are not prefabs.
For example, I want to make my game a mobile platform game, so I downloaded and added a joystick from unity asset store to my game.
If I assign this joystick to the movement script of my tank with the prefabs state, it does not work, but if I assign it to the movement script of my tank from the hierarchy part, it works.
What do you think is the reason for this, any ideas?
Edit, Instead of matching prefab objects from the inspector, joystick = GameObject.Find("Floating Joystick").GetComponent<FloatingJoystick>();` I matched it with my script file and it worked as I don't know why, but only the joystick in the hierarchy section worked, my fire button and camera tracking codes did not work. I think the reason is the connection I made with Photon, when connecting to photon, it is connected as server>loby>room, so the Start method works once until connecting to the room and it cannot find the specified object in the active scene. I have no idea how to solve this
sorry, my english is still bad so i use translate.
I think what you're saying is that you're assigning other prefabs to object slots in a script attached to your tank prefab.
If you do this when you're in prefab edit mode, then all your references to other prefabs are null when you instantiate the tank.
If you instantiate the tank in Edit mode, instantiate some other prefabs, and then make your assignments, then it works.
This is my understanding of your situation, at least. If this is right, the issue you're having with editing the prefab is that other objects are also prefabs, they're not instantiated.
You should be able to fix this by dragging the other prefabs onto your tank prefab, to instantiate them in the tank prefab, then drag those instantiated prefabs into your script slots.
As with basically everything in programming there are many other ways you can solve this, too, but this sounds the most like what you're looking for.

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.

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

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.

How would I load a Canvas from another scene in Unity?

What I'm trying to do inside this script in Unity is to load a different scene, and find the canvas from that scene and enable it. I already know how to enable the canvas from the same scene but the issue is how can i find and enabled a canvas from another scene.
I tried SceneManager.LoadScene(scenename); to change scene so what should I add or modify? Can someone help me?
Save the canvas you want to switch to as a 'prefab' in your assets folder.
If you are loading a new scene without carrying over data from the last scene then just set up the canvas in that scene using the editor.
If you are carrying data over, or perhaps a player gameobject, then you can instantiate the canvas prefab you need. This would create it in the new scene and you can have a reference to it from wherever you chose to instatiate the prefab.
Alternatively you can have multiple canvases on the same gameobject and switch them on or off as you need them. Very useful for menus.
Hope that helps.
There're many solutions:
Using MonoBehavior's DontDestroyOnLoad(transform.gameObject) for your canvas you need to be on the next scene; You can find a lot examples in Google. Here's the link : https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
Saving somewhere your current scene's gameobjects(canvas) and loading it again and recreate on the next scene as serialization etc;
Same as #2, but save required data in local variables.
There are two ways I understand your question.
You either want to copy a game object with all it's parameters as defined in the editor into another scene.
The best way to do that is obviously to use prefabs. (where to start?)
If you want to copy a game object and all its parameters after they have been modified at runtime, then you could use DontDestroyOnLoad() but that would mean the source scene has to be loaded at least once before the destination scene.