• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by KristianBalaj · Nov 03, 2015 at 08:52 PM · sizerecttransform

Getting size of stretched RectTransform ??

How to get size(width and heigth) of stretched rectTransform ?? please help !

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by KristianBalaj · Nov 04, 2015 at 05:30 PM

Ok, I found out the solution in my case it worked if you need it than try it in your project and give me feedback. This returned me the right size ... rectTransform.rect.width ... and rectTransform.rect.heigth ... It worked for me also at stretched RectTransform.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SangOk1994 · Jun 19, 2020 at 06:20 AM 0
Share

But it doesn't work when stretched multiple times. Unity Requires 1 frame time to calculate them

avatar image ltsc · Oct 07, 2020 at 07:38 AM 0
Share

this works but dont forget "yield return new WaitForEndOfFrame()" or it will give you right size after that.

avatar image
1

Answer by nanisahu1331 · Aug 17, 2018 at 03:22 PM

Thank you so much it works for me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by GiyomuGames · Nov 04, 2015 at 05:32 AM

Have you tried multiplying width by localscale.x and height by localscale.y?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AdmiralThrawn · Sep 10, 2017 at 06:07 PM 0
Share

localscale doesn't work. It will give anything between 0 and 1.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

RectTransform rounding? 0 Answers

How to get size of dynamically created layout element 0 Answers

Retreive the Width Delta of a ContentSizeFitter game object 0 Answers

Height Value of Rect Transform cannot be changed via script 1 Answer

Universal Method of finding pixel dimensions of UI elements 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges