assetdatabase.createasset 新建资源

2014-12-31 20:01| 发布者: 杨炎| 查看: 1836| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本manual

摘要: assetdatabase.createasset 新建资源static functioncreateasset(asset:object,path: string) : voiddescription描述creates a new asset at path.在指定的路径新建资源。you must ensure that the path uses a supp ...

assetdatabase.createasset 新建资源

static functioncreateasset(asset:object,path: string) : void

description描述

creates a new asset at path.

在指定的路径新建资源。

you must ensure that the path uses a supported extension ('.mat' for materials, '.cubemap' for cubemaps, '.guiskin' for skins, '.anim' for animations and '.asset' for arbitrary other assets.)

你必须保证使用的路径是一个被支持的扩展('.mat' 代表 materials, '.cubemap' 代表 cubemaps, '.guiskin' 代表 skins, '.anim' 代表 animations and '.asset' 代表任意其他的资源文件。)

you can add more assets to the file usingassetdatabase.addobjecttoassetafter the asset has been created. if an asset already exists at path it will be deleted prior to creating a new asset. all paths are relative to the project folder. like: "assets/mytextures/hello.png"

当资源被创建后,你可以使用assetdatabase.addobjecttoasset把更多的资源添加到文件。如果资源已经存在于指定路径,那么这将会删除原有的资源并新建。所有的路径都是相对于工程目录文件。例如” assets/mytextures/hello.png”。

@menuitem("gameobject/creatematerial")

static function creatematerial () {

// create a simple material asset

//新建一个简单的材质资源

var material = new material (shader.find("specular"));

assetdatabase.createasset(material, "assets/mymaterial.mat");

// print the path of the created asset

//打印新建资源的路径

debug.log(assetdatabase.getassetpath(material));

}

相关阅读

文章点评
相关文章