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 xBPM · Oct 27, 2017 at 01:50 PM · uiinstantiatebeginner

Instantiating UI?

Hey there, I am looking to do something like this below; with UI, how would I go about this? I currently have a canvas that will display the name of a gameobject, its just trying to replicate it, I understand I might need to instantiate the canvas, but unsure how approach it. I don't want to do it manually for every object haha.

alt text

This is what I was trying; would I be on the right path?

 for (var i = 0; i < part.Length; i++)
             {
                 Vector3 newPos = part[i].transform.position;
 
                 //positioning the UI above the object
                 newPos.y = part[i].transform.position.y + 7f;
                 newPos.z = part[i].transform.position.z + 2f;
                 newPos.x = part[i].transform.position.x;
 
                 newPos = part[i].transform.position + newPos;
 
                 if (part[i].tag == parentTag)
                     continue;
 
                     Instantiate(canvas, newPos ,transform.rotation);

EDIT: I know have the instantiating working pretty much, but they are coming up blank, how would I get all the text to appear.

Comment
Add comment · Show 4
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 Hellium · Oct 27, 2017 at 01:50 PM 0
Share

Have you done any research ?

  1. http://answers.unity3d.com/questions/608955/gui-follow-gameobject.html

    1. http://answers.unity3d.com/questions/826408/46-gui-anchoring-a-ui-element-to-a-game-object.html

  2. https://www.youtube.com/watch?v=0bvDmqq$$anonymous$$XcA

avatar image xBPM Hellium · Oct 27, 2017 at 02:09 PM 0
Share

I have tried looking for a solution, yes, but those links didn't exactly appear when looking around. Anyhow on what you have suggested, by the looks of what they are saying doesn't really help me, as I think I have already them stages done, again I think, maybe I am not reading it right, its more the instantiating I am having bother with. Thanks anyways.

avatar image Hellium xBPM · Oct 27, 2017 at 02:17 PM 0
Share

You should not instantiate a canvas for each element. You should :

  1. instantiate a RectTransform

  2. Parent it to a canvas

  3. Set position of it using the links I gave you.

Show more comments

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

139 People are following this question.

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

Related Questions

Instantiated UI prefab in canvas does not render image 1 Answer

How to set a variable on a drag and drop UI element. 0 Answers

How can I instantiate something as a child 2 Answers

How do I destroy the object that was instatiated 1 Answer

An Instantiated UI Button doesn't work; clicking does nothing. 1 Answer


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