mirror of
https://github.com/Earth-Genesis-Games/Ajedrez_Purgatorio.git
synced 2026-09-11 09:47:35 +00:00
- Duel flow: mating piece vs boss while board collapses (PurgatoryDuelManager/Rules/UI/MuerteQuotes) - GameState.PurgatoryDuel + CampaignManager rescue/restart hooks + SquareClick routing - Dice-based rescue of most valuable dead identity; final defeat restarts Chapter 1 - 6 SFX clips wired in Ch1/2/3 via AudioClipAssigner - OptionsMenuController runtime audio/graphics panel, wired to MainMenu - Tests migrated to Assets/Tests/EditMode subfolders + PurgatoryDuelRulesTests (200 total) - Editor tools: DiagAssign, SpeakerDatabaseSetup, PurgatoryCanvasMaintenance
88 lines
3.1 KiB
C#
88 lines
3.1 KiB
C#
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEditor.SceneManagement;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using AjedrezPurgatorio.Audio;
|
|
|
|
namespace AjedrezPurgatorio.EditorTools
|
|
{
|
|
/// <summary>
|
|
/// Asigna los SFX placeholder (Assets/Audio/SFX/*.wav) a todos los
|
|
/// AudioManager de las escenas y guarda las escenas modificadas.
|
|
/// Ejecutar con:
|
|
/// Unity -batchmode -projectPath . -executeMethod
|
|
/// AjedrezPurgatorio.EditorTools.AudioClipAssigner.AssignPlaceholderClipsToAllScenes
|
|
/// </summary>
|
|
public static class AudioClipAssigner
|
|
{
|
|
private static readonly (string field, string file)[] Bindings =
|
|
{
|
|
("_moveSFX", "move"),
|
|
("_captureSFX", "capture"),
|
|
("_checkSFX", "check"),
|
|
("_checkmateSFX", "checkmate"),
|
|
("_promotionSFX", "promotion"),
|
|
("_invalidMoveSFX","invalid_move"),
|
|
};
|
|
|
|
private static readonly string[] SceneNames =
|
|
{
|
|
"MainMenu", "Chapter1", "Chapter2", "Chapter3",
|
|
};
|
|
|
|
public static void AssignPlaceholderClipsToAllScenes()
|
|
{
|
|
int assignedTotal = 0;
|
|
|
|
try
|
|
{
|
|
foreach (string sceneName in SceneNames)
|
|
{
|
|
Scene scene = EditorSceneManager.OpenScene(
|
|
$"Assets/Scenes/{sceneName}.unity", OpenSceneMode.Single);
|
|
|
|
foreach (AudioManager am in Object.FindObjectsByType<AudioManager>(
|
|
FindObjectsInactive.Include, FindObjectsSortMode.None))
|
|
{
|
|
var so = new SerializedObject(am);
|
|
int assigned = 0;
|
|
|
|
foreach (var (field, file) in Bindings)
|
|
{
|
|
SerializedProperty prop = so.FindProperty(field);
|
|
var clip = AssetDatabase.LoadAssetAtPath<AudioClip>(
|
|
$"Assets/Audio/SFX/{file}.wav");
|
|
|
|
if (prop == null || clip == null || prop.objectReferenceValue != null)
|
|
continue;
|
|
|
|
prop.objectReferenceValue = clip;
|
|
assigned++;
|
|
}
|
|
|
|
if (assigned > 0)
|
|
{
|
|
so.ApplyModifiedPropertiesWithoutUndo();
|
|
EditorSceneManager.MarkSceneDirty(scene);
|
|
Debug.Log($"[AudioClipAssigner] '{sceneName}': {assigned} clips asignados a AudioManager.");
|
|
}
|
|
|
|
assignedTotal += assigned;
|
|
}
|
|
|
|
EditorSceneManager.SaveScene(scene);
|
|
}
|
|
|
|
Debug.Log($"[AudioClipAssigner] COMPLETO: {assignedTotal} referencias asignadas.");
|
|
EditorApplication.Exit(0);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Debug.LogError($"[AudioClipAssigner] FALLÓ: {ex}");
|
|
EditorApplication.Exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|