• 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 2dkot · Oct 03, 2011 at 07:42 PM · instantiateprefabs

Try to rename Instantinate object.

I want to get access to object, which was instantiated from prefab. Problem is that there are a lot of such objects with same name. So I decided, that it is better way to instantiate prefab by object with unique name. I try this way:

 var bigStone01:GameObject = stone.getBigStone01();
 var bigStone02:GameObject = stone.getBigStone02();
     
 cloneStone01.Instantiate(bigStone01, pos01, getSimpleTerrainRotY(pos01));
 cloneStone01.name = "1212121" + i;

In this case all "cloneStone01" do not appears in scene, if I remove line "cloneStone01.name = "1212121" + i;", "cloneStone01" appears again.

This is a link from my previous question which cause this situation.

[http://answers.unity3d.com/questions/172576/unknown-identifier-instantiate-weird-behavior.html][1] [1]: http://answers.unity3d.com/questions/172576/unknown-identifier-instantiate-weird-behavior.html

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
1
Best Answer

Answer by kevork · Oct 03, 2011 at 08:08 PM

Instantiate returns the GameObject created.

Try changing: cloneStone01.Instantiate(bigStone01, pos01, getSimpleTerrainRotY(pos01));

To: cloneStone01 = Instantiate(bigStone01, pos01, getSimpleTerrainRotY(pos01));

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 2dkot · Oct 04, 2011 at 07:46 AM 0
Share

I did it but unity3d return exception: Assets/gScripts/classes/Environment/gStoneGroups.js(37,24): BCE0005: $$anonymous$$ identifier: 'Instantiate'.

avatar image syclamoth · Oct 04, 2011 at 07:51 AM 1
Share

Try explicitly using Object.Instantiate- if your class does not derive from $$anonymous$$onobehaviour, Instantiate isn't a thing.

avatar image 2dkot · Oct 05, 2011 at 08:17 AM 0
Share

Cool, it works. Thanks

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.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

finding instantiated prefabs 2 Answers

Help needed with instantiate 0 Answers

Wrong coordinates of setting position of the object 1 Answer

Checking if object intersects? 1 Answer

Instantiating a prefab at runtime (without using Monobehaviour or Resources folder) 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