using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using BITKit; using UnityEngine; using YooAsset; using Object = UnityEngine.Object; namespace BITFALL.Debuger { public class BITFALLCommands { [BITCommand] public static async void Impulse(int code) { await BITApp.SwitchToMainThread(); switch (code) { case 101: var sw = new Stopwatch(); sw.Start(); try { var package = YooAssets.GetPackage("DefaultPackages"); var infos = package.GetAssetInfos("item"); var sos = new List(); foreach (var info in infos) { var so = YooAssets.LoadAssetAsync(info.AssetPath); so.WaitForAsyncComplete(); sos.Add(so.AssetObject.As()); so.Release(); } var pos = Camera.main.transform; foreach (var so in sos) { BIT4Log.Log("准备生成:" + so.Name); try { var instance = Object.Instantiate(so.GetPrefab(), pos.position, pos.rotation); } catch (Exception e) { BIT4Log.Warning(so.Name); BIT4Log.LogException(e); } } sw.Stop(); } catch (Exception e) { BIT4Log.LogException(e); sw.Stop(); } BIT4Log.Log($"生成完成,耗时:{sw.ElapsedMilliseconds}ms"); break; } } } }