本文整理汇总了C++中AssetPtr::IsLoaded方法的典型用法代码示例。如果您正苦于以下问题:C++ AssetPtr::IsLoaded方法的具体用法?C++ AssetPtr::IsLoaded怎么用?C++ AssetPtr::IsLoaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetPtr
的用法示例。
在下文中一共展示了AssetPtr::IsLoaded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetScriptAsset
void OgreScriptEditor::SetScriptAsset(const AssetPtr &scriptAsset)
{
asset = scriptAsset;
assert(asset.lock());
AssetPtr assetPtr = asset.lock();
if (!assetPtr)
LogError("OgreScriptEditor: null asset given.");
if (assetPtr->Type() != "OgreMaterial" && assetPtr->Type() != "OgreParticle")
LogWarning("Created OgreScriptEditor for non-supported asset type " + assetPtr->Type() + ".");
lineEditName->setText((assetPtr?assetPtr->Name():QString()));
setWindowTitle(tr("OGRE Script Editor:") + (assetPtr?assetPtr->Name():QString()));
if (assetPtr && !assetPtr->IsLoaded())
{
AssetTransferPtr transfer = framework->Asset()->RequestAsset(assetPtr->Name(), assetPtr->Type(), true);
connect(transfer.get(), SIGNAL(Succeeded(AssetPtr)), this, SLOT(OnAssetTransferSucceeded(AssetPtr)));
connect(transfer.get(), SIGNAL(Failed(IAssetTransfer *, QString)), SLOT(OnAssetTransferFailed(IAssetTransfer *, QString)));
}
示例2: HandleAssetRefChange
void AssetRefListener::HandleAssetRefChange(AssetAPI *assetApi, String assetRef, const String& assetType)
{
// Disconnect from any previous transfer we might be listening to
if (!currentTransfer.Expired())
{
IAssetTransfer* current = currentTransfer.Get();
current->Succeeded.Disconnect(this, &AssetRefListener::OnTransferSucceeded);
current->Failed.Disconnect(this, &AssetRefListener::OnTransferFailed);
currentTransfer.Reset();
}
assert(assetApi);
// Store AssetAPI ptr for later signal hooking.
if (!myAssetAPI)
myAssetAPI = assetApi;
// If the ref is empty, don't go any further as it will just trigger the LogWarning below.
assetRef = assetRef.Trimmed();
if (assetRef.Empty())
{
asset = AssetPtr();
return;
}
currentWaitingRef = "";
// Resolve the protocol for generated:// assets. These assets are never meant to be
// requested from AssetAPI, they cannot be fetched from anywhere. They can only be either
// loaded or we must wait for something to load/create them.
String protocolPart = "";
assetApi->ParseAssetRef(assetRef, &protocolPart);
if (protocolPart.ToLower() == "generated")
{
AssetPtr loadedAsset = assetApi->FindAsset(assetRef);
if (loadedAsset.Get() && loadedAsset->IsLoaded())
{
// Asset is loaded, emit Loaded with 1 msec delay to preserve the logic
// that HandleAssetRefChange won't emit anything itself as before.
// Otherwise existing connection can break/be too late after calling this function.
asset = loadedAsset;
assetApi->GetFramework()->Frame()->DelayedExecute(0.0f).Connect(this, &AssetRefListener::EmitLoaded);
return;
}
else
{
// Wait for it to be created.
currentWaitingRef = assetRef;
myAssetAPI->AssetCreated.Connect(this, &AssetRefListener::OnAssetCreated);
}
}
else
{
// This is not a generated asset, request normally from asset api.
AssetTransferPtr transfer = assetApi->RequestAsset(assetRef, assetType);
if (!transfer)
{
LogWarning("AssetRefListener::HandleAssetRefChange: Asset request for asset \"" + assetRef + "\" failed.");
return;
}
currentWaitingRef = assetRef;
transfer->Succeeded.Connect(this, &AssetRefListener::OnTransferSucceeded);
transfer->Failed.Connect(this, &AssetRefListener::OnTransferFailed);
currentTransfer = transfer;
}
// Disconnect from the old asset's load signal
if (asset)
asset->Loaded.Disconnect(this, &AssetRefListener::OnAssetLoaded);
asset = AssetPtr();
}