OnGUI() AddComponent<U3DImageEfx> Trouble

Hello,

I am attemping to make a prototype of an application to showcase Unity Pro’s image effects (their Scripts).
I created a drop down list with labels as “buttons” with their respective names like “Blur” so when you click on it, the camera becomes “Blur” by ADDING A SCRIPT COMPONENT during OnGUI(). Problem is, it adds the component infinitely due to OnGUI() being called every frame. Is there a workaround if I only want to add the effect once?.

Thanks-in-advance for anyone who cna help me out.

I’m not sure how you’re handling ‘button clicks’, but you could add additional logic to your code to only respond to ‘click’ events (it sounds like you’re doing something other than that now), and/or check to see if the game object already has the specified type of component before adding a new one (which you’ll probably want to do anyway to prevent multiple clicks from adding the same component multiple times).

I am handling the drop down list through labels where they recognize by the “String” they contain in the label and add the effect respectively, e.g. Label: Blur adds BlurEffect.