Hello ! Before explain my problem here’s the use-case :
- I have a RectTransform, with a graphic component attached (Image or Raw Image)
- I modify the “Width” field in the rect transform
- This modification triggers an editor script (from OnInspectorGUI) that automaticly change X and Y position of the Rect Transform (like in a Layout).
- The RectTransform values correctly change, I can see the white rect in the scene view moving. The gizmos pivot point is also moving. NICE
- The image have its width modified BUT its position doesn’t change. NOT NICE
Here an exemple :
On the left : Original width at “2”. I set “20”, on the right you can see the white shape and the gizmo ok, but the image doesn’t follow;
Note : If I click on another object, or save the scene, or minimiaz-maximize Unity, or even uncheck/check any component in the scene, the image moves to its right location.
I’ve tried everything : Canvas.ForceUpdateCanvases, RectTransform.ForceUpdate(), Image.SetAllDirty(), Image.UpdateCanvas(), SceneView.RepaintAll(), HandleUtility.Repaint(), and noooothing works.
The only solution i’ve found from now, is moving the z position by epsilon and set it to its correct position the next frame. It’s working but you can still see a short frame where the image is not at its correct location. It’s ugly. The code is also ugly.
Does anyone have an idea how to update or force the graphic component to redraw on the same frame the modifications occurs ? Thanks !
