// Set a given sprite to a sprite controller void SetSprite(Sprite key, string strKey, LuaSpriteController spr, int main = -1) { if (key == null) { throw new Exception("Tried to set sprite with key \"" + strKey + "\"."); } if (main < 0 || main > 1 || (main == 0 ? lastPunderSprite : lastLuSprite) != strKey) { spr.img.GetComponent <Image>().sprite = key; spr.img.GetComponent <RectTransform>().sizeDelta = new Vector2(key.texture.width, key.texture.height); if (main == 0) { lastPunderSprite = strKey; } else if (main == 1) { lastLuSprite = strKey; spr.Scale(2, 2); } } }
// Set a given sprite to a sprite controller protected virtual void SetSprite(Sprite key, string strKey, LuaSpriteController spr, int main = -1) { if (key == null) { throw new Exception("Tried to set sprite with key \"" + strKey + "\"."); } if (main >= 0 && main <= 1 && (main == 0 ? lastPunderSprite : lastLuSprite) == strKey) { return; } spr.img.GetComponent <Image>().sprite = key; spr.img.GetComponent <RectTransform>().sizeDelta = new Vector2(key.texture.width, key.texture.height); switch (main) { case 0: lastPunderSprite = strKey; break; case 1: lastLuSprite = strKey; spr.Scale(2, 2); break; } }