Get AssetId of Dynamic Slice

0

Hello!

I'm having problem getting an assetId back from the AssetCatalogRequestBus:


AZ::Data::AssetId defaultSliceAssetId;
AZ::Data::Asset<AZ::DynamicPrefabAsset>	defaultSliceAsset;
EBUS_EVENT_RESULT(defaultSliceAssetId, AZ::Data::AssetCatalogRequestBus, GetAssetIdByPath, "slices/defaultcharacter.dynamicslice", AZ::AzTypeInfo<AZ::DynamicPrefabAsset>::Uuid(), false);
if (defaultSliceAssetId.IsValid())
{
defaultSliceAsset.Create(defaultSliceAssetId, true);
EBUS_EVENT_ID(GetEntityId(), SpawnDirectorBus, SetDefaultAsset, defaultSliceAsset);
}
AZ_Assert(defaultSliceAssetId.IsValid(), "**Character Manager** defaultSliceAssetId is invalid.");

I have "slices/defaultcharacter.slice" in the main asset directory. And "slices/defaultcharacter.dynamicslice" is generated in the Cache directory by the Asset Processor.

I feel like I've gone through every permutation, trying different things. I've run out of ideas.

Does anyone have a code snippet they can share; or know what the problem is?

asked 7 years ago172 views
5 Answers
0
Accepted Answer

Moved above code out of a system component. Instead I'm sending an Init EBUS_EVENT from GameStartup. It was trying to find assets too soon; and I couldn't find a suitable "RequiredServices" component to order my system component after. It works now.

answered 7 years ago
0

"Should the asset processor be creating a dynamic slice in the main asset folder as well?" How i know no *.dinamicslice created only in cache folder. But you can try use spawner component in editor to spawn your dynamiclslice. Create it hands and see whats happening.

answered 7 years ago
0

I've tried autoRegisterIfNotFound and didn't work.

It get's through AZ::Data::AssetRegistry::GetAssetIdByPath

auto entry = m_assetPathToId.find(CreateUUIDForName(assetPath));

...and just doesn't find it in m_assetPathToId.

REMOVEDUPLOAD

REMOVEDUPLOAD

I'm not sure what else I can try. Should the asset processor be creating a dynamic slice in the main asset folder as well?

answered 7 years ago
0

Hi Kyai all looking good. You shore is file path correct ? And try set true (registers the asset if not already in the catalog.)

GetAssetIdByPath, "slices/defaultcharacter.dynamicslice", AZ::AzTypeInfo<AZ::DynamicPrefabAsset>::Uuid(), true);

p.s.

This is from my code, not dynamical asset, but pipeline is similar.

	AZ::Data::AssetId meshAssetId;
const string meshName = "objects/cube.cgf";
EBUS_EVENT_RESULT(meshAssetId, AZ::Data::AssetCatalogRequestBus, GetAssetIdByPath, meshName, AZ::AzTypeInfo<AZ::Data::AssetData>::Uuid(), true);
if (meshAssetId.IsValid())
{
// assign a the mesh asset (.cgf)
EBUS_EVENT_ID(m_voxelBrushShapeEntity->GetId(), LmbrCentral::MeshComponentRequestBus, SetMeshAsset, meshAssetId);
}
answered 7 years ago
0

@REDACTEDUSER

	static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("AssetDatabaseService", 0x3abf5601));
required.push_back(AZ_CRC("AssetCatalogService", 0xc68ffc57));
required.push_back(AZ_CRC("AssetProcessorConnection", 0xf0cd75cd));
}

But that didn't work either.

Edit: I'm going to try moving this Entity out of the system component; and load it after the core game stuff. We'll see if it's actually getting enough time to load assets into the database. To be fair, even with the "required" system components registered, this is error-ing out super early on load.

answered 7 years ago

This post is closed: Adding new answers, comments, and votes is disabled.