#if UNITY_EDITOR using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; using OnDeviceAgent.Inference; namespace OnDeviceAgent.AgentCore.Editor { // The com.sky.sentis.* weights aren't committed (fetched from Hugging Face into Models~ on demand), and the // Editor loads them straight from the packages. A player build needs them baked into StreamingAssets, so // ensure they're downloaded, copy them in before the build, and remove them afterwards to keep the tree clean. public sealed class ModelStreamingAssetsBuildStep : IPreprocessBuildWithReport, IPostprocessBuildWithReport { public int callbackOrder => 0; public void OnPreprocessBuild(BuildReport report) { SentisModelProvisioner.EnsureAll(); ModelPathResolver.ProvisionToStreamingAssets(); AssetDatabase.Refresh(); } public void OnPostprocessBuild(BuildReport report) { ModelPathResolver.RemoveFromStreamingAssets(); AssetDatabase.Refresh(); } } } #endif