Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by TitanSquash · Mar 12, 2016 at 05:53 PM · particlesystemparticle system

Turn on and off ParticleSystem and LineRenderer on same object at the same time

I have an object that has a LineRenderer and a ParticleSystem on it and its a child of another object. I am trying to turn the renderer off for both so they are not visible till they are turned on. Here is what I'm using: private Renderer objectParticles; void Start () { objectParticles = gameObject.transform.Find("spawnCast").GetComponent(); objectParticles.enable = false; }

The problem with this is it seems to only turns off the LineRenderer on the child object and not the ParticleSystem Renderer too.

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 Fredex8 · Mar 12, 2016 at 06:37 PM

Without seeing how the gameObject is set up in Unity it is hard to know what you are actually doing there since you are finding a child by name and then using GetComponent without a type specified. This is probably a better solution:

 private Transform childObject;
 private ParticleSystem objectParticles;
 private LineRenderer objectLineRenderer;
 
 void Start()
 {
 childObject = gameObject.transform.Find("spawnCast");
 objectParticles = childObject.GetComponent<ParticleSystem>();
 objectLineRenderer = childObject.GetComponent<LineRenderer>();
 
 objectParticles.enable = false; 
 objectLineRenderer.enable = false; 
 }

Without seeing what 'Spawn Cast' is I don't know how you have set it up but that should work. You might want to assign the child object via a different method though as find is pretty slow. Also you could use objectParticles.Play(); and .Stop(); instead of enabling and disabling it which may work better for you in the long run.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

RayCast on particle system 0 Answers

ParticleSystem particles do not disappear when ParticleSystem is run for a long time 0 Answers

Particles Colliding Inside Cube 0 Answers

Some question about ParticleSystem.emit() rendering 0 Answers

Legacy Particle system into new one 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