I’m told this is a known bug that causes a prefab to always say it can be overriden even when you’ve just overridden it? " … it’s a known issue in Unity that still isn’t fixed in Unity 2019. If a UI element has an auto layout component of some type, such as Horizontal Layout Group or Content Size Fitter, the Rect Transform values in the scene may be slightly different from the prefab due to floating point precision." Is there any workaround to this? It’s super annoying
This old problem is still valid today, and it does not only arise from floating point precision. The workaround I found is to disable the problematic components (uncheck the enabled checkbox) at design-time and enable them only at run-time (in Awake).
The same problem sometimes occurs when specifying a camera in Canvas in a prefab, when Canvas itself is a prefab, sometimes when Canvas has pixelPerfect, and in other cases. I created scripts that set problem properties in Awake, and set them to a safe value during design-time.
Also, this problem occurs if you make the inherited game object invisible in the prefab variant, so I hide it in run-time too, and it helps.
+1.
What’s the approach for doing something similar to this;
Where we grey out values driven by a LayoutGroup?
The way I see this, as any script that will temper with editor values in editor time, would be for unity to add a checkbox on layout builders to disable autorebuild in editor, when checked out, it should then display a “update layout” button and “update layout and child layout” button. It’s hence without breaking change as the default behaviour remains.
Meanwhile, I think it’s once again a job for Odin as it can extend base unity types. Not sure if we can disable editor auto layout rebuilding. If this is the case we need to extend the layouts or copy them in new classes to remove to auto rebuild.
It’s quite a good workaround.
Do you know if Odin handles this? Or if any other asset does?
I’m making a script for this, will let you know if it works.
Very much looking forward to seeing what you make.
https://gist.github.com/builder-main/680cc14cdaabb1cc2a7ec58992bdad29
Quick POC. It works for us, however you’ll be missing some of our internal classes. I don’t have much time to make a standalone version right now, but it should be fairly easy to adapt (I or anyone might adapt it in the gist directly) :
How to :
Scene object workflow
- Must put in a topmost parent of the roots. (Don’t work for roots not in the component children for now)
- Add all the layout roots you need (Top most could be enough)
- Use Populate button (could be used at runtime be I mostly tested it at editor time). It will disable all content size fitters and layouts while adding them to a list in order to enable/disable them in the UpdateAsync at runtime.
- You can fine tune filters if you don’t get what you want.
- At runtime use the UpdateAsync func and use sequential update checkbox if needed to update your layouts.
- Don’t use revert variant button
Prefab variant Workflow :
- Same as above
- You can use revert variant button in variant prefabs (not the original one !) recursively up, it will revert all things layouts/content fitters temper with, now your prefabs won’t be dirtied anymore.
Final note :
I had a 10fps increase.