- Home /
GetComponent with Standard Assets? C#
Hello everyone. I'm creating a game where I want a motion blur effect to appear while the player is in a slow-motion state. I have everything set up and ready to go, and I'm using the Blur script from the Standard Assets package for Unity 5. I want to make it so when a bool is true in a different script, the blur script component is enabled, but I can't seem to reference the script component via GetComponent.
Example, I'll try to do:
this.gameObject.GetComponent<MotionBlur>().enabled = true;
However, "MotionBlur" does not exist in context. Anyone know how to reference these Standard Asset scripts? They're put together very strangely.
Thanks!
Answer by nightbane30 · May 01, 2015 at 02:04 AM
Figured it out. Code should be like this:
GetComponent<UnityStandardAssets.ImageEffects.MotionBlur>().enabled = true;
Not too tricky after all!
You could have also added a reference to UnityStandardAssets.ImageEffects with:
using UnityStandardAssets.ImageEffects;
...
GetComponent<$$anonymous$$otionBlur>();
...
Your answer
Follow this Question
Related Questions
Problem when Getting a component from a non Mono Behavior class. 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How getting transform of another GameObject C#? 1 Answer
Getcomponent what do i wrong? 2 Answers