Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Set RectTransform Right, Left, Top and Bottom value via script

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 6.29k
    Comment on it

    One can easily change RectTransform right,left,top and bottom value using script in this way :-

    object.GetComponent<RectTransform> ().offsetMin = new Vector2 (0,-1);//left-bottom

    here "0" indicates Left value and "-1" indicates bottom value.

    Similarly for setting Right and Top value use:

    object.GetComponent<RectTransform> ().offsetMax = new Vector2 (0,1);//right-top

    here "0" indicating Right value and "1" indicating Top value.

     

    In my case value is 0 or 1. But it can be any value rather than 0 or 1.

    e.g:-

    object.GetComponent<RectTransform> ().offsetMin = new Vector2 (10,12);//left-bottom
    object.GetComponent<RectTransform> ().offsetMax = new Vector2 (20,40);//right-top

     

    For more understanding :-

    • rectTransform.offsetMin.x        // Left
    • rectTransform.offsetMin.y       // Bottom
    • rectTransform.OffsetMax.x    // Right
    • rectTransform.offestMax.y    // Top

     

    Hopefully this will be helpful for you.

    Thanks!

    Set RectTransform Right, Left, Top and Bottom value via script

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: