x


Turn off a script?

Hello. I know you can enable/disable a game object through something like this, how can I do that with a script (in another object)? Thanks

var CS : GameObject;

function Update (){ if (Genre==1) {CS.SetActiveRecursively(true);}; }

more ▼

asked Dec 27 '10 at 06:06 AM

Tyler 2 gravatar image

Tyler 2
1.1k 232 257 264

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

you should use CS.GetComponent("ScriptName").enabled = false;

more ▼

answered Dec 27 '10 at 08:13 AM

Kourosh gravatar image

Kourosh
1.5k 49 54 65

Thank you!! This was very helpful!!!

Jan 14 '11 at 03:50 AM Heather

is that java or C#?

Jun 04 '13 at 12:07 PM yu-gi-master
(comments are locked)
10|3000 characters needed characters left

CS.GetComponent("ScriptName").enabled = false;

Errors:

BCE0019: 'enabled' is not a member of 'UnityEngine.Component'.

more ▼

answered Apr 16 '13 at 10:28 AM

przem997 gravatar image

przem997
0

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4378
x457

asked: Dec 27 '10 at 06:06 AM

Seen: 5452 times

Last Updated: Jun 04 '13 at 12:07 PM