示例#1
0
    //

    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUILayout.BeginVertical();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("LoadXmlDialog"))
        {
            DialogWriter dialogWriter = XMLUtility.LoadXMLEvent();
            m_monoDialogWriter.m_dialogWriter = XMLUtility.LoadXMLEvent();
            UpdateWriterTree(m_dialogWriter.m_dialogEventList);
        }
        if (GUILayout.Button("SaveXmlDialog"))
        {
            XMLUtility.SaveXMLEvent();
        }


        if (GUILayout.Button("RefreshDialogTree"))
        {
            //手动refresh
            UpdateWriterTree(m_dialogWriter.m_dialogEventList);
        }

        EditorGUILayout.EndHorizontal();

        eventName = (string)EditorGUILayout.TextField("New Event Name", eventName);
        if (GUILayout.Button("Add New Event"))
        {
            if (eventName != "")
            {
                m_dialogWriter.m_dialogEventList.Add(new DialogEvent(eventName));
                UpdateWriterTree(m_dialogWriter.m_dialogEventList);
            }
            else
            {
                EditorUtility.DisplayDialog("Add New Event Fail", "Event name is empty", "Redo");
            }
        }

        EditorGUILayout.TextField("Event Number ", m_dialogWriter.m_dialogEventList.Count.ToString());
        for (int i = 0; i < m_dialogWriter.m_dialogEventList.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.TextField(i + "-" + m_dialogWriter.m_dialogEventList [i].m_name);
            if (GUILayout.Button("Delete Event"))
            {
                m_dialogWriter.m_dialogEventList.RemoveAt(i);
                UpdateWriterTree(m_dialogWriter.m_dialogEventList);
            }
            EditorGUILayout.EndHorizontal();
        }


        EditorGUILayout.EndVertical();
    }