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
Related
I am new to unity and working on a image viewer in unity2D.
I am not sure if I choose components true but for now working fine.
most of the project is script based
I created a prefab which has a raw image
and in script I Instantiate prefabs in a scrollviews content
images are displayed no problem in that
I added some events where I Instantiate my prefab pointerDown, beginDrag, endDrag
dragging workin fine too
but when I drag any added prefab to older added prefab it stays on top but if I drag it to a newer added prefabs it stays under them.
I think its because the hierarchy order.
how can I change the order or how can I manage to make prefab stay on top when dragging
ps: on the image thumb_0 is added first and after drag it stays on behind thumb_2
if you can access the Transform of your prefabs you can use the method SetAsLastSibling(); it will move your gameobject to the last spot under your parent object, therefore causing it to be drawn on top
https://docs.unity3d.com/ScriptReference/Transform.SetAsLastSibling.html
EDIT :unless you mean dragging it manually, so then drag it to the bottom , last item always appears on top
Im just starting to use the new Unity nested prefab workflow (or what ever you call it) in Unity 2018.3
So how it works is when you want to edit a prefab, you select it then click on the arrow. When you do this it erases everything from the hierarchy window and then you only have that prefab visible until your done editing it, you click save and then its back to the original hierarchy that was there before you started editing.
This is all fine, but the problem is what if i want to drag a game object from my scene into the prefab im editing is now impossible because as soon as you start editing the prefab, it removes your scene and only shows the contents of the prefab. So you cant drag anything from your scene into the prefab any more because its gone for the duration of the editing.
I dont know if im making myself clear or not.... But basically im saying while editing the prefab, only the contents of the prefab is visible, your scene is not visible, so you cant drag any object from your scene into the prefab anymore.
Anybody knows how to get around this? Right now i want to drag a gameObject from my scene into a prefab im editing to make a reference to a global object, but while editing the prefab my scene is not visible, so i cant do it.
Thank
Just create a copy of your prefab in Hierarchy and make you required changes to that copy once done, drag and drop that copy on you prefab and it will be updated.
When dropping the copy on your prefab you can either create a new prefab or update the original one.
Editing a prefab can be done in multiple ways. To achieve what you want, you should drag an instance of the prefab into your scene where your "other" gameobject is. Ensure that the prefab instance is blue, so that you know that it is still connected to the prefab.
Now, drag your "other" gameobject onto the prefab instance, so that it becomes a child of it. Now you should be able to apply prefab changes through the inspector.
Do note, if you cannot change the position in the hierarchy of the "other" gameobject onto a prefab from within the scene view. If you want to change the position, you should open the prefab scene after applying changes.
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.
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.
I'm having a terrible issue where if I create a new UI element on a canvas (such as a Button) drag it into the project files to create it as a prefab, delete it from the scene, and then Run my game, the prefab loses its Image and Button scripts. This is also happening to any image/text/UI element. Any time I make them prefabs, and then run the game, the lose their image/text/button/UI script.
Why is this?