// 初始化后，扫描并加载所有故事
ConfigManager.Instance.ScanAndLoadStories();

// 获取所有故事
var stories = ConfigManager.Instance.GetAllStories();
foreach (var storyPair in stories)
{
    Debug.Log($"故事: {storyPair.Key} - {storyPair.Value.displayName}");
}

// 设置活动故事
ConfigManager.Instance.SetActiveStory("Story_001");

// 获取活动故事
StoryDefinition activeStory = ConfigManager.Instance.GetActiveStory();

// 获取故事的初始场景
StorySceneDefinition initialScene = ConfigManager.Instance.GetInitialScene();
Debug.Log($"初始场景: {initialScene.displayName}");

// 访问场景的分包信息
if (initialScene.IsPackaged)
{
    foreach (var package in initialScene.packages)
    {
        Debug.Log($"场景包: {package.packageId}, 优先级: {package.priority}");
    }
}

// 获取所有需要加载的键
List<string> keysToLoad = initialScene.GetAllAddressableKeys();
Debug.Log($"需要加载的键: {string.Join(", ", keysToLoad)}");

// 添加新场景
StorySceneDefinition newScene = new StorySceneDefinition
{
    sceneId = "new_scene",
    displayName = "新场景",
    addressableKey = "Stories/Story_001/new_scene_main",
    isInitialScene = false,
    packages = new List<ScenePackageDefinition>
    {
        new ScenePackageDefinition
        {
            packageId = "env",
            addressableKey = "Stories/Story_001/new_scene_env",
            loadAtStart = true,
            priority = PackagePriority.Essential
        },
        new ScenePackageDefinition
        {
            packageId = "chars",
            addressableKey = "Stories/Story_001/new_scene_chars",
            loadAtStart = false,
            priority = PackagePriority.Medium
        }
    }
};

ConfigManager.Instance.AddSceneToStory("Story_001", newScene);

// 监听故事变更事件
ConfigManager.Instance.OnStoryUpdated += (story) =>
{
    Debug.Log($"故事已更新: {story.displayName}");
};