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 /
avatar image
0
Question by papirnehezek · Jul 18, 2014 at 09:12 PM · instantiateprefabreferenceconnection

Prefab connection problem

Hello,

I started using Unity a few weeks ago, and until now I barely had problems with it. I started to arrange my objects into prefabs, so I can place them whenever I want. Then I encountered the following: I have prefabs of everything including gameHandler (controls most of the game), mainCharacter, mainCamera, a torch, a spike, different types of walls, ground, etc. Some of them have attached scripts, like mainCamera. In the mainCamera script there is a reference to the player character, with the prefab from the asset files connected to it:

 public GameObject playerCharacter;

With this method I can connect every prefab which needs a reference without moving it to the scene, but when I move them to the scene via the editor, it seems like it creates another object, which means I need to change the reference to that particular object. For the prefabs which does not exist on the scene I cannot connect onscene objects, only prefabs (assets). Thats the case with spike, which has a reference to gameHandler. Spike does not exist on the scene on start, only instantiated later, so I can only connect the prefab gameHandler to it, but that is not the same as the onscene version.

Thanks for any 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by yagizpoyraz · Jul 18, 2014 at 09:31 PM

You can connect your objects via script. On Awake method , you can get the gameobject on scene by using unitys tag system. (Find object by tag) once you get the object you can store in on a variable.

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 yagizpoyraz · Jul 19, 2014 at 07:56 AM 0
Share

Did it worked @papirnehezek

avatar image papirnehezek · Jul 19, 2014 at 05:14 PM 0
Share

Yes, thank you! I hoped that there is a simpler solution, but after all it solved my problem.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Instantiate: Create Connection 1 Answer

Brain freeze: declaring a prefab inside the same prefab 1 Answer

gameObject are not referenced 2 Answers

Reference without Transform 1 Answer

Instantiating a prefab that needs a public reference to another prefab 3 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