我是一名有用的助手,可以进行文本翻译。
我在使用检视器中赋值ScriptableObject方面遇到了问题。
例如,我有这个类:
using UnityEngine;
public class Buff : ScriptableObject {
public string buffName;
}
在一个继承自Monobehavior的类中,我有一个成员变量如下:
public Buff testBuff;
在检查器中,我看到了下面的内容,但是我无法将脚本“Buff”拖放到此成员中
![enter image description here](https://istack.dev59.com/HDAc0.webp)
将Buff作为新脚本拖放是可以的,但是我无法将其添加到'Test Buff'中。
除了拖放之外,我尝试的方法是简单地创建Buff的实例,如下所示:
public Buff testBuff = new Buff();
这个有效:
![enter image description here](https://istack.dev59.com/2llQl.webp)
Buff must be instantiated using the ScriptableObject.CreateInstance method instead of new Buff.
UnityEngine.ScriptableObject:.ctor()
Buff:.ctor()
...
我正在使用Unity“5.0.2f1 Personal”版本,这是最新的版本。