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 SpeedTutor · Jul 09, 2013 at 09:21 PM · c#particlewont stop

Particle system stop?

Hello,

I'm just using one of the unity built in particle effects, the soap bubbles but can't get the particles to stop playing. I had this working in another project so I'm not sure if the more recent version of Unity has affected this.

I tried applying this script to the particle system:

 using UnityEngine;
 using System.Collections;
 
 public class Bubbles : MonoBehaviour 
 {
 
     void Start () 
     {
         particleSystem.Stop();
     }
 }

I Get the error:

NullReferenceException: Object reference not set to an instance of an object UnityEngine.ParticleSystem.Stop (Boolean withChildren) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:496) UnityEngine.ParticleSystem.Stop () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:488) Bubbles.Start () (at Assets/Bubbles.cs:9)

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by justinl · Jul 09, 2013 at 10:19 PM

Your script doesn't have reference to the particle system. Create add this public variable to the top of your script.

 public ParticleSystem particleSystem;

and then drag the particle system into that Bubbles script in the Inspector.

Comment
Add comment · Show 7 · 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 SpeedTutor · Jul 10, 2013 at 10:09 AM 0
Share

I tried exactly that, but it doesn't let me drag the particle system into the inspector slot. As if it doesn't recognise it, even when I search for it using the node at the side.

I presumed you meant "ParticleSystem" with an "e" at the end. I'm not sure what else to try.

 public ParticleSystem particleSystem;
avatar image justinl · Jul 10, 2013 at 04:56 PM 0
Share

I'm not sure of your particular setup but that's how it's supposed to work. I've done this many times before. Are there any errors in your console? Also, you cannot select the script in your Project window and then drag the particle system onto the script's slot in the inspector. You need to assign that Bubbles script to a GameObject first. THEN you can drag it onto that instance of the script which is on the GameObject

avatar image SpeedTutor · Jul 10, 2013 at 05:21 PM 0
Share

Thanks for the advice again, I know you can't drag a particle onto an asset directly in the project window, I was trying it on the $$anonymous$$ain Camera, Particle system itself and an empty game object with the particle parented. For some reason when I've tried again with:

 using UnityEngine;
 using System.Collections;
 
 public class Bubbles : $$anonymous$$onoBehaviour 
 {
     public ParticleSystem particleSystem;
     
     void Start () 
     {
         particleSystem.Stop();
     }
 }

I get a null reference again.

 NullReferenceException: Object reference not set to an instance of an object
 UnityEngine.ParticleSystem.Stop (Boolean withChildren) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:496)
 UnityEngine.ParticleSystem.Stop () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:488)
 Bubles.Start () (at Assets/Bubles.cs:10)

I also get this message when I save the code from $$anonymous$$onoDevelop.

 Assets/Bubles.cs(6,31): warning CS0108: `Bubles.particleSystem' hides inherited member `UnityEngine.Component.particleSystem'. Use the new keyword if hiding was intended
avatar image justinl · Jul 10, 2013 at 06:34 PM 0
Share

So you have a $$anonymous$$ainCamera in your scene. That $$anonymous$$ainCamera has the Bubbles.cs script attached to it. Then you have a particle system in the scene, and you drag that particle system onto the bubbles.cs instance on the $$anonymous$$ainCamera? Is that about right? (Also I notice that your errors reference "Bubles" but the class you've copy/pasted is "Bubbles" with 2 "b"'s. Not sure if that's a typo...

avatar image SpeedTutor · Jul 10, 2013 at 11:48 PM 0
Share

That is correct, yes. "Bubles" was just my input error when I was replying. I was going to mention that but I forgot! :(

Show more comments
avatar image
0

Answer by SpeedTutor · Jul 10, 2013 at 05:58 PM

Thanks for the advice again, I know you can't drag a particle onto an asset directly in the project window, I was trying it on the Main Camera, Particle system itself and an empty game object with the particle parented. For some reason when I've tried again with:

 using UnityEngine;
 using System.Collections;
 
 public class Bubbles : MonoBehaviour 
 {
     public ParticleSystem particleSystem;
     
     void Start () 
     {
         particleSystem.Stop();
     }
 }

I get a null reference again.

 NullReferenceException: Object reference not set to an instance of an object
 UnityEngine.ParticleSystem.Stop (Boolean withChildren) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:496)
 UnityEngine.ParticleSystem.Stop () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:488)
 Bubles.Start () (at Assets/Bubles.cs:10)

I also get this message when I save the code from MonoDevelop.

 Assets/Bubles.cs(6,31): warning CS0108: `Bubles.particleSystem' hides inherited member `UnityEngine.Component.particleSystem'. Use the new keyword if hiding was intended
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 Palta · May 27, 2015 at 09:54 AM

GetComponent().Stop(); GetComponent().Play();

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

17 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Can you still not change the Velocity of spawned particles? 2 Answers

Flip over an object (smooth transition) 3 Answers

Change particle velocity when gameobject rotates 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