internal static void Postfix(StandardTowerPurchaseButton __instance) { if (__instance.baseTowerModel.GetModTower()?.ModTowerSet is ModTowerSet modTowerSet) { ResourceLoader.LoadSpriteFromSpriteReferenceAsync(modTowerSet.ContainerReference, __instance.GetComponent <Image>()); } }
internal static void Postfix(StandardTowerPurchaseButton __instance, ref SpriteReference __result) { if (__instance.baseTowerModel.GetModTower()?.ModTowerSet is ModTowerSet modTowerSet) { __result = modTowerSet.ContainerReference; } }
/// <summary> /// Set the background image of this button /// </summary> /// <param name="button"></param> /// <param name="texture2D"></param> public static void SetBackground(this StandardTowerPurchaseButton button, Texture2D texture2D) { button.bg = button.gameObject.GetComponent <Image>(); var sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f), 100f, 0u, SpriteMeshType.Tight); button.bg.overrideSprite = sprite; button.bg.sprite = sprite; }
internal static bool Fix(ref StandardTowerPurchaseButton __instance, ref TowerModel towerModel, ref bool showTowerCount, ref bool hero, ref int buttonIndex) { if (towerModel.baseId.Contains(customTowerName)) { __instance.UpdateTowerDisplay(); Texture2D pngTexture = TextureFromPNG(@"Mods\bloonchipper\bloonchipper.png"); Sprite temp = Sprite.Create(pngTexture, new Rect(0.0f, 0.0f, pngTexture.width, pngTexture.height), default); __instance.bg.sprite = temp; __instance.icon.sprite = temp; __instance.icon.overrideSprite = temp; __instance.icon.material.mainTexture = temp.texture; __instance.UpdateIcon(); } return(true); }
/// <summary> /// Set the background image of this button /// </summary> /// <param name="button"></param> /// <param name="sprite"></param> public static void SetBackground(this StandardTowerPurchaseButton button, Sprite sprite) { button.bg = button.gameObject.GetComponent <Image>(); button.bg.overrideSprite = sprite; button.bg.sprite = sprite; }