Working flipping cards

This commit is contained in:
Michal Pikulski
2025-11-06 21:31:16 +01:00
parent 774f27410a
commit d23c000347
16 changed files with 2221 additions and 272 deletions

View File

@@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using AppleHills.Data.CardSystem;
using AppleHills.Editor.Utilities;
using UI.CardSystem;
using UnityEditor;
using UnityEngine;
@@ -17,7 +18,7 @@ namespace Editor.CardSystem
// Paths
private const string CardDefinitionsPath = "Assets/Data/Cards";
private const string MenuPath = "AppleHills/Card Editor";
private const string CardUIPrefabPath = "Assets/Prefabs/UI/Cards/Card.prefab";
private const string CardUIPrefabPath = "Assets/Prefabs/UI/CardsSystem/Cards/Card.prefab";
private const string CardVisualConfigPath = CardDefinitionsPath + "/CardVisualConfig.asset";
// Preview settings
@@ -501,6 +502,17 @@ namespace Editor.CardSystem
AssetDatabase.CreateAsset(newCard, path);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
// Add to Addressables group "BlokkemonCards" and apply "BlokkemonCard" label
if (AddressablesUtility.EnsureAssetInGroupWithLabel(path, "BlokkemonCards", "BlokkemonCard"))
{
AddressablesUtility.SaveAddressableAssets();
Debug.Log($"[CardEditorWindow] Added new card to Addressables with 'BlokkemonCard' label");
}
else
{
Debug.LogWarning("[CardEditorWindow] Failed to add new card to Addressables. Please ensure Addressables are set up in this project.");
}
LoadCardDefinitions();
SelectCard(newCard);
@@ -524,6 +536,7 @@ namespace Editor.CardSystem
string desiredFileName = _selectedCard.UseCustomFileName && !string.IsNullOrEmpty(_selectedCard.CustomFileName)
? _selectedCard.CustomFileName
: _selectedCard.Name;
string finalPath = oldPath;
if (!string.IsNullOrEmpty(desiredFileName))
{
@@ -547,12 +560,26 @@ namespace Editor.CardSystem
Debug.LogError($"[CardEditorWindow] Failed to rename asset: {error}");
}
else
finalPath = uniquePath;
{
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
}
// Add to Addressables group "BlokkemonCards" and apply "BlokkemonCard" label
if (!string.IsNullOrEmpty(finalPath))
{
if (AddressablesUtility.EnsureAssetInGroupWithLabel(finalPath, "BlokkemonCards", "BlokkemonCard"))
{
AddressablesUtility.SaveAddressableAssets();
Debug.Log($"[CardEditorWindow] Added {_selectedCard.Name} to Addressables with 'BlokkemonCard' label");
}
else
{
Debug.LogError("[CardEditorWindow] Failed to add card to Addressables. Please ensure Addressables are set up in this project.");
}
}
_isDirty = false;