Here’s the situation
I have a script “CallAdmin” assigned on a canvas
and there is a prefab “warning” ,which needs “closeBlur”, a function in the script"CallAdmin".
I want to assign “CallAdmin” to the prefab via a script “CloseWarning”
the script seems assigned, but why the compiler says that "obj isn’t exist in current context?
While I don’t really understand much of what you said, your error is pretty straight forward.
You declare CallAdmin obj within Start, which means it’s only available in Start. This is known as a local variable. I’ll not get into to much detail of scope. But if you want a variable available to all methods in that class you need to declare it outside of any methods. You can still assign a value to it in Start, just don’t declare it within Start.
Thanks to your suggestion.
and I decided to assign the “CallAdmin” by FindObjectOfType as below
obj = FindObjectOfType (typeof(CallAdmin))as CallAdmin;