Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Oct 29, 2014 at 01:46 AM by robertbu for the following reason:

Duplicate Question

avatar image
0
Question by MajorParts · Oct 29, 2014 at 01:45 AM · c#guitextgui-text

Updating GUI text

Hi I recently started a project that was single player. My player had a GUI text stating the engine %. This was done by having a GUI text gameobject in the hierarchy that was dragged to a public var box in the player controls script.

BUT....I then converted to multiplayer and this involved making my player a prefab as opposed to something already in the scene hierarchy.

Even though the text object is still dragged to the var box, the text no longer updates. Well, it does, but not on the screen! If I go to say 50% engine and stop the game, next time I start it, the engine will be at 50% even though I'm stationary!

So, why has making the player a prefab broken this? and how would I fix it? I've tried making the GUItext object a prefab too, but that doesn't work (and if I remember correctly, couldn't even drag it to the var box)

Cheers

Comment
Add comment · Show 5
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 robertbu · Oct 29, 2014 at 01:49 AM 0
Share

Your question is not clear enough to indicate the exact solution, but your issue is a common one. Prefabs can be considered as blueprints for an object. They don't exist in a scene until they are Instantiated(). You cannot drag and drop from/to a scene object and a prefab to create links. Note you can create links through drag and drop within a prefab.

The solution will depend on which way you want to establish the links. If a prefab needs the link, then you would use GameObject.Find() or GameObject.FindWithTag(), possibly with GetComponent() to establish the link. Going the other way, the Instantiate() can save the reference and assign it to a variable.

http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

http://unitygems.com/script-interaction1/

http://unitygems.com/script-interaction-tutorial-getcomponent-unityscript/

avatar image MajorParts · Oct 30, 2014 at 11:08 PM 0
Share

Still confused after searching "duplicate" questions & google. Was it really necessary to close this? I could have been clearer on the question had somebody asked for anything inparticular to show them to aid an answer.

avatar image robertbu · Oct 30, 2014 at 11:50 PM 0
Share

Actually what should of happened is that this question should be rejected in the moderation queue with a request to 1) review some links on accessing other game objects, 2) restate your question, and 3) add your scripts to the question. Unfortunately the 'Send $$anonymous$$essage' feature of the moderation queue is broken. So my choice is either to just reject your question and have it disappear without you knowing why or to publish and close the question. Note that solving the accessing of variables on one game object from another is a very frequent question (many times most days). $$anonymous$$ost of those just disappear in moderation.

If after reading the materials and experimenting with the examples you are still stuck, resubmit your question with greater context and your scripts.

avatar image MajorParts · Oct 30, 2014 at 11:56 PM 0
Share

fair enough. Those 2 unitygems links don't work btw

avatar image robertbu · Oct 31, 2014 at 12:05 AM 0
Share

UnityGems appears to be down. I saw that a day or two ago. I hope it is not permanent since there is a lot of really good information on the site.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

GUI text blinking opacity 1 Answer

GUI Problem 2 Answers

Text Effects... 2 Answers

Multiple Cars not working 1 Answer

My text field is not taking any input 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