my skin is not being loaded properly when I load the scene

when I Start the game the my skin works.
skin is active and true prints a lot.
but when I change scenes and then come back to my Menu Scene
the skin is not active and it is printing false.

so my real question is why it is ever able to print false
since i am trying keep this skin applied the whole time.

void OnGUI (){

GUI.skin=darkness;
print(GUI.skin==darkness);
GUI.DrawTexture (new Rect (0,0,mainMenuTexture.width,mainMenuTexture.height), mainMenuTexture);

}

Welcome to the forums! :slight_smile:

Perhaps you can share some info as to how you set your variable “darkness”? Is it set via the inspector, some other code elsewhere, other? Knowing how that variable is set/initialized will help us (hopefully) sort out why it might be null in later visits to the same scene/level.

First I would like to say that the form has been very helpful there have been many well answered questions that I have been able to look at.

I set darkness in the inspector it is a public variable.

GUI.skin=darkness;
print(GUI.skin==darkness); how can this become false

I do not have my code with me now but tomorrow I can put more up but I do not want to spam the world.

this is your thread. you can spam it with as much of your code as needed to fix the problem!

Then I’m very puzzled as to why it wouldn’t be set properly when you return to that level a second time. In all your code is there anywhere else you set that variable via scripts? Perhaps you can post your project for us to peek at? (or send via PM?)

Sorry for not having something firm here but I’m at a loss to explain this behavior…

I am doing some rearranging of my scripts top make them make more readable for my project hopefully i will find the problem but if after this code clean up is done I am still having the error then I will post more.