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 gamerguy · Oct 17, 2013 at 05:20 AM · instantiaterunning

I wrote this code to create 7 prefabs and rename the clones thus formed.This Code isnt working as anticipated.

Script doesnt rename the instantiated prefab.Rather, what i get is one clone and that not renamed. Why is it so?How do I correct it? I even tried on forums, but none of offered solutions worked. Posted: 03:47 AM 1 Hour Ago

 using UnityEngine;
 using System.Collections;
 
 public class CreateNew : MonoBehaviour {
 
 public Object PathFloorUnit;
 // Use this for initialization
 void Start () {
 for(int x=0;x<=6;x=+1){
 Object pathRef;
 pathRef=Instantiate(PathFloorUnit,new Vector3(0,0,10*x),Quaternion.identity);
 pathRef.name="newName";
 }
 }
 // Update is called once per frame
 void Update () {
 
 }
 }

I wrote it to rename an instantiated prefab but this is not working.Why?And how can i correct it?

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 DaveA · Oct 17, 2013 at 05:22 AM 0
Share
  1. Don't write very long subject lines. $$anonymous$$eep it short and put details in the question body.

  2. Format your code

  3. Don't repost the same question

avatar image deltamish · Oct 17, 2013 at 05:49 AM 0
Share

hi select the code and select 101010 in the edit question so that we can understand the code

avatar image deltamish · Oct 17, 2013 at 05:50 AM 0
Share

and by notwroking what do you mean

avatar image gamerguy · Oct 17, 2013 at 06:29 AM 0
Share

understood.I have made the code a bit more legible.this mistake will not be repeated.

2 Replies

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

Answer by wilgieseler · Oct 17, 2013 at 05:36 AM

Use x++ instead of x=+1.

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 Loius · Oct 17, 2013 at 05:52 AM 1
Share

x++ increments x by one. x=+1 sets x to positive one. x+=1 adds 1 to x.

avatar image gamerguy · Oct 17, 2013 at 06:32 AM 0
Share

I want to add that I understood this mistake after I asked the question in forums.But it still didnt work because I hadnt reset the script (from inspector) after modifying and saving it in asset folder

avatar image
0

Answer by gamerguy · Oct 17, 2013 at 05:50 AM

Yes that worked.Thanks.I want to add that the code in asset folder didnt change until i reset it.I think we have to reset the code after making changed in editor and saving.

Comment
Add comment · Show 1 · 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 wilgieseler · Oct 17, 2013 at 05:54 AM 0
Share

If you can, mark the correct answer as correct so other people can see that it worked rather than adding a new answer.

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

18 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

Related Questions

code intended to instantiate 7 PathFloorUnit Prefabs,creates only one clone. 1 Answer

Instantiated prefab name change 3 Answers

Checking if object intersects? 1 Answer

Associate objects to a prefab 1 Answer

Editor Script to place prefabs with some variance 0 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