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 Xeong-Hu · May 06, 2015 at 03:56 PM · all

C# How do i destroy all of my instantiated clones?

Hello everyone. I'm trying to destroy all of my clones with the for loops that were recommended by others questions, and Answers.

But I just can't seem to get it right, I believe most of them are in Java Script and I don't really know how it works for javascript and my entire scripts are C#. So it confuses me.

If anyone know how to do this with C# please let me know. I'm kind of confused.

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 IvovdMarel · May 06, 2015 at 04:20 PM 0
Share

Fappp's answer is incomplete. But so is your question.

Since you already have some code, post it! Do you already have an array of clones? Of what type are your clones?

And also, if you want to pursue a career in Unity3D, change to C# as soon as you can. Professionals work with C#.

avatar image Fappp · May 06, 2015 at 05:49 PM 0
Share

Thanks for clearing that up! I don't really believe C# is for professionals. C++ is. But most likely pro's who are capable of writing C++ are not bound to Unity.

Also I've never ran into anything that couldn't be done with Unity JavaScript :) It's different, yes... Better or worse, no...

avatar image Xeong-Hu · May 06, 2015 at 06:44 PM 0
Share

Well then, it's a good thing I'm currently using C# then Haha, I started out with C# ever since I watched that 2D Character tutorial video from Unity. Haven't stopped since.

But anyways sorry about the late reply everyone.

I got it working thanks to Galshal's answer.

Thanks for the help Fappp and Galshal, the Lists really did make it easier and I got it going smoothly now.

: )

avatar image IvovdMarel · May 06, 2015 at 09:20 PM 0
Share

@Fappp - I am a professional freelance developer and I worked on multiple successful mobile and Facebook games - built in Unity. The reason I say professional is because in the industry, when companies use Unity (and yes they do, trust me), they always use C#, never UnityScript. You can Google why, or just accept it for now and find out later why. C++ is a completely different language, and yes, also used in the industry environment.

I meant no offence, but again, if you're looking for a career as a Unity3D developer, learn how to use C#.

3 Replies

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

Answer by galshal · May 06, 2015 at 04:17 PM

first of all , are the instanitated GameObjects are in a dictionary or List because then running all of them and distroying them will be very easy, if not you should do that, i recomment a list.

second you should run that list in somthing like this:

(lets call the gameObjects list monstersList)

 foreach (GameObject monster in monstersList){
   GameObject.Destroy(monster);
 }


Comment
Add comment · 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
1

Answer by Dubtoker · Dec 09, 2016 at 06:18 AM

Just give them all a tag , then Destroy all game objects with tag....??? This should work I think, not tested!

Comment
Add comment · 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
0

Answer by Fappp · May 06, 2015 at 04:03 PM

I'm pretty much a JavaScript type myself, but this should be the correct looping in C#.

for ( GameObject i = 0; i < clones.Length; i++ ){ GameObject.Destroy(clones[i]); }

Comment
Add comment · 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

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

23 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

Related Questions

Destroy All Objects In The Scene??? 1 Answer

How to disable all input binds for typing 1 Answer

How can I check if ALL items in an array/list meet a condition? 2 Answers

How to make perlin noise generate terrain in all directions? 2 Answers

Application.LoadLevel("name") help! 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