Unity UI Prefabs have begun to break / exhibit strange behavior

Hi there,

So this started happening recently. Things that are anchored have started moving around and not being positioned correctly. Difficult to explain so i’ll just show you:

So these are my options sliders. The Sound Effects slider should look like the music slider. The slider is set to value of 1, and it should be anchored over on the right. But the position is wrong, so I adjust the position…

And everything looks good. I then hit apply, and everything goes back to the way you see it in picture 1! This happens randomly, and in a lot of places. Any thoughts on this one?

Bump - I really need an answer to this question. Can anything be causing it?

Sliders are positioned based on their value, its probably just correcting the position.

Be VERY careful applying prefabs with Unity UI. It will change it for everything in all of your UIs.

@LaneFox they don’t “break” until applied to the prefab. Note the position that it sets to: -123, the value of the slider is 1, and it is right justified. The value should be 0.

@LunaticEdit I need it to be a prefab, because this is my UI that gets instantiated in every scene. Not sure how else to do it.

I was having the same problem, I got crazy and started to try a lot of things, I guess I solved it by changing all sliders to center and making then childs of the panel behind.

When it was happening to me, I used to delete and put another one, but every time I tried to prefab, I got this strange error, until it stop happen :slight_smile:

This is an annoying bug which has been occuring since the first 4.6 beta. With each new version, we were hoping to see it fixed, but we’ve given up hope, so now we’re keeping all of the UI in the scene instead of in prefabs. It’s not a fix, but then there’s not much else that we can do about it.

TBH I don’t get how stuff like this even makes it past QA, much less past beta stage. This bug has a super high reproducibility rate and it will occur at some point wherever you may be using sliders (like maybe in every Settings menu & HUD ever made.)

Did anyone submit a bug report? If so, post the case number here in case a Unity engineer comes by.

1 Like

@Victor_Kallai is it weird that i’m happy that other people are suffering from this problem? I was worried that it was just me. Man I have WAY too many scenes to break the prefabs on all of them… maybe i’ll let it sit there as a bug for now.

we did just find a bug with 5.0 with prefabs and ordering, its been back ported even though we couldn’t repo the same issue in 4.6.X. if you have a bug report that would help us verify

I have a sort of similar bug happening which I described here: Annoying bug with child canvasses - Unity Engine - Unity Discussions

@phil-Unity my project is enormous - 4+gb. If i submit a bug, can i submit multiple bugs at once?
for example my other thread:

I’d like to report both at once.

sure, i think QA might just separate them out into different ones at a later time.

Could this be related to the post below, which I literally came across in the last 30 minutes after installing 4.6.2p1?

If anyone gets this bug - I have a workaround:
Break the prefab, fix your issue, then create a new prefab (Don’t overwrite the old prefab, delete the old one and drag out a new one). Things can definitely break again, but for now that seems to be working for me.

I am having the same issue and i cannot figure out a single way that it may be fixed from our side. It seems that the pivot points and and the anchors positions calculations reset internally when we hit apply to prefab on a parent object of the prefab. Thus that means that we cannot create any single multislider prefab.

This though is way to much tedious to be done correctly. And if you have nearly 100 ui objects active on your scene at runtime this is not going to happen.

@Drowning-Monkeys this did not work for me. It is just times that works and some others that doesn’t.

For example : If i break the prefab and i create a new prefab from the new modified game objects it seems ok while it exists on the screen. Then when i try to instantiate it sometimes it breaks even in runtime.

To me the only solution seems to just have a datatype that represents the slider transform and slider utilities. Then create an empty game object at the place that you want the slider to be generated in runtime. While in runtime just create the functionality to replace the empty gameobject with the slider prefab (it seems a bit messy to try adding components and all the children the original ui uinty slider has). Then try to replace the properties with the datatype properties you have stored through a scriptable object.

Seems like the only solution and it may be a bit of overkill that kind of use of scriptable objects; but i cannot figure out anything else.

Also something that i just found is that the “Handle” gameobject of the “Handle Slide Area” of the “Slider” prefab gets a bit confused when you hit apply to prefab on any parent object or hierarchically higher object of the slider.

This actually happens or has its Pos X property messed up somehow and it literally changes it to some relative value of the canvas (plus pivot of the parent) to a negative value.

Moreover this seems like a standard issue i did notice that this is not the case when i disable Raw edit mode on recttrans and when i select Stretch on all the parent objects of the slider.

Weird enough.

@doukOmega this worked for me for a day, then broke again… sigh

So this has been driving me around the bend a few times the last few days.
A more permanent workaround, since the Devs seem unmotivated to deal with it, is to use an image(UI-> image) instead of a panel. It scales ok, and doesn’t break sliders as it goes.
This is especially a problem for those of us stuck on 4.6x due to the broken joints issues in 5.

So little time, so much to do. You should cut them some slack.