Beispiel #1
0
bool Asset::SetPath(const String& path)
{

    assert(!guid_.Length());
    assert(!path_.Length());

    // need to update path, not set, which should only be done on first import
    assert(importer_.Null());

    FileSystem* fs = GetSubsystem<FileSystem>();
    AssetDatabase* db = GetSubsystem<AssetDatabase>();

    path_ = path;

    // create importer based on path
    if (!CreateImporter())
        return false;

    String assetFilename = GetDotAssetFilename();

    if (fs->FileExists(assetFilename))
    {
        // load the json, todo: handle fail
        Load();
    }
    else
    {
        dirty_ = true;
        guid_ = db->GenerateAssetGUID();

        Save();
    }

    // TODO: handle failed

    return true;

}