unity asset 怎么用
答案:2 悬赏:10
解决时间 2021-02-17 06:38
- 提问者网友:独菊痴梦
- 2021-02-16 09:16
unity asset 怎么用
最佳答案
- 二级知识专家网友:错过的是遗憾
- 2021-02-16 09:23
不太明白你的意思。assetstore在unity的菜单--windows--assetstore
下载之后的文件会自动导入project面板中
也就是在项目目录的assets目录下
全部回答
- 1楼网友:苦柚恕我颓废
- 2021-02-16 09:58
description
这是一个很容易的创建一个新的派生类实例的方法scriptableobject资产文件。该资产是唯一命名,并放置在当前选定的项目路径,scriptableobject资产文件用于存储数据,不适合自然monobehaviour /对象预制系统内。因为他们使用unity内置的序列化,他们是保证完全映射到一个现有的类;因此,scriptableobject资产工作在unity比xml,csv文件或其他传统的存储这些数据的方法更容易.
usage
scriptableobjectutility.cs复制到您的项目。然后创建一个类yourclassasset.cs
scriptableobjectutility.cs
using unityengine;
using unityeditor;
using system.io;
public static class scriptableobjectutility
{
///
// this makes it easy to create, name and place unique new scriptableobject asset files.
///
public static void createasset () where t : scriptableobject
{
t asset = scriptableobject.createinstance ();
string path = assetdatabase.getassetpath (selection.activeobject);
if (path == "")
{
path = "assets";
}
else if (path.getextension (path) != "")
{
path = path.replace (path.getfilename (assetdatabase.getassetpath (selection.activeobject)), "");
}
string assetpathandname = assetdatabase.generateuniqueassetpath (path + "/new " + typeof(t).tostring() + ".asset");
assetdatabase.createasset (asset, assetpathandname);
assetdatabase.saveassets ();
assetdatabase.refresh();
editorutility.focusprojectwindow ();
selection.activeobject = asset;
}
}
youreditorasset.cs
using unityengine;
using unityeditor;
public class youreditorasset
{
[menuitem("assets/create/yourclass")]
public static void createasset ()
{
scriptableobjectutility.createasset ();
}
}
yourclassasset.cs
using unityengine;
using unityeditor;
public class yourclassasset : scriptableobject
{
//写上各种变量
}
之后就可以生成出像这样高大上的*.asset文件
我要举报
大家都在看
推荐资讯