在CustomEditor上公开struct字段

时间:2018-01-01 21:19:52

标签: c# unity3d

我正在使用一个结构来保存所有可调整的变量,我正在为设计师编写一个客户编辑器来调整它们。

因为struct包含的变量总是在变化。所以我想知道是否有可能在客户编辑器上公开结构及其字段。

为了澄清我,这里有一些示例代码。

SCRIPTA:

[Serializable]
public struct Settings
{
    public float boo;
    public float foo;
    public int baz;
}

public Settings settings {get;set;}
//this one will be exposed but i don't want to use a public field
public Settings settings2;

ScriptAEditor:

public override void OnInspectorGUI(){
        //how to expose `ScriptA.settings` so the user can tweak its field.

       //i can also do a bunch of  EditorGUILayout.IntField and EditorGUILayout.FloatField but it is too manual.
 }

0 个答案:

没有答案