在 StateMachineBehaviours 的自定义 Unity Inspector 中显示脚本字段
Show the script field in a custom Unity Inspector for StateMachineBehaviours
通常我会在 CustomEditor 中使用以下方法在检查器中显示组件的脚本字段
private void DrawScriptField()
{
// Disable editing
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour((MyClass) target), typeof(MyClass), false);
EditorGUI.EndDisabledGroup();
}
我的问题是 MonoScript
显然只包含 FromMonoBehaviour
和 FromScriptableObject
这两种方法,但是没有从 StateMachineBehaviour
.[=17 获取脚本的方法=]
如何在自定义编辑器中为 StateMachineBehaviour
脚本制作类似的脚本字段?
哦没关系。我读过 StateMachineBehaviour
实际上继承自 ScriptableObject
所以我可以简单地使用 MonoScript.FromScriptableObject
.
通常我会在 CustomEditor 中使用以下方法在检查器中显示组件的脚本字段
private void DrawScriptField()
{
// Disable editing
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour((MyClass) target), typeof(MyClass), false);
EditorGUI.EndDisabledGroup();
}
我的问题是 MonoScript
显然只包含 FromMonoBehaviour
和 FromScriptableObject
这两种方法,但是没有从 StateMachineBehaviour
.[=17 获取脚本的方法=]
如何在自定义编辑器中为 StateMachineBehaviour
脚本制作类似的脚本字段?
哦没关系。我读过 StateMachineBehaviour
实际上继承自 ScriptableObject
所以我可以简单地使用 MonoScript.FromScriptableObject
.