• 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 Feb 19, 2019 at 02:54 PM by mustang4484 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by mustang4484 · Feb 19, 2019 at 11:06 AM · prefab-instance

Prefab instantiate the second time and script are missing

Hi guys I've a instantiate prefab with a car, and i have a game manager always in scene. When i instantiate the first prefab, game manager found by name the prefab script, but when destroy prefab and instantiate a new prefab clone, the script are missing and it's impossible to found by name or tag.

Any solution?

Thank you

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 zereda-games · Feb 19, 2019 at 11:15 AM 0
Share

is the prefab fine or is it missing scripts?

avatar image mustang4484 · Feb 19, 2019 at 11:21 AM 0
Share

prefab is instatiate fine, but on the game manager the script is missing, after destroy. I will try to found it after instantiate the second time but doens't work.

  public void testme()
     {
        Supercars =  Instantiate (car, new Vector3(-40, -14, -17), Quaternion.Euler(0, 90, 0));
         Supercars.name = "Car03";
         WC = GameObject.FindGameObjectWithTag("Respawn").GetComponent<VehicleBehaviour.WheelVehicle>();
         car = GameObject.FindGameObjectWithTag("Respawn");
 
         F$$anonymous$$.inizia();
 
     }
Show more comments
avatar image zereda-games · Feb 19, 2019 at 11:29 AM 0
Share

are you linking the prefab in folder to the manager prefab in folder and not in scene?

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by zereda-games · Feb 19, 2019 at 11:39 AM

And your loading a prefab from File? No, no, you need to link the prefabs in file together, so it cannot be lost. if not linked that way the One instance in scene gets destroied and if the object in scene goes there is no actual reference to it anymore.. Then the manager must be an instance of the prefab in file. I learned this making Editors and Editor Windows. If not done this way the EditorWindow throws a continuous null reff error once the reff is missing..Good way to test if your doing things correctly

Comment
Add comment · Show 3 · 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 mustang4484 · Feb 19, 2019 at 11:30 AM 0
Share

no the link is between car prefab(in scene) and game manager (in scene).

avatar image zereda-games · Feb 19, 2019 at 07:58 PM 0
Share

Well, i guess this was the answer.... they closed it.

avatar image zereda-games · Feb 21, 2019 at 12:49 AM 0
Share

also i noticed that if you should have a prefab for any game object that has a script, so when you make a main parent prefab all the scripts are linked to the prefabs on the main prefab. if that makes any sense. i'll try and make a screen shot or 2

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

100 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

Related Questions

Destroy Cloned Object on Collision 1 Answer

Instantiating a new clone of a prefab whilst setting the previous clone as inactive 0 Answers

Spawned prefabs not keeping their Look At funtion 2 Answers

Script stopped working, prefabs behaving strangely 0 Answers

How to instantiate a prefab declared in one script, from another script 2 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