void setupTexture() { if (spriteHandler == null) { spriteHandler = FindObjectOfType <SpriteHandler>(); } Texture2D tex = spriteHandler.GetTexture(spell.spellType); texture = new Texture2D(tex.width, tex.height); texture.SetPixels(tex.GetPixels()); texture.filterMode = FilterMode.Point; pixelList = HelperFunctions.makePixelMap(tex); iconMap = HelperFunctions.makeSpellIconMap(tex); GetComponent <BoxCollider2D>().size = new Vector2(tex.width, tex.height); applyTexture(); }