privateTexturetex;...if(GUILayout.Button("查找法线贴图")){//参数释义//1. 查找对象的引用//2. 是否允许查找场景对象//3. 查找对象名称过滤(比如这里的normal是指文件名称中有normal的会被搜索到)//4. controlID, 默认写0EditorGUIUtility.ShowObjectPicker<Texture>(tex,false,"normal",0);} 2. 选中提...
Editor还会从Inspector调用OnValidate和Reset。你可以在SO对象上创建自己的方法,但是游戏引擎循环并不会自动调用它们。 运行时,MB必须依附于GameObjects。如果你需要在运行时新建一个,则要使用AddComponent API. 每一个SO实例都可以单独在项目层次存储在自己的文件中。 在编辑器中,当退出Play状态后,所有在Play状态下所...
我们需要实例化一个继承自Scriptable Object的C#脚本,为了方便在Unity Editor中实例化一个Scriptable Object,我们在脚本类声明前添加CreateAssetMenu属性,这样我们就可以在Unity Asset面板中右键创建一个Scriptable Object实例了,如下图。 当我们实例化一个Scriptable Object脚本之后,我们就可以发现实例化后的Scriptable Object...
EditorGUILayout.PropertyField(gunProp, newGUIContent("Gun Object")); // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI. serializedObject.ApplyModifiedProperties (); } // CustomGUILayoutprogress bar. voidProgressBar(float value, string label) { // Get a ...
但只有在编辑器模式下才可以修改里面的数据,这是因为ScriptableObject对象虽然声明在UnityEngine中,但是它的Scriptable是通过UnityEditor命名空间下的类(例如Editor类等)来实现的, 所以ScriptableObject生成的数据资源文件在Editor外具有只读属性,这是非常需要注意的一点。如果我们需要在游戏中修改数据并存储下来,就不推荐使用Scr...
ScriptableObject类的对象必须由ScriptableObject.CreateInstance方法来生成。由于Unity生成Object的时候必须经过序列化,而且如果使用new操作符来生成对象程序就必定会出现一定的卡顿情况,所以,不能使用new操作符来生成 using UnityEngine; using UnityEditor; public class ExampleAsset : ScriptableObject ...
OnDisableThis function is called when the scriptable object goes out of scope. OnEnableThis function is called when the object is loaded. OnValidateEditor-only function that Unity calls when the script is loaded or a value changes in the Inspector. ...
using UnityEditor;publicclassImporterExample:AssetPostprocessor{privatevoidOnPreprocessTexture(){varimporter=assetImporterasTextureImporter;// Read/Write settings, etc. are also possible.importer.isReadable=false;varsettings=newTextureImporterPlatformSettings();// Specify Android = "Android", PC = "Standalo...
在多材质编辑器中,MaterialArrayDrawers类实现了MultiMaterialEditor和MultiMaterialDataEditor中材质编辑器框的绘制。如果想为自己的Scriptable Object定制检视窗口并支持直接将其用于组件,可以完全复用该多材质编辑器代码。 当尝试在另一编辑器的OnInspectorGUI方法中绘制材质编辑器时,出于对性能与交互限制的考虑有些重要事项...
当创建⼀个脚本化对象实例后使⽤AssetDatabase.CreateAsset()保存成资源),因为是作为本地资源保存的,所以在退出之后也不会丢失。 但只有在编辑器模式下才可以修改⾥⾯的数据,这是因为ScriptableObject对象虽然声明在UnityEngine中,但是它的Scriptable是通过UnityEditor命名空 ...