Search Unity

Question Window resize inconsistency, with delay before updating

Discussion in 'UGUI & TextMesh Pro' started by CuddlesWithEmus, Mar 4, 2022.

  1. CuddlesWithEmus

    CuddlesWithEmus

    Joined:
    Jul 31, 2021
    Posts:
    2
    I haven't tested how this works in an actual build or anything yet, but I'm running into an inconsistency with my UI and I can't figure out much about this after searching on google and all that. I just want it to be consistent.

    I have a canvas. On my canvas, I have a couple of buttons with images, and some other standalone images.

    When I resize my window, these buttons/images don't resize right away-- they wait until I release my mouse.

    However, I have my own element that I'm creating, and that element does resize as I drag my mouse (it uses LineRenderer to draw lines in front of the UI).

    Again, I just want consistency... I don't care if I have to delay my line renderer thing, but I don't know how I would go about that. I tried looking at the metadata for the classes that images inherit from, but I couldn't understand how they worked at all. The only idea I had was to use one particular check I saw in there, like this:

    Code (CSharp):
    1. protected override void OnRectTransformDimensionsChange(){
    2.     base.OnRectTransformDimensionsChange();
    3.     SetScaleValues();
    4.     if(!CanvasUpdateRegistry.IsRebuildingLayout())
    5.         Redraw();
    6. }
    That didn't really seem to do anything though. Oddly enough, when I had a debug log in there earlier, everything in the log was delayed until I released my mouse on the drag. I got something like 40 logs in one instant after a short drag (and more at once with longer dragging). I don't really understand this...

    Anyway, the other way to do it would be to allow the rest of the canvas to update sizes and stuff during my mouse dragging (my UI is not that complicated, I feel like it'd probably be OK)... but I don't think there's an option for that.

    So to summarize, I would like to either delay my own element's graphical update until the rest of the UI is going to update, or force the rest of the UI to update as I drag my mouse. It also might help if I understood the events a little better.
     
  2. CuddlesWithEmus

    CuddlesWithEmus

    Joined:
    Jul 31, 2021
    Posts:
    2
    Oh, another solution might be if LineRenderer isn't the best way to draw lines on the canvas. That could definitely help.