private Resources() { resourceManagers = new Dictionary <Type, ResourceManager>(); Type type = new GameObject().GetType(); LoaderGameObject loaderGO = new LoaderGameObject(type); resourceManagers.Add(type, new ResourceManager("Assets/Objects", type, loaderGO)); type = new ModelWrapper().GetType(); LoaderModel loaderM = new LoaderModel(type); resourceManagers.Add(type, new ResourceManager("Assets/Models", type, loaderM)); type = new Font().GetType(); LoaderFont loaderF = new LoaderFont(type); resourceManagers.Add(type, new ResourceManager("Assets/Fonts", type, loaderF)); type = new Sprite().GetType(); LoaderSprite loaderS = new LoaderSprite(type); resourceManagers.Add(type, new ResourceManager("Assets/Textures", type, loaderS)); type = new RenderTarget2DWrapper().GetType(); resourceManager_renderTarget2D = new ResourceManager("Assets/Shaders", type, null); resourceManagers.Add(type, resourceManager_renderTarget2D); type = new Material().GetType(); LoaderMaterial loaderE = new LoaderMaterial(type); resourceManagers.Add(type, new ResourceManager("Assets/Shaders", type, loaderE)); }
public static RenderTarget2DWrapper LoadRenderTarget2D(string name, Scene parent, int width, int height, bool mipMap, SurfaceFormat surfaceFormat, DepthFormat depthFormat, int multiSampleCount, RenderTargetUsage usage, RenderTargetSettings settings) { RenderTarget2DWrapper target = new RenderTarget2DWrapper(new RenderTarget2D(GraphicsHelper.graphicsDevice, width, height, mipMap, surfaceFormat, depthFormat, multiSampleCount, usage)); ResourceManager manager = instance.resourceManagers[target.GetType()]; if (manager.ContainsResource(name)) { if (target != manager.GetResource(name)) { throw new AssetExceptions.AssetAlreadyExists("Cannot resolve difference between existing RenderTarget2D and new RenderTarget2D\nExisting RenderTarget2D: " + instance.resourceManager_renderTarget2D.GetResource(name) + "\nNew RenderTarget2D" + target); } } else { manager.AddResource(name, target); RenderTargetBatch batch = new RenderTargetBatch(name, target, settings); RenderManager.AddRenderTargetBatch(batch); return(target); } RenderTarget2DWrapper wrapper = manager.GetResource(name) as RenderTarget2DWrapper; Type type = wrapper.GetType(); if (parent != null) { parent.assets.AddAsset(name, type); } else { // TODO: Log a warning that unbound assets will not unload when a scene switch occurs } return(wrapper); }