Fixed asset creation broken logic loop

This commit is contained in:
Xiao Qi 2022-11-01 00:44:37 +08:00
parent 7ed5279f8c
commit 220e1a7d8b
2 changed files with 13 additions and 0 deletions

View File

@ -11,6 +11,10 @@
#pragma once
#include "SHAssetLoader.h"
#include "Assets/Asset Types/SHPrefabAsset.h"
#include "Assets/Asset Types/SHSceneAsset.h"
#include "Assets/Asset Types/SHMaterialAsset.h"
namespace SHADE
{
struct SHTextBasedLoader : SHAssetLoader

View File

@ -151,19 +151,26 @@ namespace SHADE
****************************************************************************/
AssetID SHAssetManager::CreateNewAsset(AssetType type, AssetName name) noexcept
{
SHAssetData* data = nullptr;
std::string newPath{ ASSET_ROOT };
switch (type)
{
case AssetType::PREFAB:
newPath += PREFAB_FOLDER;
auto prefab = new SHPrefabAsset();
data = prefab;
break;
case AssetType::SCENE:
newPath += SCENE_FOLDER;
auto scene = new SHSceneAsset();
data = scene;
break;
case AssetType::MATERIAL:
newPath += MATERIAL_FOLDER;
auto material = new SHMaterialAsset();
data = material;
break;
default:
@ -189,6 +196,8 @@ namespace SHADE
)
});
assetData.emplace(id, data);
return id;
}