예제 #1
0
    /// <summary>
    /// 数据列表
    /// </summary>
    /// <param name="storeInfo"></param>
    public static string GUIListData <E>(string titleName, string content) where E : System.Enum
    {
        //前置相关
        EditorGUILayout.BeginVertical();
        GUILayout.Label(titleName + ":", GUILayout.Width(100), GUILayout.Height(20));
        if (GUILayout.Button("添加", GUILayout.Width(100), GUILayout.Height(20)))
        {
            content += ("|" + EnumExtension.GetEnumValueByPosition <E>(0).GetEnumName() + ":" + "1|");
        }
        List <string> listConditionData = content.SplitForListStr('|');

        content = "";
        for (int i = 0; i < listConditionData.Count; i++)
        {
            string itemConditionData = listConditionData[i];
            if (itemConditionData.IsNull())
            {
                continue;
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("删除", GUILayout.Width(100), GUILayout.Height(20)))
            {
                listConditionData.RemoveAt(i);
                i--;
                continue;
            }
            List <string> listItemConditionData = itemConditionData.SplitForListStr(':');
            listItemConditionData[0] = EditorGUILayout.EnumPopup(listItemConditionData[0].GetEnum <E>(), GUILayout.Width(300), GUILayout.Height(20)).GetEnumName();
            listItemConditionData[1] = EditorGUILayout.TextArea(listItemConditionData[1] + "", GUILayout.Width(100), GUILayout.Height(20));
            EditorGUILayout.EndHorizontal();
            content += (listItemConditionData[0] + ":" + listItemConditionData[1]) + "|";
        }
        EditorGUILayout.EndVertical();
        return(content);
    }