Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How do you resize texture displayed on inspector (GUILayout)?

Discussion in 'Immediate Mode GUI (IMGUI)' started by hyperkvlt, Jul 30, 2023.

  1. hyperkvlt

    hyperkvlt

    Joined:
    Aug 16, 2020
    Posts:
    37
    Hi. I tried to figure out how to resize texture when it displayed on inspector. The method I found could only set the max size of the texture displayed but I cannot figure out how to set the minimum size for texture displayed on inspector.

    For bigger texture they will be displayed smaller to fit the layout group. While for smaller texture they remained the same size. Is there a way to display the smaller texture bigger?


    Here's my script:

    Code (CSharp):
    1. GUILayout.BeginVertical(GUILayout.Width(50), GUILayout.Height(50));
    2. GUILayout.Box(texture, GUILayout.Width(50), GUILayout.Height(50), GUILayout.MinWidth(50), GUILayout.MinHeight(50));
     
  2. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    759
  3. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    759
    Another option you could try would be to create a new GUIStyle from the Box Style and enabled StretchWidth and StretchHeight. That might work.