I did it, only he is not going for the button,
someone help?
public GameObject Script;
public Button previous, next;
GameObject Script = ((previous) as Button).gameObject;
GameObject Script = ((next) as Button).gameObject;
I did it, only he is not going for the button,
someone help?
public GameObject Script;
public Button previous, next;
GameObject Script = ((previous) as Button).gameObject;
GameObject Script = ((next) as Button).gameObject;
If your class has a variable public GameObject Script;
and then you want to assign a value to it, you should just write Script = <whatever>
. If you write GameObject Script = <whatever>
you are creating a new variable that is “local” to your function (only visible inside of that function) that just happens to have the same name (this is called “shadowing”). When you do that, “Script” refers to the new (local) variable inside of that function, but it still refers to the class variable in all other functions.
Also, if “previous” and “next” are already Button variables, you don’t need to write “as Button” when you use them. You only need to use “as” when you are changing it to a different type.
I did not understand your logic, would it,If not, can you show me?
Script = previous.GetComponent<Button>();