- Home /
Unity get component help
Ok I don't know how to put the problem in the title, but here is the problem. I have a main camera and it has two sunshaft scripts, and they have different colors, how would I disable to one which is at the bottom? Without disabling the top one!? Please help I use javascript!
Ok so I'll edit it here; First off, thank you for the nice people who downvoted, you're too kind, no really, too kind. Anyway I have a sunshaft script, and I have another sunshaft script, I tried to separate them by doing
var SunBloom : Component;
it wasn't the best idea. Now I can enable one, but it also enables the other one, which is basically a conflict between them on who can actually be enabled, so I have no idea on how to use get components, and I need help. I get an error and that's all I know.
I only want to disable one script not both, but one. And I want to enable one script, not both, but one!
Top/bottom makes no sense without more of an explanation and/or relevant code
You can use GetComponent*s* ins$$anonymous$$d of GetComponent and switch between them.
Example usage: https://docs.unity3d.com/Documentation/ScriptReference/Component.GetComponents.html
Yes, but it doesn't show anything near an example for me to use as a template.
Something like this?
var blooms : Script[];
blooms = GetComponents (Scripts);
blooms[0].setActive( true);
blooms[1].setActive( false);
Thanks! I already figured it out eventually, the answers you need on this site are really slow!
Answer by unimechanic · Feb 21, 2014 at 11:36 PM
Question solved according to comments, but no specific solution was given. [Adding this answer to remove it from the Unanswered list.]
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to replace a gameobject referenced in JS using C# 2 Answers
What variables can i declare? 1 Answer
Destroy GameObject A or B 1 Answer
What is wrong with my script? 1 Answer