Search Issue Tracker

By Design

Votes

2

Found in

2018.3.0a6

2018.3.1f1

Issue ID

1124531

Regression

Yes

Child Canvas Prefabs get correct 1,1,1 scale on disk but incorrect 0,0,0 scale in library

--

-

Repro steps (easy):
1. Download the attached project
2. Open the sample scene
3. Notice the Canvas_child Prefab instance scale is now 0,0,0
4. Open the Canvas_child Prefab Asset in a text editor or in prefab isolation
5. Notice the localScale of the RectTransform is 1,1,1

Repro steps(longer):
1. Create a new Canvas and name it Canvas_Parent
2. Create a new Canvas_child and make it a prefab
3. Delete the Canvas_child object from the scene
4. Parent the Canvas_child prefab from the project folder to the Canvas_parent in the scene
5. Notice the Canvas_child Prefab instance scale is now 0,0,0
6. Open the Canvas_child Prefab Asset in a text editor or in prefab isolation
7. Notice the local Scale of the RectTransform is 1,1,1

Reproducible in 2018.3.1f1, 2019.1.0b2 and 2019.2.0a4
Not reproducible in 2018.2.0a6

  1. Resolution Note (2018.3.X):

    Driven properties are serialized as 0; otherwise they could constantly change, for example based on current Game view size. When a Prefab with driven properties is saved or applied, it will thus have zeroes for driven values. When this Prefab is instantiated, the values will normally be driven again, and so get their proper driven values. But if they are no longer driven, they will be zero. In the case here, a CanvasScaler component was driving the localScale when the Prefab was saved (it was an outermost Canvas) but the Prefab is then instantiated as a sub-canvas under another Canvas, where CanvasScaler components have no effect (as shown in a warning in the Insector). Thus the scale is not driven, and remains zero as it is on disk. It's advisable to not use CanvasScaler components on Prefabs that are meant to be used under a different Canvas.

    Note that it's tricky to compare the behavior to earlier version of Unity. Unity 2018.2 had a bug where driven properties were not shown as such in the Inspector, and certain previous versions of Unity had driven properties temporarily work in a different way, which however caused a lot of regressions so that it was later reverted. Furthermore, Versions prior to 2018.3 didn't have Prefab Mode, and inspecting a Prefab in Prefab mode is not the same as inspecting the asset in the Inspector in earlier versions, since Prefab Mode causes driven properties to be actively driven, while inspecting a Prefab Asset in the Inspector in 2018.2 and earlier does not.

Comments (1)

  1. taichis

    Feb 12, 2019 11:48

    I can not migrate to Unity 2018.3 because of the same problem.
    I want you to solve it soon.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.