Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by MaxLvl99 · Jan 24, 2017 at 05:20 AM · sizedynamicprefab changing at runtime

Instantied GameObject Prefab doesn't have a height

I'm making a dynamic menu, and I use the instantiate method to load in the prefab, which is a parameter into the script from the Unity scene. I need the height of the instantiated pre-fab so I can use it to position the pre-fab correctly. The pre-fab is already showing up on the screen, so that's not an issue. However, the size of my instantiated prefab is always zero for some reason. Here is the code:

GameObject element = (GameObject)Instantiate(prefabSliderPanel); element.transform.SetParent(modifyTextureScrollPanel.transform,false);

Below is what I am printing to the console: element.GetComponent().rect.size: (508.0, 0.0) element.GetComponent().sizeDelta: (508.0, 0.0) bounds.size: (0.0, 0.0, 0.0) element.GetComponent().rect.height: 0

As you can see, there appears to be a width to the prefab, but not a height. I believe there should be a height since I can see the prefab on the screen, but its not at the right height (of course). I have also tried using a method I found on Stack Overflow which uses the MeshFilter of the object to calculate the bounds, but that also did not work. I was wondering if anyone knew why this may be occuring?

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

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can I dynamically changed where buttons are placed? 2 Answers

Rigidbody and collider controlled by 2 gameObjects 1 Answer

GridLayout dynamic cell size based on object count 0 Answers

Dynamic UI Size? 1 Answer

GuiText for Unity 4 dynamic scaling issue mobile 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges