UI Prefab lose its orignal Rect Transform values
UI Prefab lose its orignal Rect Transform values
I tried to create a UI prefab that will be responsive to its parent canvas setting, this is its original Rect Transform values
It works fine if I directly drag and drop this prefab under the canvas under dialogue manager, but when I use it in the Dialogue UI under the display settings and run the game, the value is changed to some really weird numbers
Is there a way to solve this problem? Thanks!Re: UI Prefab lose its orignal Rect Transform values
Hi,
The Dialogue Manager has a Default Canvas field that, by default, points to a canvas with a Canvas Scaler that scales to a reference resolution of 960x600. You can, of course, change the Canvas Scaler or point the Default Canvas field to a different canvas if you want. I don't think the Canvas Scaler is the entire issue, since it would presumably limit your UI to 960x600, but I mention it in case it has some effect on what's going on.
Does your canvas have any layout components such as a Vertical Layout Group or Content Size Fitter that might change your dialogue UI's layout when it becomes a child of that layout component?
The Dialogue Manager has a Default Canvas field that, by default, points to a canvas with a Canvas Scaler that scales to a reference resolution of 960x600. You can, of course, change the Canvas Scaler or point the Default Canvas field to a different canvas if you want. I don't think the Canvas Scaler is the entire issue, since it would presumably limit your UI to 960x600, but I mention it in case it has some effect on what's going on.
Does your canvas have any layout components such as a Vertical Layout Group or Content Size Fitter that might change your dialogue UI's layout when it becomes a child of that layout component?
Re: UI Prefab lose its orignal Rect Transform values
Hi Tony,
I change the default canvas field's canvas scaler to 1080*1920 (since I'm making a mobile game) and I also change the screen match mode to "expand". Not sure if that's the reason?
I do have a vertical layout group and content size fitter for some of the elements like subtitle background and nametag background... If I directly drag my UI prefab under the dialogue manager's default canvas, then everything works perfectly fine.
I've found a temporary way to solve this by selecting "add instance" and manually changing its Rect Transform, but I do hope I can find a way to directly use the prefab since I want to update my settings and layout across the scenes by updating the prefab.
I change the default canvas field's canvas scaler to 1080*1920 (since I'm making a mobile game) and I also change the screen match mode to "expand". Not sure if that's the reason?
I do have a vertical layout group and content size fitter for some of the elements like subtitle background and nametag background... If I directly drag my UI prefab under the dialogue manager's default canvas, then everything works perfectly fine.
I've found a temporary way to solve this by selecting "add instance" and manually changing its Rect Transform, but I do hope I can find a way to directly use the prefab since I want to update my settings and layout across the scenes by updating the prefab.
Re: UI Prefab lose its orignal Rect Transform values
Hi Tony,
I change the default canvas field's canvas scaler to 1080*1920 (since I'm making a mobile game) and I also change the screen match mode to "expand". Not sure if that's the reason?
I do have a vertical layout group and content size fitter for some of the elements like subtitle background and nametag background... If I directly drag my UI prefab under the dialogue manager's default canvas, then everything works perfectly fine.
I've found a temporary way to solve this by selecting "add instance" and manually changing its Rect Transform, but I do hope I can find a way to directly use the prefab since I want to update my settings and layout across the scenes by updating the prefab.
I change the default canvas field's canvas scaler to 1080*1920 (since I'm making a mobile game) and I also change the screen match mode to "expand". Not sure if that's the reason?
I do have a vertical layout group and content size fitter for some of the elements like subtitle background and nametag background... If I directly drag my UI prefab under the dialogue manager's default canvas, then everything works perfectly fine.
I've found a temporary way to solve this by selecting "add instance" and manually changing its Rect Transform, but I do hope I can find a way to directly use the prefab since I want to update my settings and layout across the scenes by updating the prefab.
Re: UI Prefab lose its orignal Rect Transform values
In either case, I recommend making your Dialogue Manager into a prefab or prefab variant. Then you can use the same Dialogue Manager in all scenes. You can add an instance of your dialogue UI to this prefab if you can't figure out why the RectTransform values are changing when the dialogue UI prefab is instantiated at runtime.
Re: UI Prefab lose its orignal Rect Transform values
You could also try this patch containing an update that's in the upcoming version 2.2.28. It has some improvements to instantiating dialogue UI prefabs.
DS_UIPrefabPatch_2022-06-06.unitypackage
DS_UIPrefabPatch_2022-06-06.unitypackage
Re: UI Prefab lose its orignal Rect Transform values
That's a great suggestion! Thanks!