Skip to content

Commit

Permalink
Merge pull request cocos#644 from xunyi0/master
Browse files Browse the repository at this point in the history
修正管理项目资源的保存当前场景部分
  • Loading branch information
jareguo authored Oct 10, 2018
2 parents 3405f20 + ba76a89 commit 7f6a2dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
22 changes: 13 additions & 9 deletions en/extension/asset-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@

## Manage the scene

### Save the current scene
### New scene

you can use the `Editor.Ipc` module to create the new scene:

In the previous section [Calling Engine APIs and Project Scripts] (scene-script.md), we introduced the method of accessing the engine API and the user project script through the scenario script. After modifying the scene data, you can use the following interface to save the current scene The
`Editor.Ipc.sendToPanel('scene', 'scene:new-scene');`

`_Scene.save ()`
### Save the current scene

Where `_Scene` is a special singleton that controls the scene instance loaded in the scene editor.
After modifying the scene data, you can use the `Editor.Ipc` module to save the current scene:

`Editor.Ipc.sendToPanel('scene', 'scene:stash-and-save');`

### Load other scenes

Our expansion packs may need to traverse multiple scenes and operate and save them sequentially. To load a new scene, use
Our expansion packs may need to traverse multiple scenes and operate and save them sequentially. In the previous section [Call the engine API and project script](scene-script.md), we introduced the method of accessing the engine API and the user project script through the scenario script. To load a new scene, use:

```js
_Scene.loadSceneByUuid (uuid, function (error) {
    // do more work
});
```

Where _Scene is a special singleton that controls the scene instance loaded in the scene editor.<br>
The incoming parameter is the uuid of the scene asset, which can be obtained by the asset manager interface described below.


## Mapping of asset URL and UUID

In the Cocos Creator editor and extension, the url of the asset is shaped
Expand Down Expand Up @@ -67,7 +71,7 @@ Editor.assetdb.import ([

### Create an asset

A common misuse of using extended package management assets is to use the [fs module] of the Node.js (https://nodejs.org/dist/latest-v6.x/docs/api) when the extension package needs to create new assets /fs.html), so that even if the creation of the file to the `assets` directory, it can not be automatically imported by the Explorer. The correct workflow should use the `create` interface to create the asset.
A common misuse of using extended package management assets is to use the [fs module](https://nodejs.org/dist/latest-v6.x/docs/api/fs.html) of the Node.js when the extension package needs to create new assets, so that even if the creation of the file to the `assets` directory, it can not be automatically imported by the Explorer. The correct workflow should use the `create` interface to create the asset.

```js
// main process or renderer process
Expand Down Expand Up @@ -111,7 +115,7 @@ Editor.assetdb.createOrSave ('db: //assets/foo/bar/foobar.js', data, callback);

### Refresh the asset

When the asset file has been modified in the `asset` and there is no reintroduction for some reason, the asset data in the` asset` and the asset data displayed in the database are inconsistent (if the `fs` module Direct operation of the contents of the file will appear), you can manually call the asset refresh interface to re-import assets
When the asset file has been modified in the `asset` and there is no reintroduction for some reason, the asset data in the` asset` and the asset data displayed in the database are inconsistent (if the `fs` module direct operation of the contents of the file will appear), you can manually call the asset refresh interface to re-import assets

```js
// main process or renderer process
Expand All @@ -127,4 +131,4 @@ Editor.assetdb.move (srcUrl, destUrl);
Editor.assetdb.delete ([url1, url2]);
```

For more information on these interfaces, see [AssetDB API Main] (api / asset-db / asset-db-main.md) and [AssetDB API Renderer] (api / asset-db / asset-db-renderer.md).
For more information on these interfaces, see [AssetDB API Main](api/asset-db/asset-db-main.md) and [AssetDB API Renderer](api/asset-db/asset-db-renderer.md).
16 changes: 10 additions & 6 deletions zh/extension/asset-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@

## 管理场景

### 保存当前场景
### 新建场景

通过 `Editor.Ipc` 模块新建场景:

在上一节 [调用引擎 API 和项目脚本](scene-script.md) 中我们介绍了通过场景脚本访问引擎 API 和用户项目脚本的方法,在对场景数据进行修改后可以使用以下接口保存当前场景。
`Editor.Ipc.sendToPanel('scene', 'scene:new-scene');`

`_Scene.save()`
### 保存当前场景

其中 `_Scene` 是一个特殊的单例,用来控制场景编辑器里加载的场景实例。
对场景数据修改完成后可以通过 `Editor.Ipc` 模块来保存当前场景:

`Editor.Ipc.sendToPanel('scene', 'scene:stash-and-save');`

### 加载其他场景

我们的扩展包可能需要遍历多个场景并依次操作和保存,要加载新场景,请使用
我们的扩展包可能需要遍历多个场景并依次操作和保存,在上一节 [调用引擎 API 和项目脚本](scene-script.md) 中我们介绍了通过场景脚本访问引擎 API 和用户项目脚本的方法,要加载新场景,请使用

```js
_Scene.loadSceneByUuid(uuid, function(error) {
//do more work
});
```

其中 _Scene 是一个特殊的单例,用来控制场景编辑器里加载的场景实例。<br>
传入的参数是场景资源的 uuid,可以通过下面介绍的资源管理器接口来获取。


## 资源 URL 和 UUID 的映射

在 Cocos Creator 编辑器和扩展中,资源的 url 由形如
Expand Down

0 comments on commit 7f6a2dc

Please sign in to comment.