本文整理汇总了C++中Asset::GetImporter方法的典型用法代码示例。如果您正苦于以下问题:C++ Asset::GetImporter方法的具体用法?C++ Asset::GetImporter怎么用?C++ Asset::GetImporter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::GetImporter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportAnimations
bool ModelImporter::ImportAnimations()
{
if (!animationInfo_.Size())
{
if (!ImportAnimation(asset_->GetPath(), "RootAnim"))
return false;
}
// embedded animations
for (unsigned i = 0; i < animationInfo_.Size(); i++)
{
const SharedPtr<AnimationImportInfo>& info = animationInfo_[i];
if (!ImportAnimation(asset_->GetPath(), info->GetName(), info->GetStartTime(), info->GetEndTime()))
return false;
}
// add @ animations
FileSystem* fs = GetSubsystem<FileSystem>();
String pathName, fileName, ext;
SplitPath(asset_->GetPath(), pathName, fileName, ext);
Vector<String> results;
fs->ScanDir(results, pathName, ext, SCAN_FILES, false);
for (unsigned i = 0; i < results.Size(); i++)
{
const String& result = results[i];
if (result.Contains("@"))
{
Vector<String> components = GetFileName(result).Split('@');
if (components.Size() == 2 && components[1].Length() && components[0] == fileName)
{
String animationName = components[1];
AssetDatabase* db = GetSubsystem<AssetDatabase>();
Asset* asset = db->GetAssetByPath(pathName + result);
assert(asset);
assert(asset->GetImporter()->GetType() == ModelImporter::GetTypeStatic());
ModelImporter* importer = (ModelImporter*) asset->GetImporter();
if (!importer->animationInfo_.Size())
{
if (!ImportAnimation(asset->GetPath(), animationName))
return false;
}
else
{
// embedded animations
for (unsigned i = 0; i < importer->animationInfo_.Size(); i++)
{
const SharedPtr<AnimationImportInfo>& info = importer->animationInfo_[i];
if (!ImportAnimation(asset->GetPath(), info->GetName(), info->GetStartTime(), info->GetEndTime()))
return false;
}
}
}
}
}
return true;
}
示例2: if
void SceneView3D::HandleDragEnterWidget(StringHash eventType, VariantMap& eventData)
{
using namespace DragEnterWidget;
UIWidget* widget = static_cast<UIWidget*>(eventData[P_WIDGET].GetPtr());
if (widget != this)
return;
UIDragObject* dragObject = static_cast<UIDragObject*>(eventData[P_DRAGOBJECT].GetPtr());
Object* object = dragObject->GetObject();
if (!object)
return;
if (object->GetType() == Asset::GetTypeStatic())
{
Asset* asset = (Asset*) object;
AssetImporter* importer = asset->GetImporter();
if (!importer)
return;
StringHash importerType = importer->GetType();
if (importerType == PrefabImporter::GetTypeStatic())
{
dragNode_ = scene_->CreateChild(asset->GetName());
PrefabComponent* pc = dragNode_->CreateComponent<PrefabComponent>();
pc->SetPrefabGUID(asset->GetGUID());
}
else if (importerType == ModelImporter::GetTypeNameStatic())
{
dragNode_ = scene_->CreateChild();
SharedPtr<File> file(new File(context_, asset->GetCachePath()));
SharedPtr<XMLFile> xml(new XMLFile(context_));
if (!xml->Load(*file))
return;
dragNode_->LoadXML(xml->GetRoot());
dragNode_->SetName(asset->GetName());
}
else if (importerType == SpriterImporter::GetTypeNameStatic())
{
AnimationSet2D* animationSet = GetSubsystem<ResourceCache>()->GetResource<AnimationSet2D>(asset->GetPath());
String animationName;
if (animationSet && animationSet->GetNumAnimations())
{
animationName = animationSet->GetAnimation(0)->GetName();
}
dragNode_ = scene_->CreateChild(asset->GetName());
AnimatedSprite2D* sprite = dragNode_->CreateComponent<AnimatedSprite2D>();
if (!animationName.Length())
sprite->SetAnimationSet(animationSet);
else
sprite->SetAnimation(animationSet, animationName);
}
else if (importerType == TextureImporter::GetTypeNameStatic())
{
dragNode_ = scene_->CreateChild(asset->GetName());
Sprite2D* spriteGraphic = GetSubsystem<ResourceCache>()->GetResource<Sprite2D>(asset->GetPath());
StaticSprite2D* sprite = dragNode_->CreateComponent<StaticSprite2D>();
sprite->SetSprite(spriteGraphic);
}
if (dragNode_.NotNull())
{
Input* input = GetSubsystem<Input>();
IntVector2 pos = input->GetMousePosition();
UpdateDragNode(pos.x_, pos.y_);
}
//LOGINFOF("Dropped %s : %s on SceneView3D", asset->GetPath().CString(), asset->GetGUID().CString());
}
}