diff --git a/CameraAI~/CHANGELOG.md b/CameraAI~/CHANGELOG.md index d3115a3..db53d7e 100644 --- a/CameraAI~/CHANGELOG.md +++ b/CameraAI~/CHANGELOG.md @@ -208,3 +208,6 @@ - Added a self-contained `RuntimeData~` reference bundle (263 prepared songs). - The packaged worker auto-discovers the bundle; raw CW-AI source audio and a separate checkout are no longer required for generation. - Generation caches remain project-local and writable. +## 0.4.4 + +- Automatically prefers bundled `RuntimeData~`, including Unity Git PackageCache installs, over stale serialized external roots. diff --git a/CameraAI~/Editor/AICameraGeneratorWindow.cs b/CameraAI~/Editor/AICameraGeneratorWindow.cs index f87fcac..d6266fb 100644 --- a/CameraAI~/Editor/AICameraGeneratorWindow.cs +++ b/CameraAI~/Editor/AICameraGeneratorWindow.cs @@ -4182,24 +4182,18 @@ namespace Streamingle.Editor var normalizedProjectRoot = string.IsNullOrWhiteSpace(projectRoot) ? Environment.CurrentDirectory : Path.GetFullPath(projectRoot); - var candidates = new[] - { - configuredRoot, - // Self-contained package install: RuntimeData~ is shipped - // beside the editor scripts, so artists do not need a - // separate CW-AI checkout. - Path.Combine( - normalizedProjectRoot, - "Packages", - "com.mingle.cw-ai", - "RuntimeData~"), + var candidates = new List(); + // Prefer the self-contained package, including Unity's resolved + // Git PackageCache path. A stale serialized external CW-AI root + // must not silently override the bundled reference library. + candidates.AddRange(EnumeratePackagedRuntimeRoots(normalizedProjectRoot)); + candidates.Add(configuredRoot); + candidates.Add(normalizedProjectRoot); + candidates.Add(Path.Combine( + Directory.GetParent(normalizedProjectRoot)?.FullName ?? normalizedProjectRoot, - Path.Combine( - Directory.GetParent(normalizedProjectRoot)?.FullName ?? - normalizedProjectRoot, - "CW-AI"), - Environment.CurrentDirectory - }; + "CW-AI")); + candidates.Add(Environment.CurrentDirectory); foreach (var candidate in candidates) { @@ -4230,6 +4224,37 @@ namespace Streamingle.Editor "CW-AI"); } + private static IEnumerable EnumeratePackagedRuntimeRoots( + string projectRoot) + { + yield return Path.Combine( + projectRoot, + "Packages", + "com.mingle.cw-ai", + "RuntimeData~"); + var packageCache = Path.Combine(projectRoot, "Library", "PackageCache"); + if (!Directory.Exists(packageCache)) + { + yield break; + } + IEnumerable matches; + try + { + matches = Directory.EnumerateDirectories( + packageCache, + "com.mingle.cw-ai@*", + SearchOption.TopDirectoryOnly); + } + catch (Exception) + { + yield break; + } + foreach (var match in matches.OrderByDescending(path => path)) + { + yield return Path.Combine(match, "RuntimeData~"); + } + } + private static string ResolveProjectCacheRoot() { var projectRoot = Directory.GetParent(Application.dataPath)?.FullName diff --git a/CameraAI~/package.json b/CameraAI~/package.json index 81eb2bc..27136ae 100644 --- a/CameraAI~/package.json +++ b/CameraAI~/package.json @@ -1,6 +1,6 @@ { "name": "com.mingle.cw-ai", - "version": "0.4.3", + "version": "0.4.4", "displayName": "Mingle Camera Work AI", "description": "Self-contained high-quality Unity Timeline camera generation with an embedded prepared reference library, per-shot editable clips, and A/B review tools.", "unity": "6000.0",