Access to prefab scrpit variable by code
Hi, i need to read the sprite from a prefab's script. For example, the prefab "Axe", has a script "Weapon", and this script has a sprite "icon". Actually i instatiate it, take the sprite, and destroy it. Anyone knows a better way to do it? Gameobject trash=Instantiate("Weapons/Axe",typeof(Gameobject))as Gameobject; Weapon trash_script=trash.getComponent(); Sprite icon_show=trash_script.icon; Destroy(trash);
Comment
Your answer
Follow this Question
Related Questions
[C#] Creating falling coins 1 Answer
Unity 2018.3 New prefab system How do I get rid of it? 1 Answer
Prefabs getting deleted in all scenes! 0 Answers