Handling Scene links within Prefabs

Hey folks,

I have an annoying problem:
I have a UI Prefab that is self contained, except the input cameras. The cameras can be rendering various other stuff that gets displayed in the UI via render textures.

But everytime I have to revert the Prefab in the scene these linked cameras get thrown out, since they can’t live in the prefab itself. I then have to go manually in and find all the places for cameras and relink them. Sometimes I end up doing that several times a day.

Due this being a common problem (not only with cameras) are there any best practices on how to handle this? I tried to replace the camera with scriptable objects, but realized that they too can’t link to scene prefabs, since they are basically prefabs aswell.

What is your workflow? Why do you need to (frequently) revert the Prefabs in the scene? And if you do need to revert some things on the instances, why not only selectively revert the things you need to revert instead of using “Revert All” if you don’t actually want to revert everything?

You can use the Overrides dropdown on Prefab instances to choose what you want to revert. You can also use right click menus on individual components or individual properties to revert only those.

Hey runevision,
thanks for checking by, that’s why:


This happens everytime I disable the prefab in the scene view. On the other hand I sometimes want to test something without changing the prefab, which I must save in order to test it.

You can imagine, finding the 3 cameras in there takes quite a while every time and it’s unnecessary work. Before I started this thread I was on the edge of writing an editor script, or some kind of dirty “apply camera by name” script, which really can’t be the solution. Especially since the UI is getting bigger as the game grows.

Greetings from Germany :wink:

Which version of Unity and which version of TextMeshPro are you using? Deactivating and activating a GameObject is not supposed to create overrides (except for the active toggle). I know there’s been some issues with TextMeshPro in this area, but at least some of them, if not all, have been fixed in later versions.

@runevision Sorry, I’ve been away from the project a few days. As you can see the producer of this problem is the TMP Submesh feature. This happens on all components where something like <sprite=1034> is used as “text” to display sprites. The “overrides” are also non existent, nothing in these component has changed as far as I can tell, but Unity marks them as changed anyway.

Unity Version: 2019.3.12f1
TMP Version: 2.0.1

I just put up a feature request to allow us to make prefab variants that are scene specific and can link to scene objects… sounds like that would solve your problem!

I think your editor script would be a quick workaround… you could do it a number of ways. If you don’t want to mess with stuff by name, you could add a component to your cameras with a list of objects and assign the camera to each list item on Start() or trigger with an editor command. Easy enough to remove if a bugfix makes it a moot point and probably less time to implement than one or two iterations of your camera hunting.

Hope that helps, good luck!

These issues should be resolved in version 2.1.0-preview.13 of the TMP package for Unity 2019.x.

I can confirm that TMP doesn’t produce the overrides on 2.1.0-preview.13.
However the problem in my case stays the same, since the RectTransforms seem to think they have to take over the TMPs job :smile:

It looks like some component is changing the RectTransform values without driving the properties. Do you know which component is changing the values?

Yes of course. Depending on the current window aspect ratio the ui gets updated to fit the screen when I enable it.

Not sure what you mean.

RectTransforms by themselves do stretching to parent size etc. without changing any of the RectTransform values.

Auto Layout Components like HorizontalLayoutGroup, ContentSizeFitter etc. do change values but drive the properties they change, so they’re serialized as 0 and shown as non-editable in the Inspector.

But here, the values are changed but also shown as editable (so not driven). I don’t know what is the cause of that. Can you maybe record a video showing what you do that makes the fields go from not overriden to overrideen?

Yes, there are several Layout Groups involved. The Transforms are only editable when the mask is turned off. If they are enabled, the values are driven by the Layout Groups.
The overrides occur when turning the object back off. When I turn it on, only the canvas gets overridden, because it changes from a default canvas component to one that inherits the “master” canvas.

I can’t make a video at the moment, sorry. This is my personal project, but I’m currently getting started with Addressables for work, ugh. :s

If you are turning layout components on and off, that’s expected to create overrides on RectTransforms.