AssetDB

Editor.assetdb

remote

Editor.remote.assetdb

library

The library path

explore

Reveal given url in native file system Parameters

  • url **

    exploreLib

    Reveal given url’s library file in native file system Parameters
  • url **

    queryPathByUrl

    Get native file path by url Parameters
  • url **
  • cb ** The callback function
  • cb.path **

    queryUuidByUrl

    Get uuid by url Parameters
  • url **
  • cb ** The callback function
  • cb.path **

    queryPathByUuid

    Get native file path by uuid Parameters
  • uuid **
  • cb ** The callback function
  • cb.path **

    queryUrlByUuid

    Get asset url by uuid Parameters
  • uuid **
  • cb ** The callback function
  • cb.url **

    queryInfoByUuid

    Get asset info by uuid Parameters
  • uuid **
  • cb ** The callback function
  • cb.info ** Examples**
    1. ```js Editor.assetdb.queryInfoByUuid( uuid, function ( err, info ) { // info.path // info.url // info.type });
    ```

    queryMetaInfoByUuid

    Get meta info by uuid Parameters
  • uuid **
  • cb ** The callback function
  • cb.info ** Examples**
    1. ```js Editor.assetdb.queryMetaInfoByUuid( uuid, function ( err, info ) { // info.assetPath // info.metaPath // info.assetMtime // info.metaMtime // info.json });
    ```

    deepQuery

    Query all assets from asset-db Parameters
  • cb ** The callback function
  • cb.results ** Examples**
    1. ```js Editor.assetdb.deepQuery(function ( results ) { results.forEach(function ( result ) { // result.name // result.extname // result.uuid // result.type // result.children - the array of children result }); });
    ```

    queryAssets

    Query assets by url pattern and asset-type Parameters
  • pattern ** The url pattern
  • type ** The asset type
  • cb ** The callback function
  • cb.results **
  • url
  • assetType Examples
    1. ```js Editor.assetdb.queryAssets( 'db://assets/**\/*', 'texture', function ( results ) { results.forEach(function ( result ) { // result.url // result.path // result.uuid // result.type }); });
    ```

    import

    The import result will be sent through ipc message asset-db:assets-created Parameters
  • rawfiles ** Rawfile path list
  • destUrl ** The url of dest folder
  • showProgress ** Show progress or not
  • cb ** The callbak function Examples**
    1. ```js Editor.assetdb.import( [ '/file/to/import/01.png', '/file/to/import/02.png', '/file/to/import/03.png', ], 'db://assets/foobar' );
    ```

    create

    The created result will be sent through by ipc message asset-db:assets-created Parameters
  • url **
  • data **
  • cb ** Examples**
    1. ```js Editor.assetdb.create( 'db://assets/foo/bar/foobar.js', 'var foobar = 0;');
    ```

    move

    The moved result will be sent through by ipc message asset-db:assets-moved Parameters
  • srcUrl **
  • destUrl **
  • showMessageBox Examples
    1. ```js Editor.assetdb.move( 'db://assets/foo/bar/foobar.js', 'db://assets/foo/bar/foobar02.js');
    ```

    delete

    The deleted results will be sent through by ipc message asset-db:assets-deleted Parameters
  • urls ** Examples**
    1. ```js Editor.assetdb.delete([ 'db://assets/foo/bar/foobar.js', 'db://assets/foo/bar/foobar02.js', ]);
    ```

    saveExists

    The saved results will be sent through by ipc message asset-db:asset-changed Parameters
  • url **
  • data **
  • cb ** the callback function Examples**
    1. ```js Editor.assetdb.saveExists( 'db://assets/foo/bar/foobar.js', 'var foobar = 0;');
    ```

    createOrSave

    If the url is already existed, it will be changed with new data. The behavior is same with method saveExists. Otherwise, a new asset will be created. The behavior is same with method create Parameters
  • url **
  • data **
  • cb ** the callback function Examples**
    1. ```js Editor.assetdb.createOrSave( 'db://assets/foo/bar/foobar.js', 'var foobar = 0;');
    ```

    saveMeta

    The saved results will be sent through by ipc message asset-db:asset-changed Parameters
  • uuid **
  • metaJson **
  • cb ** the callback function Examples**
    1. ```js Editor.assetdb.saveMeta( meta.uuid, JSON.stringify(meta, null, 2));
    ```

    refresh

    Refresh the assets in url, and return the results Parameters
  • url **
  • cb ** Examples**
    1. ```js Editor.assetdb.refresh('db://assets/foo/bar/', function (err, results) { // assets that imported during init results.forEach(function ( result ) { if ( result.command === 'delete' ) { // result.uuid // result.url // result.path // result.type } else if ( result.command === 'change' || result.command === 'create' ) { // result.uuid // result.parentUuid // result.url // result.path // result.type } else if ( result.command === 'uuid-change' ) { // result.oldUuid // result.uuid // result.parentUuid // result.url // result.path // result.type } }); });
    ```

    Editor

    assetdb

    The AssetDB instance