Ejemplo n.º 1
0
    public static void OnHubGUI()
    {
        if (m_level == null || m_layout == null)
        {
            m_level = GameObject.FindObjectOfType <Level>();
            return;
        }

        Editing = EditorGUILayout.Toggle("Editing", Editing);

        GUI.enabled = m_layout.Dirty;

        if (GUILayout.Button("Save"))
        {
            string path = EditorUtility.SaveFilePanelInProject("Save Level", "newlevel", "xml", "Save levels in \"Resources/Levels\"!");

            m_layout.Serialise(path);
        }

        GUI.enabled = true;

        if (GUILayout.Button("Load"))
        {
            string path = EditorUtility.OpenFilePanel("Open Level", Application.dataPath + "/Resources/Levels", "xml");

            if (!string.IsNullOrEmpty(path))
            {
                m_layout = LevelLayout.Deserialise(path);
                Level.Instance.LoadFromLayout(m_layout);
            }
        }
    }