修改项目根地址, 并将部分依赖于ToolFile的功能迁移至依赖Interaction以实现网络文件的获取

This commit is contained in:
2025-09-29 16:38:09 +08:00
parent 557a08d51b
commit 6c3d5934dc
86 changed files with 1184 additions and 48 deletions

View File

@@ -309,7 +309,7 @@ namespace Demo.Editor
new GameObject("GameContent").AddComponent<GameContent>();
}
var content = GameContent.instance;
content.RootSourceDir = Path.Combine(PlatformIndicator.StreamingAssetsPath, ProjectName) + "/";
content.RootSourceDir = Path.Combine(PlatformIndicator.PersistentDataPath, ProjectName) + "/";
content.IsCreateNewProject = IsCreateNewProject;
content.ScriptableObjectTypen = GetDefaultScriptableObjectTypen();
content.IsAutoPlay = true;

View File

@@ -61,6 +61,7 @@ namespace Demo.Game
if (Editor.EditorController.instance.MainGameController == this)
{
string clipPath = (string)MainConfig.FindItem("song", "");
AudioType audioType = (AudioType)MainConfig.FindItem("audioType", BasicAudioSystem.GetAudioType(clipPath));
if (string.IsNullOrEmpty(clipPath))
{
foreach (var file in MainConfig.ConfigFile.BackToParentDir().DirToolFileIter())
@@ -79,15 +80,15 @@ namespace Demo.Game
{
IEnumerator Run()
{
var clipFile = new ToolFile(clipPath);
var clipFile = new Interaction(clipPath);
if (clipFile.Exists() == false)
clipFile = MainConfig.GetFile(clipPath);
clipFile = new(MainConfig.GetFile(clipPath).GetFullPath());
if (clipFile.Exists() == false)
{
Debug.LogError($"Cannt load {clipPath}", this);
yield break;
}
yield return MainAudio.LoadAudio(clipFile, BasicAudioSystem.GetAudioType(clipPath));
yield return MainAudio.LoadAudio(clipFile, audioType);
content.SongLoadOverCallback(MainAudio);
yield return GameAudioSystemInit();
}

View File

@@ -871,6 +871,7 @@ namespace Demo
file = file | "Windows";
#endif
file = file | ab;
var downloader = new Interaction(file.GetFullPath());
if (AssetBundlesItemEntry == null)
{
var hierarchy = HierarchyWindow.instance;
@@ -880,7 +881,7 @@ namespace Demo
var abLoadingItem = AssetBundlesItemEntry.ref_value.GetComponent<HierarchyItem>().CreateSubPropertyItem(1)[0];
var loadingHierarchyItem = abLoadingItem.ref_value.GetComponent<HierarchyItem>();
loadingHierarchyItem.title = $"{ab}<Loading>";
var ir = file.LoadAsAssetBundle(p =>
var ir = downloader.LoadAsAssetBundle(p =>
{
loadingHierarchyItem.title = $"{ab}<Loading{(int)(p * 100)}%>";
}, x =>
@@ -908,39 +909,6 @@ namespace Demo
AssetBundleLoading.Remove(ab);
}
public static AssetBundle LoadAssetBundle(this IAssetBundleLoader self, string ab)
{
if (AssetBundleCounter.TryGetValue(ab, out var result))
{
result.referenceCounter++;
return result.assetBundle;
}
var file = new ToolFile(PlatformIndicator.StreamingAssetsPath) | "AssetBundle/";
#if PLATFORM_WINDOWS
file = file | "Windows";
#endif
file = file | ab;
if (AssetBundlesItemEntry == null)
{
var hierarchy = HierarchyWindow.instance;
AssetBundlesItemEntry = hierarchy.CreateRootItemEntryWithBinders(nameof(AssetBundlesLoadHelper))[0];
AssetBundlesItemEntry.ref_value.GetComponent<HierarchyItem>().title = nameof(AssetBundlesLoadHelper);
}
var abLoadingItem = AssetBundlesItemEntry.ref_value.GetComponent<HierarchyItem>().CreateSubPropertyItem(1)[0];
abLoadingItem.ref_value.GetComponent<HierarchyItem>().title = $"{ab}<Loading>";
var assetBundle = file.LoadAsAssetBundle();
var item = abLoadingItem.ref_value.GetComponent<HierarchyItem>();
item.title = $"{ab}";
var assets = assetBundle.GetAllAssetNames();
var subAssetsItems = item.CreateSubPropertyItem(assets.Length);
for (int i = 0, e = assets.Length; i < e; i++)
{
subAssetsItems[i].ref_value.GetComponent<HierarchyItem>().title = Path.GetFileName(assets[i]);
}
AssetBundleCounter[ab] = new(assetBundle, 1, abLoadingItem);
return assetBundle;
}
public static IEnumerator UnloadAssetBundle(this IAssetBundleLoader self, string ab)
{
// Editor中暂时忽略卸载功能