Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
AssetDatabase.CreateAsset 新建资源
# [AssetDatabase](AssetDatabase.html).CreateAsset 新建资源 static function *CreateAsset* (*asset* : [Object](../Object/Object.html), *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 using [AssetDatabase.AddObjectToAsset](AssetDatabase.AddObjectToAsset.html) after 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](http://unity3d.com/support/documentation/ScriptReference/AssetDatabase.AddObjectToAsset.html) 把更多的资源添加到文件。如果资源已经存在于指定路径,那么这将会删除原有的资源并新建。所有的路径都是相对于工程目录文件。例如” Assets/MyTextures/hello.png”。 ``` @MenuItem("GameObject/Create Material") 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)); } ```
da
2022年5月14日 12:59
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码