Exemplo n.º 1
0
    void ConfigItemGUI(Dictionary <string, SingleField> dict, string key)
    {
        EditorGUI.indentLevel = 2;
        string      newContent = "";
        SingleField data       = dict[key];

        EditorGUILayout.LabelField(key);

        EditorGUI.indentLevel = 3;

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField("字段类型:", data.m_type.ToString());

        if (GUILayout.Button("删除字段"))
        {
            if (EditorUtility.DisplayDialog("警告", "确定要删除该字段吗!", "是", "取消"))
            {
                dict.Remove(key);
                return;
            }
        }

        EditorGUILayout.EndHorizontal();

        newContent = EditorUtilGUI.FieldGUI_Type(data);

        if (data.GetString() != newContent)
        {
            data.m_content = newContent;
        }

        EditorGUILayout.Space();
    }
Exemplo n.º 2
0
    public static string FieldGUI_Type(SingleField data, string labelContent = "字段内容")
    {
        string content = "";

        switch (data.m_type)
        {
        case FieldType.String:
        case FieldType.StringArray:
        case FieldType.BoolArray:
        case FieldType.IntArray:
        case FieldType.FloatArray:
        case FieldType.Vector2Array:
        case FieldType.Vector3Array:
            content = EditorGUILayout.TextField(labelContent, data.GetString());
            break;

        case FieldType.Int:
            content = EditorGUILayout.IntField(labelContent, data.GetInt()).ToString();
            break;

        case FieldType.Float:
            content = EditorGUILayout.FloatField(labelContent, data.GetFloat()).ToString();
            break;

        case FieldType.Bool:
            content = EditorGUILayout.Toggle(labelContent, data.GetBool()).ToString();
            break;

        case FieldType.Vector3:
            content = EditorGUILayout.Vector3Field(labelContent, data.GetVector3()).ToSaveString();
            break;

        case FieldType.Vector2:
            content = EditorGUILayout.Vector2Field(labelContent, data.GetVector2()).ToSaveString();
            break;

        case FieldType.Color:
            content = EditorGUILayout.ColorField(labelContent, data.GetColor()).ToSaveString();
            break;

        case FieldType.Enum:
            if (data.m_enumType != "" && data.m_enumType != null)
            {
                content = EditorGUILayout.EnumPopup(labelContent, data.GetEnum()).ToString();
            }
            break;
        }

        if (data.m_content != content)
        {
            data.m_content = content;
        }

        return(content);
    }
Exemplo n.º 3
0
 static int GetString(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         SingleField obj = (SingleField)ToLua.CheckObject(L, 1, typeof(SingleField));
         string      o   = obj.GetString();
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }