Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug How to override canvas rect transform scale value

Discussion in 'UGUI & TextMesh Pro' started by diwang, May 15, 2020.

  1. diwang

    diwang

    Joined:
    Sep 14, 2015
    Posts:
    30
    So i wanted to create a custom canvas scaler , but canvas rect transform value is driven by canvas , so it makes sense if the scale value is driven by canvas IF there is canvas scaler , so i deleted canvas scaler , to my surprise scale value in canvas rect transform is still driven by canvas even though the canvas no longer control scale value in any mean . So how do i override this setting and change the scale value in rect transform while keeping canvas component ?
     
  2. BIOoOAG

    BIOoOAG

    Joined:
    May 14, 2020
    Posts:
    6
    Could you use panel?
     
  3. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,057
    can you please describe what you want to achieve?
     
  4. diwang

    diwang

    Joined:
    Sep 14, 2015
    Posts:
    30
    I already described it , i want to create my own canvas scaler script , but i can't do it because canvas rect transform data is being driven by canvas
     
    Novack likes this.
  5. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,057
    Obviously you didn't dive very deep yet and didn't start to write your own canvas scaler.
    if you would have done research, you probably would have already checked out the source code of the default CanvasScaler you would have noticed that this script simply sets the
    scaleFactor
    and
    referencePixelsPerUniy
    of the
    Canvas
    . So, if you remove the canvas scaler, the previous values remain in the Canvas.
     
  6. diwang

    diwang

    Joined:
    Sep 14, 2015
    Posts:
    30
    Oh so it mean my script will still work despite unity saying in the editor that "some value is driven by canvas" ?? thank you !!!