More asset handles

This commit is contained in:
Simon Lübeß
2023-03-13 20:35:36 +01:00
parent c22d122921
commit c3fb9bbd5d
11 changed files with 97 additions and 75 deletions
@@ -268,10 +268,7 @@ namespace GlitchyEditor.EditWindows
StringView path = .((char8*)payload.Data, (int)payload.DataSize);
using (Texture2D texture = Content.LoadAsset<Texture2D>(path))
{
spriteRendererComponent.Sprite = texture;
}
spriteRendererComponent.Sprite = Content.LoadAsset(path);
}
ImGui.EndDragDropTarget();
@@ -301,10 +298,7 @@ namespace GlitchyEditor.EditWindows
{
StringView fullpath = .((char8*)payload.Data, (int)payload.DataSize);
using (Material loadedMaterial = Content.LoadAsset<Material>(fullpath))
{
meshRendererComponent.Material = loadedMaterial;
}
meshRendererComponent.Material = Content.LoadAsset(fullpath);
}
ImGui.EndDragDropTarget();
@@ -488,10 +482,7 @@ namespace GlitchyEditor.EditWindows
StringView filePath = fullpath.Substring(0, idx);
StringView meshName = fullpath.Substring(idx + 1);*/
using (GeometryBinding geometry = Content.LoadAsset<GeometryBinding>(fullpath))
{
meshComponent.Mesh = geometry;
}
meshComponent.Mesh = Content.LoadAsset(fullpath);
// TODO: support multiple primitives (treat every primitive as a single mesh? or: mesh can have multiple primitives)
/*using (GeometryBinding binding = ModelLoader.LoadMesh(filePath, meshName, 0))
@@ -18,7 +18,8 @@ class PropertiesWindow : EditorWindow
private append String _selectedFileName = .();
private Asset _currentAsset ~ _?.ReleaseRef();
private AssetHandle _currentAssetHandle;
private Asset _currentAsset;
public this(Editor editor)
{
@@ -78,7 +79,8 @@ class PropertiesWindow : EditorWindow
if (_currentAsset?.Identifier != assetFile.Identifier)
{
_currentAsset?.ReleaseRef();
_currentAsset = _editor.ContentManager.LoadAsset(assetFile.Identifier);
_currentAssetHandle = _editor.ContentManager.LoadAsset(assetFile.Identifier);
_currentAsset = _editor.ContentManager.GetAsset(null, _currentAssetHandle);
}
// TODO: allow changing AssetLoader