或者使用 Assets/Create 菜单 通过代码创建: // 运行时创建临时实例 var tempData = ScriptableObject.CreateInstance<GameData>(); // 创建持久化资源 #if UNITY_EDITOR var data = ScriptableObject.CreateInstance<GameData>(); UnityEditor.AssetDatabase.CreateAsset(data, "Assets/Data/NewData.asset"); UnityEd...
"ShowObject Window",true);// 直接根据ScriptableObject构造一个Editorwindow.editor=Editor.CreateEditor(ScriptableObject.CreateInstance<ShowObject>());}privatevoidOnGUI(){// 直接调用Inspector的绘制显示this.editor
有了上述类后,创建QuestionsProfile类,继承ScriptableObject,使用CreateAssetMenu为创建该类型资产提供了创建菜单,并创建QuestionsProfileInspector继承Editor类进行了编辑器拓展: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 using UnityEngine; using System.Collections.Generic; #if UNITY_EDITOR using UnityEditor;...
class in UnityEditor / Inherits from:ScriptableObject Leave feedback Description Derive from this base class to create a custom inspector or editor for your custom object. using UnityEngine; using System.Collections; // This is not an editor script. public class MyPlayer :MonoBehaviour{ public int...
实例化完对象后,接下来我们就需要将实例化的对象保存成资源。我们使用AssetDatabase.CreateAsset来创建资源文件,并且确保扩展名为.asset。如果使用其他扩展名,Unity则不会将其识别为ScriptableObject的派生资源。 usingUnityEditor; usingUnityEngine; public classEditorTest : ScriptableObject ...
可以通过多种方式来创建该资源,主要使用ScriptableObject.CreateInstance方法 方式一:使用tool菜单创建 注意:在使用Editor类中添加如下方法 publicstaticTCreateAsset<T>(stringpath)whereT : ScriptableObject{ T dataClass = (T) ScriptableObject.CreateInstance<T>(); AssetDatabase.CreateAsset(dataClass, path); Asset...
1、实例化 ScriptableObject.CreateInstance 2、生成资源文件 AssetDatabase.CreateAsset 3、加载资源文件 AssetDatabase.LoadAssetAtPath 补充:如何在编辑器中直接显示ScriptableObject的OnInspectorGUI。 ```Csharp if (editor==null) //这一步很重要,如果没有设置,那么就不会显示 ...
Namespace: UnityEditor/Inherits from: ScriptableObjectDescription Derive from this class to create an editor window.Create your own custom editor window that can float free or be docked as a tab, just like the native windows in the Unity interface. Editor windows are typically opened using a ...
最后,检查对话条目节点的OnExecute()事件,单击“+”按钮,并分配TestScriptableObject。选择你想要执行的方法(PlayAudioClip),并指定你想要播放的音频剪辑的索引: Outline Editor 大纲编辑器 你也可以在大纲模式下编辑对话,如上图所示,这对像Bioware的Aurora工具集这样的编辑器的用户来说可能更熟悉。要切换到大纲模式...
if (GUILayout.Button("Create/Update XML")) { CreateXml(XmlName); } 1. 2. 3. 4. 随后打开窗口即可看到 输入数据并点击按钮生成文件 打开XML文件查看数据 创建Asset数据用于保存XML数据 新建脚本XmlAsset.cs,继承自ScriptableObject,同样放置在Editor文件夹下 public class XmlAsset : ScriptableObject { public...