OnEnable 当SO被加载或实例化时调用,紧接着Awake之后执行。会在ScriptableObject.CreateInstance或者脚本成功重新编译之后执行。 OnDisable 当SO超出作用域时调用。如果在加载一个场景时没有引用该SO资产或者在SO执行OnDestroy之前就发生这种情况。Unity还会再脚本重新编译之前执行OnDisable。当进入Play模式时,OnDisable会在OnEn...
17, 34, 42, 67 }; public int A { get { return a; } } //返回b数组中的值;如果x超出范围,则返回-1 public int B(int x) { if (x >= 0 && x <= 5) return b[x]; else return -1; } //创建Asset以及CreateInstance的时候会调用Awake->OnEnable public void Awake() { Debug...
要对Unity的帧(玩家)循环有着足够的理解。例如,知道Awake,OnEnable,Update和其他函数是什么时候被调...
OnDestroy This function is called when the scriptable object will be destroyed. OnDisable This function is called when the scriptable object goes out of scope. OnEnable This function is called when the object is loaded. Inherited members Variables hideFlags Should the object be hidden, saved with...
1、只有很少的回调函数 ,ScriptableObject内部实现上也继承自MonoBehavior,当它只有Awake、OnDestroy、OnEnable、OnDisable四个消息函数; 2、真正意义上的共享,因此一旦修改数据都真的修改了; 3、只能在编辑器状态下进行修改,一旦发布就只能读取; 总结:在编辑器模式下,我们可以将数据保存到ScriptableObject里(当创建一个脚...
OnDisable This function is called when the scriptable object goes out of scope. OnEnable This function is called when the object is loaded. OnValidate Editor-only function that Unity calls when the script is loaded or a value changes in the Inspector. Reset Reset to default values.Did...
注意:它仍然有Awake,OnEnable,OnDestory等方法可以供你使用,详见上方API 创建一个ScriptableObject 需要创建一个ScriptableObject只需要让一个类继承ScriptableObject即可。 usingUnityEngine;usingSystem;namespaceMyScirptableObject{ [Serializable]publicclassLevelSettings:ScriptableObject{publicfloatgravity =-30;publicAudioClip...
1 不允许从ScriptableObject.ctor构造函数(或实例字段初始化程序)调用ScriptableObject,而是在OnEnable中调用它。从ScriptableObject'Find_Object_by_component‘调用。有关详细信息,请参阅“统一手册”中的“脚本序列化”页面。从ScriptableObject'Find_Object_by_com ...
1 不允许从ScriptableObject.ctor构造函数(或实例字段初始化程序)调用ScriptableObject,而是在OnEnable中调用它。从ScriptableObject 'Find_Object_by_component‘调用。有关详细信息,请参阅“统一手册”中的“脚本序列化”页面。从ScriptableObject 'Find_Object_by_component‘调用。有关详细信息,请参阅“统一手册”中的“...
SceneView.onSceneGUIDelegate -= OnSceneGUI; SceneView.onSceneGUIDelegate += OnSceneGUI; //确保我们加载了block的数据库 m_LevelBlocks = AssetDatabase.LoadAssetAtPath<LevelBlocks>( "Assets/E09 - Scriptable Object/LevelBlocks.asset" ); }