x


turn on/off two same named component on an object with j script

i added two "ColorCorrectionCurves" effect on camera; how turn on/off each one separately in j Script ?!

i tried GameObject.GetComponent("ColorCorrectionCurves").enabled; but it can turn on/off just on off the ColorCorrection effect added, but i want to control each on separately;

i also tried to create a same copy of ColorCorrectionCurves.js with ColorCorrectionCurves1.js with change name in ColorCorrectionCurvesEditor1.js and even i changed variable name in both script! but the new ColorCorrectionCurves1.js when added, just turned black the screen; most bug report is this : *

" NullReferenceException: Object reference not set to an instance of an object"
"ColorCorrectionCurvesEditor1.OnEnable () (at Assets/Standard Assets/Editor/Image Effects/ColorCorrectionCurvesEditor1.js:60)"
ColorCorrectionCurvesEditor1:ApplyCurves1() (at Assets/.../ColorCorrectionCurvesEditor1.js:85)
turn on/off components with same name on an object w
ColorCorrectionCurvesEditor1:OnInspectorGUI() (at Assets/.../ColorCorrectionCurvesEditor1.js:129)
"SendMessage UpdateTextures has no receiver"

*

i hope and rather a clear and cool solution :)) without changing script and variables names; but if there is not, also please help me.

specially thanks to every reader

more ▼

asked Aug 01 '12 at 12:04 AM

HanEisa gravatar image

HanEisa
3 2

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

1 answer: sort voted first

Normally you would either name them differently, or use Tags (different ones) and find by tag. If they have different parents (or other ancestors), you could find the ancestors by name with a path as described here: http://docs.unity3d.com/Documentation/ScriptReference/GameObject.Find.html

more ▼

answered Aug 01 '12 at 12:09 AM

DaveA gravatar image

DaveA
26.5k 151 171 256

Thank you very much dave; but two components are added to a single camera, how i use tag? Clearer,for better color correction, i used this component two times on a camera,do you think i can use tag and GameObject.Find for turn on/off each on of them separately? Mistakenly some where in question i called "glow" component, but "ColorCorrectionCurves" be correct,

Aug 01 '12 at 12:59 AM HanEisa

No, not in that case. Normally you should not have to add the same component twice to one object. Are there no settings for which a single one of those components works? In any case, here's a clue: http://answers.unity3d.com/questions/162678/how-to-distinguish-between-multiple-components-of.html Basically, set a variable on each component differently, then GetComponents (gets array of them) and look for the one with the variable value you need.

Aug 01 '12 at 01:09 AM DaveA

Thank you for taking your time to answer me; your guide is true and helpful,also i tried change script and variable name in ColorCorrectionCurves again step-by-step, and it was done,thanks for your assist dear Dave

Aug 01 '12 at 11:18 AM HanEisa
(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:

x302
x42
x21

asked: Aug 01 '12 at 12:04 AM

Seen: 288 times

Last Updated: Aug 01 '12 at 11:18 AM