Quantcast
Channel: Questions in topic: "static variables"
Viewing all articles
Browse latest Browse all 84

Making my variable global.

$
0
0
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***

Viewing all articles
Browse latest Browse all 84

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>