• 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 Skuzzbag · Jun 27, 2011 at 03:53 PM · gameobjectactive

gameObject.active still draws object

How can I stop them getting drawn? I've created a number of particle objects and setting active to false has stopped them updating but they still get drawn on the screen.

Comment
Add comment · Show 2
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 rocket5tim · Jun 27, 2011 at 04:17 PM 0
Share
avatar image Chris D · Jun 27, 2011 at 05:20 PM 0
Share

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DavidDebnar · Jun 27, 2011 at 04:41 PM

If its a particle effect, everyt$$anonymous$$ng you need to do is somet$$anonymous$$ng like t$$anonymous$$s:

function Update () { gameObject.particleEmitter.emit = false; }

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 Skuzzbag · Jun 27, 2011 at 05:02 PM

It's not a Unity particle emitter (I'm hoping I'm not confusing the issue by naming it so) as I wanted to use some primitive shapes for the particles.

The codes a bit long text wise because of my long variable names!

There are 3 instantiate lines in the loop as I'm creating and storing the reference to 3 different particle objects.

The objects are drawing at the default location 0,0,0 even though they are active = false

function Start () { s$$anonymous$$pControlScript = playerS$$anonymous$$p.GetComponent("S$$anonymous$$pControl_script"); // reference to s$$anonymous$$p control script

 explosionEventScript = explosionEvent.GetComponent("ExplosionEvent_script");
 
 particleArray = new GameObject[s$$anonymous$$pControlScript.maxMissiles * explosionEventScript.numberOfParticles];

 print("Array size = " + s$$anonymous$$pControlScript.maxMissiles * explosionEventScript.numberOfParticles);
 
 // Setup the array with the pre-cooked prefabs - they are deactivated.
 // The 3 in the following line is the amount of lines below. So if another particle type is added to t$$anonymous$$s list
 // the a += 3 should be changed to 4.
 for (var a = 0; a != s$$anonymous$$pControlScript.maxMissiles * explosionEventScript.numberOfParticles; a += 3) {
     particleArray[a] = Instantiate(explosionEventScript.explodePart01, Vector3(0,0,0),  Quaternion.identity);
     particleArray[a].active = false;
     particleArray[a+1] = Instantiate(explosionEventScript.explodePart02, Vector3(0,0,0), Quaternion.identity);
     particleArray[a+1].active = false;
     particleArray[a+2] = Instantiate(explosionEventScript.explodePart03, Vector3(0,0,0),  Quaternion.identity);
     particleArray[a+2].active = false;
 }
 print("Particle array loaded OK");

}`enter code here

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 Skuzzbag · Jun 27, 2011 at 05:17 PM

Ok I t$$anonymous$$nk I've found out what's happened but I don't know how to fix it.

I tried disabling the renderer and it still drew! So I checked the inspector and there is a mesh renderer in the prefab at the top level and a mesh renderer that is attached to the actual mesh and t$$anonymous$$s isn't disabled.

I would have thought that anyt$$anonymous$$ng done to the prefab at the top level would trickle down to meshes underneith it?

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 qwertyp · Jun 27, 2011 at 05:25 PM 0
Share

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use if statement properly 1 Answer

Does inactive Objects eat up Performance? 1 Answer

The best overload for the method 'UnityEngine.GameObject.SetActive(boolean)' is not compatible with the argument list '()'. 1 Answer

Set child gameobject active? 1 Answer

How do I change a gameobject to be active through a script? 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