找回密碼
 注冊帳號

掃一掃,訪問微社區

assetdatabase.createasset 新建資源

2014-12-31 20:01| 發布者: 楊炎| 查看: 2018| 評論: 0|原作者: 蠻牛|來自: unity3d腳本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));

}

相關閱讀

文章點評
相關文章
女校游泳队彩金