I'm customizing the game UI but I get this error, twice for now in the console.
"Cannot find which Transform to reposition with the AutoCorrectUIDimensions component - either assign the Transform To Control field, or link the Canvas to a Menu with a RectTransform boundary."
Any method to figure out which of the many menus I have has this issue? I've checked that the "Linked Canvas.." and "RectTransform..." options are set but maybe I've missed two of them? I think I've got all of them.
Another possibility is that it may be related to an issue I've got when duplicating existing AC UIs prefabs. The ConstantID remained the same as the original, as far as I know. On some UIs I've removed this component and add it back which triggered a new ID to be created. I may have missed some of these components maybe? But how to know which one? If the error is related to this anyway.
Thank You.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can click this message in the Console to "ping" the affected object in the Hierarchy.
It's coming from an Auto Correct UI Dimensions component that has no Transform to control field assigned. If the component is attached to a Menu's Canvas root, it will attempt to rely on its RectTransform boundary if this is left blank.
Thank You, great trick I've missed
Now this got rid of the error, but there is something really strange at play because I've triple checked that the Menu variables were set before creating the thread. Opening the project again today and the RectTransform was missing. Go figure. But I did got the errors when the variable was set. (in the AC menu) Must be the usual unity error.
**
But I have a different problem, related. **
So what this "Auto Correct Ui dimensions" script does because it keeps screwing the position of the UI elements, it moves the UI outside the game camera. I'm placing all the elements in the center of the screen, then it doubles the size of something and they get spread out outside the game area. Can you share some information on the exact settings that this scripts expects from the unity UI so that the UI remains as i need it?
I'm attaching 3 images. One shows the InventoryUI which I've duplicated but didn't touched (except the previous issue with the ConstandID). Unity created that grey "Canvas" top object that is not present in the original Inventory Ui prefab then it moved the elements as shown in the image. This is a screen from out of play. In the third image you can see the InventoryUI is correctly placed at the top. (I've verified it is this duplicated InventoryUI prefab used in the AC Menu options, not the original)
The second image show a customized UI prefab based on the InventoryUI. The image shows the out of play positioning. Also there is no grey "Canvas" top object as in the previous one. When going in play this Ui gets crazy as seen in the third image outside the game view area.
the third images shows that the Inventory is placed at the top while the second menu is spread out side the area and moved up to the center
The component will also have no effect while in Edit mode. If you're getting red "X" boxes in your prefab's preview window (suggesting a RectTransform has a negative scale), then that'll be an issue with the RectTransform default values.
The "Canvas (Environment)" object in the Hierarchy will be present if the prefab's root has no Canvas component on it.
The Auto Correct UI Dimensions component adjusts its Menu to adhere to your game's enforced aspect ratio, which - if set - may differ from your game window's actual ratio.
For example, if your game window is 4:3, but you're enforcing a 1:1 ratio (such that you're getting pillarbox borders on the side), then the component will adjust the UI (by resizing the RectTransform boundary) to account for the simulated 1:1 ratio.
Are you enforcing such a ratio? You likely don't need the component if not.
If you are enforcing a ratio, and want the UI to be aligned along the bottom edge, then you'll need to set the component's Min/max anchor point values to (0,0) and (1,0) (referring to the lower-left and lower-right corners) respectively.
You'll also need to have these same anchor values on the RectTransform boundary itself (i.e. the Panel object), as well as set its Y-pivot value to 0.
The default Inventory UI has similar values, except for Y being 1 to denote the top-edge.
unfortunately this is confusing. I have no idea about this ratio enforcing.
I just want a 1920x1080 game for computers
but why the same thing works fine when using the originals UIs prefabs that come with AC but when duplicated them, first they work then they go crazy like this. Everything worked at first.
Do you think unity knows those prefabs were created with previous versions and the editor doesn't touch it and behave differently, like in compatibility mode behind scenes, then once they are duplicated they are treated as "new" prefabs and this compatibility doesn't work anymore?
I will try to create a new prefab from zero instead.
So this Auto Correct UI Dimensions is not required actually?
It's necessary if you're enforcing an aspect ratio in the Settings Manager - is this the case?
I can't be too specific about what the exact issue is without seeing the properties of the UI components. If you'd like to PM me your UI prefab, along with details of your AC/Unity versions, I can take a look at it on my end.
So I've checked, I didn't knew about this option, here is how it is
But please put this on hold for now, I don't want to make you lose time. I'm suspecting that duplicating those UIs, then replacing them in the AC menus may have triggered something with unity. probably is a better idea to just create the menus new from scratch. I will post here the results.
The version of AC is 1.81.4 and unity 2022.3.37f1
I think I've got this under control for now, maybe.
Duplicating the AC menus, for example InventoryUI will not change the ConstantIDs for the elements inside the prefab. They will remain the same as the original InventoryUI prefab. This apparently has no visible impact, it works, but I suspect things go slowly out to crazy world and the menus will at some point become screw up, like creating that Canvas top object I was showing in a previous image out of the blue.
What I did for now was to, duplicate an AC menu, add this prefab to a scene, unpack the prefab completely, remove all the ConstantIDs scripts from the all UI objects. Add them back and checking the option "Retain in prefab". Delete the duplicated UI prefab from the Project, drag the one from the Scene and create a new prefab. Drag this one to the AC menu and after opening the prefab drag all the elements to the correct slot. (The slots in the AC menus even if empty they were showing the IDs from the original AC prefab) When dragging the new objects the IDs updated.
i will see in the next days if the menus will remain functional or not.
Thank You for your help as always
@dgames , I was getting the same warning as you and your suggestion to unpack and remove the ConstantIDs from the UI prefab worked. I also think it started when I copied the UI prefabs from another project.
The version of AC I am using is 1.83.0 with Unity 2022.3.59f1