- Home /
I cannot get script component.
I want to enable/disable bloom effect through script. I have done it in my previous projects successfully. I've tried creating new projects, scripts. Nothing helped.
Answer by Vicarian · Jun 29, 2018 at 07:21 PM
Bloom's no longer a class as of Unity 5.4 or so. Use the Post-Processing Stack. Search for it on asset store.
I’ve choosed older version because it is easier for me to manage graphics settings from game menu. I don’t know how to do it with the latest version.
I wouldn't advise this, but you can do what you want. You'll have to search your local documentation because Unity Technologies no longer has documentation online from any version prior to 5.1.
Answer by HHammerite · Jun 29, 2018 at 07:23 PM
Where in your project is the 'Bloom' script located? You probably need to add a reference to it at the top of your file.
As you can see on the image bloom script is added to main camera. In my old projects i didn’t have to add a reference.
I was asking where it is located in your project's asset's folder. You will need a reference to it in your script. For example -> Bloom is located under Assets/Scripts/PostProcessing/ you will have to include something similar to 'using Scripts.PostProcessing;' in your script where you are referencing it.
Here is the solution for post-processing but i still have problems with enabling / disabling other scripts.
Answer by wicke · Jun 29, 2018 at 07:36 PM
You are trying to get the script from a transform type object. Try this instead
target.gameObject.GetComponent<Bloom>();
This is assuming. The target variable is assigned with the MainCamera's transform.
The bloom class is missing, if you notice the error generated by VS. Resolving the component to a reference isn't the issue for the OP. I suspect his code was upgraded to a higher version of Unity somehow, where the bloom effect was removed and placed into the Post Processing Stack. The OPs unwillingness to learn the latest version of Unity is the overarching problem here.
From the editor, add a script to the project (it can be just the default template). Click into VS. You should get a dialog mentioning that the project changed on disk and needs to be reloaded. If you don't then there's something wrong with the .sln file. Delete it and the .csproj files from the project folder and have Unity recreate them.
Your answer
Follow this Question
Related Questions
how to enable or disable a script via code c# 1 Answer
About takeover control 0 Answers
Enable/Disable Script on GameObject when pressing a key 1 Answer
Can't disable component, little checkbox is missing from inspector 1 Answer
Add components to a list in inspector and then activate them at runtime? 1 Answer