for line 1 i get - ‘The name obj' does not exist in the current context' for line 2 i get- A field initializer cannot reference the nonstatic field, method, or property FadeScript.spRend’
my motive with this script is to change the alpha level (transparency) of the 2D sprite.
I can’t give you a save answer without seeing the whole code, but I’m assuming that you defined these two variables as class-variables.
The second error simply means, that you don’t know, when which variable is initialized at runtime. The second expression could possibly be called first and then you get a NullReferenceException.
You can declare them as class-variables, but initialize them at the Awake or Start method to avoid these errors.
The first error is like Cherno said, that “obj” does not exist and if you want to reference to the GameObject the script is attached to, you have to use “transform” instead.