Combine two sprites into prefab Unity - unity3d

I have two sprites I downloaded off the asset store on my canvas one is a building, one is the foundation the building sits on.
However, in my game these two sprites will always be together. I'm going to be creating many instances of these on my map and I don't want to have to drag each piece on to the map individually and position them. So I was hoping to highlight them both and turn them into a prefab so Id just have to manage one object instead of dragging around both sprites.
I could just open them in photoshop and combine the two images but I'd prefer to just put them together in unity and leave my sprites modular.

You can create a empty object. This object is parent object.
Then in hierarchy window, you drag 2 sprite to this parent object. So 2 sprites is child of parent object. Make this parent object as prefab.

Related

Can I have multiple sprites on one game object in Unity?

So I'm making a 2d top down game and one of my enemies is supposed to be a tank. I have two separate sprites for this tank, one for the tracks/body and one and for the turret. I want to have one game object contain both of these sprites. I would just combine them into one sprite but I want to have the turret rotate itself to face the player using a script I wrote while keeping the tracks pointed in the direction the tank is moving. Is this possible? I'm new to Unity but, I cant think of another way to accomplish this goal.
A good way to do this would be have a parent game object A with two children game objects B and C. B can have a sprite for base and C can have a sprite for the top. You can then rotate each game object individually and can still use gameObject.GetComponent(). To move the tank move the parent.

Move multiple child objects with parent in Unity + LeanTouch

I am facing some issues using LeanTouch asset.
Context:
I am creating a Human Anatomy application using Unity3D and Vuforia. My task here is to enable user to select, drag, move human skeleton and different organs to inspect them. I was able to achieve this as long as my GameObject does not have any parent.
For example, I have a Heart 3D model having 3 child gameobjects. If i use leantouch's selectable and other drag translate. It works with no issues. But as soon as i apply the same components to the parent Heart Object. It does not work.
If you want to try it out. Create 2 or 3 3D cube objects in unity. Then create an empty gameobject and place 3d cubes into it. Now try to add lean touch components to the parent gameobject. It won't work.
Thanks

How can you make a prefab that can expand to show its constituent objects?

I am very new to Unity3d. I want to make an prefab that expands with a little right facing button to show other objects. I have tried giving the prefab children and then dragging it into the project window, but it didn't show the little right-facing arrow. Can anybody help?
To add components to a prefab, add it to the scene as you said you have, then drag your next object on top of the prefab in the Hierarchy window. Sometimes this places it relative to the prefab but does not actually child it, so simply drag the object now in your Hierarchy onto your prefab once more and it should fall in place as a child, you will know this worked if you now have an expand node next to your prefab.
First, make your root game object that you will convert into a prefab.
In order to add objects which are children, right click on the root object and then make the children. You can also drag other gameobjects onto the root game object to make them children of the root game object.
Finally, drag your final prefab into window where all of your files are, and the resulting prefab will have children.
If you want to change the prefab after it is made, you have to change one object that results from your prefab and after changing it, click Apply in the top of the Inspector window to apply that change to all other objects resulting from the same prefab.

Do Meshes get reloaded when switching scene?

Lets suppose I have a scene with several meshes like trees, boxes, etc. lets call it level 1.
After I finish playing level 1 I switch to level 2 like this.
SceneManager.LoadScene (1, LoadSceneMode.Single); //level2 scene index is 1
The thing is level 2 uses the same meshes level 1 uses. Do they get unloaded -> reloaded?
I'm not talking about DontDestroyOnLoad, as I dont need the same instances of the GameObjects in the level 2 scene.
I'm talking about the Model Data of each object (the meshes), not their instances. I know the instances are deleted, but I think Unity someway knows the next scene uses the same Meshes and keeps them. I just need to know if the Meshes are unloaded and reloaded when switching scene.
Objects that you don't call DontDestroyOnLoad on are destroyed once you change the scene using LoadScene (as if you called Destroy on them all), so yes the get reloaded. They are destroyed then (if they're present in the next scene) they're re-instantiated.
If you do edits to a specific object instantiated in a scene then these edits belong to this object.
If you load the same scene more than once then this specific object will have your edits. However if you load a different scene that has this prefab then the prefab will be a new one without the edits.
If you want all object instantiated to be like this object you have to edit the prefab. To do this you just click the "apply" button.
This will make all objects that become instantiated have the edits.
If you want some object to have the edits and some not to have them you make a separate prefab, just drag the "name" of this object from the hierarchy into your project folder. You've just created a new prefab and you can use it.
Also remember that this doesn't apply to edits done within the game. These are edits that you do (as a developer not as a gamer) in the scene view. Game view edits (for example if a player squishes a cube) are lost after game close.

How can i switch multiple layer with same sprite?

I have 6 sprites on screen, now after particular time, I want to reload that 6 sprites without affecting screen. (with removing old & add new images)
like objects are changing in one frame.
I use Layers for this, but I am not able to assign two same sprite in both layers.
How can I switch multiple layer with same sprite?
got the answer.
just detach current layer.
initialize next layer.
overwrite ArrayList (in my case, i have taken arraylist of sprite) of sprite with required images.
attach that arraylist to newly created layer & then attach that layer to scene.