Hi all,
Can someone show me how to temporarily disable a component
on an object via another object?
Ie, I press object 1 to stop component script
on object 2. When I stop touching object 1, the script continues…
Thanks,
Greg
Hi all,
Can someone show me how to temporarily disable a component
on an object via another object?
Ie, I press object 1 to stop component script
on object 2. When I stop touching object 1, the script continues…
Thanks,
Greg
Step 1: get a reference to the desired game object, either store a reference via a public variable or use something like GameObject.Find.
Step 2: get a reference to the component attached to that game object using GetComponent.
Step 3: enable/disable that component by setting its enabled property.
GameObject.Find("Foo").GetComponent("Blah").enabled = false
Thanks, Higgy,
I’m getting an error: ‘enabled’ is not a member of ‘UnityEngine.Component’. I forgot to mention that this was for iphone unity. Sorry, I mistakenly placed this under scripts, when it should have been entered under iphone dev.
Hi,
I’m still trying to figure out why the above is giving me: ‘enabled’ is not a member of ‘UnityEngine.Component’
When you get a chance, I’d appreciate some help.
Thanks,
Greg
(GameObject.Find(“Foo”).GetComponent(“Blah”) as Behaviour).enabled = false
Thanks, Chris!