Question by 
               ssk090 · Oct 10, 2015 at 07:06 AM · 
                javascriptspritesspriterendererdontdestroyonloadstatic variables  
              
 
              Making my variable global.
I was trying to change the sprite image of my character from another scene. I made two scripts 1. Sprite_Img.js 2. changeTheSprite.js
I have attached Sprite_Img.js to my character object and changeTheSprite,js to a image
But still it isn't working well. I dont know why. Please Help
Sprite_Img.js
 #pragma strict
 
 var sprite2:Sprite;
 static public var sprite1:Sprite;
 
 
 
 function Awake(){
 sprite2 = sprite1;
 }
 
 function Start (){
 GetComponent(SpriteRenderer).sprite = sprite2;
 }
 
               changeTheSprite.js
 #pragma strict
 
 var sprite3 : Sprite;
 function Start() {
  if (Input.GetMouseButton(1)){       
      Sprite_Img.sprite1 = sprite3;
      }
 }
 
 
               THANK YOU
               Comment
              
 
               
              Answer by hexagonius · Oct 10, 2015 at 07:40 AM
keep a reference to the spriterenderer instead of the sprite . this way, the change will work.
can you edit my code a bit and explain I would appreciate if you do so :D
Your answer