/// <summary> /// 同步加载接口 /// 注意:仅支持特殊的无依赖资源 /// </summary> public T SyncLoad <T>(string resName) where T : UnityEngine.Object { UnityEngine.Object result = null; if (AssetSystem.AssetLoadMode == EAssetLoadMode.EditorMode) { #if UNITY_EDITOR string loadPath = AssetSystem.GetDatabaseAssetPath(resName); result = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(loadPath); #else throw new Exception("AssetDatabaseLoader only support unity editor."); #endif } else if (AssetSystem.AssetLoadMode == EAssetLoadMode.ResourceMode) { result = Resources.Load <T>(resName); } else if (AssetSystem.AssetLoadMode == EAssetLoadMode.BundleMode) { string fileName = System.IO.Path.GetFileNameWithoutExtension(resName); string manifestPath = AssetPathHelper.ConvertResourcePathToManifestPath(resName); string loadPath = AssetSystem.BundleMethod.GetAssetBundleLoadPath(manifestPath); AssetBundle bundle = AssetBundle.LoadFromFile(loadPath); result = bundle.LoadAsset <T>(fileName); bundle.Unload(false); } else { throw new NotImplementedException($"{AssetSystem.AssetLoadMode}"); } return(result as T); }
protected override void Start(SystemRegistry registry) { _input = registry.GetSystem <InputSystem>(); _gs = registry.GetSystem <GraphicsSystem>(); _sls = registry.GetSystem <SceneLoaderSystem>(); _as = registry.GetSystem <AssetSystem>(); }
/// <summary> /// 获取显示列表 /// </summary> private string[] GetShowInfos() { // 清空列表 _cacheInfos.Clear(); var fileLoaders = AssetSystem.DebugAllLoaders(); foreach (var loader in fileLoaders) { // 只搜索关键字 if (string.IsNullOrEmpty(_searchKey) == false) { if (loader.LoadPath.Contains(_searchKey) == false) { continue; } } string showInfo = EditorTools.Substring(loader.LoadPath, "/assets/", false); showInfo = showInfo.Replace(".unity3d", string.Empty); showInfo = $"{showInfo} = {loader.RefCount}"; // 添加到显示列表 _cacheInfos.Add(showInfo); } // 重新排序 var array = _cacheInfos.ToArray(); System.Array.Sort(array, string.CompareOrdinal); return(array); }
/// <summary> /// 从路径预载异步游戏对象 /// </summary> /// <param name="resPath">路径</param> public static void PreLoadFromPath(string resPath) { if (!CachePrefabs.Contains(resPath)) { AssetSystem.LoadAssetAsyn(resPath, answer); } }
private void FilterInfos() { // 回收引用 ReferencePool.Release(_cacheInfos); _cacheInfos.Clear(); var fileLoaders = AssetSystem.GetAllLoaders(); _loaderTotalCount = fileLoaders.Count; foreach (var loader in fileLoaders) { // 只搜索关键字 if (string.IsNullOrEmpty(_filterKey) == false) { if (loader.BundleInfo.BundleName.Contains(_filterKey) == false) { continue; } } LoaderWrapper loaderWrapper = ReferencePool.Spawn <LoaderWrapper>(); loaderWrapper.BundleName = loader.BundleInfo.BundleName; loaderWrapper.Loader = loader; // 添加到显示列表 _cacheInfos.Add(loaderWrapper); } // 重新排序 _cacheInfos.Sort(); }
protected override void Attached(SystemRegistry registry) { _as = registry.GetSystem <AssetSystem>(); _meshData = _as.Database.LoadAsset <MeshData>(_meshAsset.ID); _textureData = _as.Database.LoadAsset <ImageSharpTexture>(_textureAsset.ID); _transform = GameObject.Transform; _centeredBounds = _meshData.GetBoundingBox(); _objectCenter = _centeredBounds.GetCenter(); // _gs.ExecuteOnMainThread(() => // { // InitializeContextObjects(_gs.Context, _gs.MaterialCache, _gs.BufferCache); // }); // _gs = registry.GetSystem<GraphicsSystem>(); // _ad = registry.GetSystem<AssetSystem>().Database; // _texstture = Texture.Get(_ad); // _mesh = Mesh.Get(_ad); // _centeredBoundingSphere = _mesh.GetBoundingSphere(); // _centeredBoundingBox = _mesh.GetBoundingBox(); // _gs.ExecuteOnMainThread(() => // { // InitializeContextObjects(_gs.Context, _gs.MaterialCache, _gs.BufferCache); // }); }
public void UnLoadAnimEffectData() { foreach (KeyValuePair <int, AnimationEffect> pair in mAnimEffectTemplateList) { AssetSystem.UnloadAsset(pair.Value); } mAnimEffectTemplateList.Clear(); }
protected override void PostAttached(SystemRegistry registry) { _as = registry.GetSystem <AssetSystem>(); if (_mesh.GetRef() != null) { SetEntity(CreateEntity()); } }
protected override void Attached(SystemRegistry registry) { _gs = registry.GetSystem <GraphicsSystem>(); _as = registry.GetSystem <AssetSystem>(); var ad = _as.Database; RecreateCubemapTexture(); _gs.ExecuteOnMainThread(() => InitializeContextObjects(ad, _gs.Context)); }
public void OnGUI() { int totalCount = AssetSystem.GetFileLoaderCount(); int failedCount = AssetSystem.GetFileLoaderFailedCount(); DebugConsole.GUILable($"[{nameof(ResManager)}] AssetLoadMode : {AssetSystem.AssetLoadMode}"); DebugConsole.GUILable($"[{nameof(ResManager)}] Asset loader total count : {totalCount}"); DebugConsole.GUILable($"[{nameof(ResManager)}] Asset loader failed count : {failedCount}"); }
public void DestroyMouseCursroManager() { foreach (var tmpCursorInfo in dic_CursorInfo) { AssetSystem.UnloadAsset(tmpCursorInfo.Value.CursorTexture); //tmpCursorInfo.Value.CursorTexture = null; } dic_CursorInfo.Clear(); dic_CursorInfo = null; }
// Use this for initialization IEnumerator Start() { INS = this; MessageSystem.UF_GetInstance().UF_AddListener(DefineEvent.E_START_BATTLE, OnAllReady); yield return(StartCoroutine(AssetSystem.UF_GetInstance().UF_InitAssetSystem())); RandomUtil.Init(int.Parse(GetTimeStamp())); AllUI.Instance.Show("PanelLogin"); }
protected unsafe override void Start(SystemRegistry registry) { _assetSystem = registry.GetSystem <AssetSystem>(); _sls = registry.GetSystem <SceneLoaderSystem>(); _gs = registry.GetSystem <GraphicsSystem>(); _audioSource = GameObject.GetComponent <AudioSourceComponent>(); LoadFont(); _gs.ImGuiRenderer.RecreateFontDeviceTexture(_gs.Context); _allScenes = _assetSystem.Database.GetAssetsOfType(typeof(SceneAsset)); }
static T Test <T>(Func <IAssetManager, T> func) { var disk = new MockFileSystem(true); var exchange = AssetSystem.Setup(disk, JsonUtil, GeneralConfig, Settings, CoreConfig, GameConfig); var assets = exchange.Resolve <IAssetManager>(); var result = func(assets); Assert.NotNull(result); return(result); }
protected override void Attached(SystemRegistry registry) { _assetSystem = registry.GetSystem <AssetSystem>(); _audioSystem = registry.GetSystem <AudioSystem>(); _source = _audioSystem.Engine.ResourceFactory.CreateAudioSource(); OnTransformChanged(Transform); _source.Gain = _gain; _source.Looping = Looping; if (_clipRef != null && !_clipRef.ID.IsEmpty) { GetBufferForRef(); } }
public void Start() { if (CachePrefabs.Contains(resPath)) { GameObject prefab = CachePrefabs[resPath] as GameObject; Perform(prefab); DestroyImmediate(this); } else { AssetSystem.LoadAssetAsyn(resPath, this); } }
public async Task <AssetSystem> PutSystem(AssetSystem note) // public async Task<IActionResult> Index([FromForm]IFormFile file) { var userId = (string)HttpContext.Items["User"]; UserDetailsRequest userDetailsRequest = new UserDetailsRequest(); userDetailsRequest.id = userId; var userDetails = await _kistService.UsersDetails(userDetailsRequest); note.modifiedBy = userDetails.Forename + " " + userDetails.Surname; note.modifiedOn = DateTime.Now; return(await _kistService.PutAssetSystem(note)); }
static void Main() { AssetSystem.LoadEvents(); var disk = new FileSystem { CurrentDirectory = @"C:\Depot\bb\ualbion" }; var baseExchange = AssetSystem.SetupSimple(disk, AssetMapping.Global, "Base"); var testExchange = AssetSystem.SetupSimple(disk, AssetMapping.Global, "UATestDev"); var repackedExchange = AssetSystem.SetupSimple(disk, AssetMapping.Global, "Repacked"); InitialiseAssets(); var assets = new Dictionary <AssetId, object> { [AssetId.FromUInt32(PaletteCommon.Id)] = PaletteCommon, [Palette1Id] = Palette1, [Tileset1.Tileset.Id] = Tileset1.Tileset, [(SpriteId)Tileset1.TilesetGfx.Id] = Tileset1.TilesetGfx, }; void Merge(Dictionary <AssetId, object> newAssets) { foreach (var kvp in newAssets) { assets[kvp.Key] = kvp.Value; } } Merge(JumpMap.Build((Map)300, (Map)100, 5, 5)); Merge(NpcMap.Build((Map)301)); Merge(FlagTestMap.Build((Map)100)); (object?asset, AssetInfo?info) LoaderFunc(AssetId id, string lang) => assets.TryGetValue(id, out var asset) ? (asset, new AssetInfo(new Dictionary <string, object> { { AssetProperty.PaletteId, Palette1Id.Id } })) : (null, null); // Create 3D lab graphics // Create 3D lab data // Create item data // Create player graphics //Tileset1.TilesetGfx.ToBitmap().Dump(); testExchange.Resolve <IModApplier>().SaveAssets(LoaderFunc, () => { }, assets.Keys.ToHashSet(), null, null); repackedExchange.Resolve <IModApplier>().SaveAssets(LoaderFunc, () => { }, assets.Keys.ToHashSet(), null, null); Console.WriteLine("Done"); }
static AssetLoadTests() { var disk = new MockFileSystem(true); var baseDir = ConfigUtil.FindBasePath(disk); GeneralConfig = AssetSystem.LoadGeneralConfig(baseDir, disk, JsonUtil); CoreConfig = new CoreConfig(); GameConfig = AssetSystem.LoadGameConfig(baseDir, disk, JsonUtil); Settings = new GeneralSettings { ActiveMods = { "Base" }, Language = Language.English }; }
IModApplier BuildApplier(string mod) { var generalConfig = AssetSystem.LoadGeneralConfig(_baseDir, _disk, JsonUtil); var coreConfig = new CoreConfig(); var gameConfig = AssetSystem.LoadGameConfig(_baseDir, _disk, JsonUtil); var settings = new GeneralSettings { ActiveMods = { mod }, Language = Language.English }; var exchange = AssetSystem.Setup(_disk, JsonUtil, generalConfig, settings, coreConfig, gameConfig); return(exchange.Resolve <IModApplier>()); }
public void Awake() { if (System.IO.Directory.Exists(ResDef.DataPath) == false) { System.IO.Directory.CreateDirectory(ResDef.DataPath); } if (System.IO.Directory.Exists(ResDef.OuterPackageDirectory) == false) { System.IO.Directory.CreateDirectory(ResDef.OuterPackageDirectory); } Singleton = this; LoadPackageList(); LoadResourceList(); ResourceEx.Init(); }
protected override void Start(SystemRegistry registry) { _input = registry.GetSystem <InputSystem>(); _ballCollider = GameObject.GetComponent <SphereCollider>(); int magnetTrackerLayer = registry.GetSystem <PhysicsSystem>().GetLayerByName("MagnetDetector"); _magnetTrackingZone = ObjectTrackingZone.Create(GameObject.Transform, Radius, "CrazyCore.Magnet", magnetTrackerLayer); _zoneSphereCollider = _magnetTrackingZone.GameObject.GetComponent <SphereCollider>(); AssetSystem assetSystem = registry.GetSystem <AssetSystem>(); _magnetParticleGo = assetSystem.Database.LoadAsset <SerializedPrefab>("Prefabs/MagnetParticles.prefab", false) .Instantiate(registry.GetSystem <GameObjectQuerySystem>()); _magnetParticles = _magnetParticleGo.GetComponent <ParticleSystem>(); _magnetParticleGo.Transform.Parent = Transform; _magnetParticleGo.Transform.LocalPosition = Vector3.Zero; }
/// <summary> /// 异步加载 /// </summary> public void Load(string resName, System.Action <Asset, EAssetResult> prepareCallbcak) { // 防止重复加载 if (Result != EAssetResult.None) { LogSystem.Log(ELogType.Warning, $"Asset {ResName} is already load."); return; } if (_cacheLoader != null) { LogSystem.Log(ELogType.Warning, $"Asset {ResName} loader must null."); return; } ResName = resName; Result = EAssetResult.Loading; _prepareCallback = prepareCallbcak; _cacheLoader = AssetSystem.LoadAssetFile(ResName, AssetType, OnAssetFileLoad); }
private void FilterInfos() { // 回收引用 ReferencePool.Release(_cacheInfos); // 清空列表 _cacheInfos.Clear(); // 绘制显示列表 var fileLoaders = AssetSystem.GetAllLoaders(); _loaderTotalCount = fileLoaders.Count; foreach (var loader in fileLoaders) { // 只搜索关键字 if (string.IsNullOrEmpty(_filterKey) == false) { if (loader.LoadPath.Contains(_filterKey) == false) { continue; } } string info = Substring(loader.LoadPath, "/assets/"); info = info.Replace(".unity3d", string.Empty); info = $"{info} = {loader.RefCount}"; InfoWrapper element = ReferencePool.Spawn <InfoWrapper>(); element.Info = info; element.LoadState = loader.States; element.ProviderFailedCount = loader.GetFailedProviderCount(); // 添加到显示列表 _cacheInfos.Add(element); } // 重新排序 _cacheInfos.Sort(); }
/// <summary> /// 异步加载 /// </summary> public void Load(string resName, System.Action <Asset> userCallbcak) { // 防止重复加载 if (Result != EAssetResult.None) { LogSystem.Log(ELogType.Warning, $"Asset {ResName} is already load."); return; } if (_cacheLoader != null) { LogSystem.Log(ELogType.Warning, $"Asset {ResName} loader must null."); return; } ResName = resName; Result = EAssetResult.Loading; _userCallback = userCallbcak; bool isStreamScene = this is AssetScene; _cacheLoader = AssetSystem.LoadAssetFile(ResName, isStreamScene, OnAssetFileLoad); }
public static Shader Load(string path) { if (CacheShaders.ContainsKey(path) == false) { Shader s = null; if (s == null) { s = AssetSystem.LoadAssetSync(path) as Shader; } if (s == null) { s = AssetBundleManager.GetShader(path); } CacheShaders[path] = s; return(s); } else { Shader s = CacheShaders[path] as Shader; return(s); } }
static (MockFileSystem disk, string baseDir, GeneralConfig generalConfig, AssetMapping mapping) SetupAssets(IJsonUtil jsonUtil) { Event.AddEventsFromAssembly(typeof(ActionEvent).Assembly); var mapping = new AssetMapping(); var disk = new MockFileSystem(true); var baseDir = ConfigUtil.FindBasePath(disk); var assetConfigPath = Path.Combine(baseDir, "mods", "Base", "assets.json"); var assetConfig = AssetConfig.Load(assetConfigPath, mapping, disk, jsonUtil); var generalConfig = AssetSystem.LoadGeneralConfig(baseDir, disk, jsonUtil); foreach (var assetType in assetConfig.IdTypes.Values) { var enumType = Type.GetType(assetType.EnumType); if (enumType == null) { throw new InvalidOperationException( $"Could not load enum type \"{assetType.EnumType}\" defined in \"{assetConfigPath}\""); } mapping.RegisterAssetType(assetType.EnumType, assetType.AssetType); } return(disk, baseDir, generalConfig, mapping); }
private void FilterInfos() { // 回收引用 ReferencePool.Release(_cacheInfos); // 清空列表 _cacheInfos.Clear(); // 绘制显示列表 var fileLoaders = AssetSystem.GetAllLoaders(); _loaderTotalCount = fileLoaders.Count; foreach (var loader in fileLoaders) { // 只搜索关键字 if (string.IsNullOrEmpty(_filterKey) == false) { if (loader.BundleInfo.ManifestPath.Contains(_filterKey) == false) { continue; } } string info = $"资源名称:{loader.BundleInfo.ManifestPath} 资源版本:{loader.BundleInfo.Version} 引用计数:{loader.RefCount}"; InfoWrapper element = ReferencePool.Spawn <InfoWrapper>(); element.Info = info; element.LoadState = loader.States; element.ProviderFailedCount = loader.GetFailedProviderCount(); // 添加到显示列表 _cacheInfos.Add(element); } // 重新排序 _cacheInfos.Sort(); }
public static void Main(string[] args) { OpenTKWindow window = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (OpenTKWindow) new DedicatedThreadWindow() : new SameThreadWindow(); window.Title = "ge.Main"; window.Visible = true; Game game = new Game(); GraphicsSystem gs = new GraphicsSystem(window); game.SystemRegistry.Register(gs); gs.AddFreeRenderItem(new ShadowMapPreview(gs.Context)); InputSystem inputSystem = new InputSystem(window); inputSystem.RegisterCallback((input) => { if (input.GetKeyDown(Key.F4) && (input.GetKey(Key.AltLeft) || input.GetKey(Key.AltRight))) { game.Exit(); } if (input.GetKeyDown(Key.F11)) { window.WindowState = window.WindowState == WindowState.Normal ? WindowState.FullScreen : WindowState.Normal; } if (input.GetKeyDown(Key.F12)) { gs.ToggleOctreeVisualizer(); } }); game.SystemRegistry.Register(inputSystem); ImGuiRenderer imGuiRenderer = new ImGuiRenderer(gs.Context, window.NativeWindow, inputSystem); gs.AddFreeRenderItem(imGuiRenderer); ImGuiNET.ImGui.GetIO().FontAllowUserScaling = true; AssetSystem assetSystem = new AssetSystem(Path.Combine(AppContext.BaseDirectory, "Assets")); game.SystemRegistry.Register(assetSystem); BehaviorUpdateSystem bus = new BehaviorUpdateSystem(game.SystemRegistry); game.SystemRegistry.Register(bus); bus.Register(imGuiRenderer); PhysicsSystem ps = new PhysicsSystem(); game.SystemRegistry.Register(ps); ScoreSystem ss = new ScoreSystem(); game.SystemRegistry.Register(ss); ConsoleCommandSystem ccs = new ConsoleCommandSystem(game.SystemRegistry); game.SystemRegistry.Register(ccs); window.Closed += game.Exit; LooseFileDatabase db = new LooseFileDatabase(AppContext.BaseDirectory); AddBinGameScene(); SceneAsset scene = new SceneAsset(); var goqs = game.SystemRegistry.GetSystem <GameObjectQuerySystem>(); scene.GameObjects = goqs.GetAllGameObjects().Select(go => new SerializedGameObject(go)).ToArray(); db.SaveDefinition(scene, "BINSCENE.scene"); //var scene = db.LoadAsset<SceneAsset>("BINSCENE.scene_New"); //scene.GenerateGameObjects(); game.RunMainLoop(); }
static void Main(string[] args) { #if DEBUG PerfTracker.IsTracing = true; #endif PerfTracker.StartupEvent("Entered main"); AssetSystem.LoadEvents(); PerfTracker.StartupEvent("Built event parsers"); var commandLine = new CommandLineOptions(args); if (commandLine.Mode == ExecutionMode.Exit) { return; } PerfTracker.StartupEvent($"Running as {commandLine.Mode}"); var disk = new FileSystem(); var jsonUtil = new FormatJsonUtil(); var baseDir = ConfigUtil.FindBasePath(disk); if (baseDir == null) { throw new InvalidOperationException("No base directory could be found."); } PerfTracker.StartupEvent($"Found base directory {baseDir}"); if (commandLine.Mode == ExecutionMode.ConvertAssets) { using var converter = new AssetConverter( AssetMapping.Global, disk, jsonUtil, commandLine.ConvertFrom, commandLine.ConvertTo); converter.Convert( commandLine.DumpIds, commandLine.DumpAssetTypes, commandLine.ConvertFilePattern); return; } var(exchange, services) = AssetSystem.SetupAsync(baseDir, AssetMapping.Global, disk, jsonUtil).Result; IRenderPass mainPass = null; if (commandLine.NeedsEngine) { mainPass = BuildEngine(commandLine, exchange); } services.Add(new StdioConsoleReader()); var assets = exchange.Resolve <IAssetManager>(); AutodetectLanguage(exchange, assets); switch (commandLine.Mode) // ConvertAssets handled above as it requires a specialised asset system setup { case ExecutionMode.Game: Albion.RunGame(exchange, services, mainPass, baseDir, commandLine); break; case ExecutionMode.BakeIsometric: IsometricTest.Run(exchange, commandLine); break; case ExecutionMode.DumpData: PerfTracker.BeginFrame(); // Don't need to show verbose startup logging while dumping var tf = new TextFormatter(); exchange.Attach(tf); var parsedIds = commandLine.DumpIds?.Select(AssetId.Parse).ToArray(); if ((commandLine.DumpFormats & DumpFormats.Json) != 0) { var dumper = new DumpJson(); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } if ((commandLine.DumpFormats & DumpFormats.Text) != 0) { var dumper = new DumpText(); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } if ((commandLine.DumpFormats & DumpFormats.Png) != 0) { var dumper = new DumpGraphics(commandLine.DumpFormats); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } if ((commandLine.DumpFormats & DumpFormats.Annotated) != 0) { var dumper = new DumpAnnotated(); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } //if ((commandLine.DumpFormats & DumpFormats.Tiled) != 0) // DumpTiled.Dump(baseDir, assets, commandLine.DumpAssetTypes, parsedIds); break; case ExecutionMode.Exit: break; } Console.WriteLine("Exiting"); exchange.Dispose(); }