Is it possible to change CustomPass variables via other script?
Is it possible to set/get a variable used in a CustomPassVolume component? I tried just using GetComponent<[CustomPassName]>() but that didn't work because apparently GetComponent only works on MonoBehaviour components. I also tried using an interface:
public interface ICustomPassVariables {
Transform transform {
get; set;
}
}
and implementing it like this:
class [CustomPassName] : CustomPass, ICustomPassVariables {
.
.
public Transform transform {
get {
return target;
}
set {
target = value;
}
}
.
.
}
And using it in the other script like this:
ICustomPassVariables customPassVariables = volume.gameObject.GetComponent<ICustomPassVariables>();
customPassVariables.transform = transform;
But that just resulted in a NullReferenceException. I tried other methods to get the interface component referenced here but it still resulted in a NullReferenceException. We can change the variables in the inspector so there has to be a way to do so by script right? Thank you.
Your answer
Follow this Question
Related Questions
C# - Cannnot access variable in another script unless I get the component everytime. 1 Answer
Referencing a GameObject's Components from if Statements (c#) 0 Answers
I want to check if variable is missing(not null),Can't check if object has missing variable 0 Answers
Game Manager can't decide what the instance of the object is despite just making an instance of it 1 Answer