| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Fateforge.Editor
- {
- public static class CabinetArtwork
- {
- const string Art = "Assets/Fateforge/Art/PhysicalCasino/";
- const string Shop = "Assets/Fateforge/Resources/Fateforge/Art/assets/graphics/sprites/kit_ui_shop_interface/";
- const string Audio = "Assets/Fateforge/Resources/Fateforge/Audio/sfx/";
- public static void Load(UiTheme theme)
- {
- theme.coinSprite = AssetDatabase.LoadAssetAtPath<Sprite>(Art + "CoinStack.png");
- theme.helpBadge = AssetDatabase.LoadAssetAtPath<Sprite>(Art + "HelpBadge.png");
- theme.leverHub = AssetDatabase.LoadAssetAtPath<Sprite>(Art + "LeverHub.png");
- theme.leverRod = AssetDatabase.LoadAssetAtPath<Sprite>(Art + "LeverRod.png");
- theme.leverKnob = AssetDatabase.LoadAssetAtPath<Sprite>(Art + "LeverKnob.png");
- theme.unlockSprite = AssetDatabase.LoadAssetAtPath<Sprite>(Art + "UnlockPlus.png");
- theme.rerollSprite = AssetDatabase.LoadAssetAtPath<Sprite>(Shop + "reroll_button_normal.png");
- theme.ticketRip = AssetDatabase.LoadAssetAtPath<AudioClip>(Audio + "RS_ticket_rip_1.ogg");
- theme.defeatStinger = AssetDatabase.LoadAssetAtPath<AudioClip>(Audio + "CHA_MUS_STINGER_DEFEAT_03.ogg");
- theme.scoreTick = AssetDatabase.LoadAssetAtPath<AudioClip>(Audio + "score/RS_score_ratchet_1.ogg");
- theme.scoreImpact = AssetDatabase.LoadAssetAtPath<AudioClip>(Audio + "score/RS_score_impact.ogg");
- theme.defeatArt=AssetDatabase.LoadAssetAtPath<Sprite>(Art+"AfterHours.png");
- theme.magnetActivation=AssetDatabase.LoadAssetAtPath<AudioClip>(Audio+"combinations/RS_magnet_electric_activation_1.ogg");
- EditorUtility.SetDirty(theme);
- }
- // Also upgrades an already authored scene without rebuilding unrelated assets.
- public static void Apply(ViewBindings view)
- {
- Load(view.theme);
- SetCoin(view.play.Find("CoinIcon"), view.theme);
- var help = (Image)view.help.targetGraphic;
- help.sprite = view.theme.helpBadge;
- help.color = Color.white;
- var helpLabel=view.help.GetComponentInChildren<TMPro.TMP_Text>(true);
- helpLabel.text="";
- helpLabel.enabled=false;
- string path = AssetDatabase.GetAssetPath(view.offerPrefab);
- var root = PrefabUtility.LoadPrefabContents(path);
- try
- {
- var offer = root.GetComponent<OfferView>();
- offer.priceCoin = SetCoin(offer.buy.transform.Find("PriceCoin"), view.theme);
- PrefabUtility.SaveAsPrefabAsset(root, path);
- }
- finally { PrefabUtility.UnloadPrefabContents(root); }
- }
- static Image SetCoin(Transform node, UiTheme theme)
- {
- if (node.TryGetComponent<UiGlyph>(out var old)) Object.DestroyImmediate(old);
- if (!node.TryGetComponent<Image>(out var image)) image = node.gameObject.AddComponent<Image>();
- image.sprite = theme.coinSprite;
- image.color = Color.white;
- image.preserveAspect = true;
- image.raycastTarget = false;
- return image;
- }
- }
- }
|