예제 #1
0
    private void OnGUI()
    {
        GUILayout.BeginArea(new Rect(0f, base.position.height / 3f, base.position.width, base.position.height / 3f));
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        GUILayout.FlexibleSpace();




        if (GUILayout.Button(new GUIContent("New Dungeon"), new GUILayoutOption[]
        {
            GUILayout.Width(100f),
            GUILayout.Height(60f)
        }))
        {
            string text = EditorUtility.OpenFilePanel("New Dungeon", "Assets/Scene/Test", "unity");
            if (!string.IsNullOrEmpty(text) && SceneUtils.CheckScene(text))
            {
                text = text.Replace(Application.dataPath, "Assets");
                string text2 = EditorUtility.SaveFilePanel("Save New Dungeon", "Assets", "NewDungeon", "asset");
                if (!string.IsNullOrEmpty(text2) && !text2.Contains(Application.dataPath))
                {
                    string contents = File.ReadAllText(text2);
                    string arg = text2.Split(new char[]
                    {
                        '/'
                    }).Last<string>();
                    text2 = string.Format("{0}/DungeonTmp/{1}", Application.dataPath, arg);
                    Debug.Log(text2);    
                    File.WriteAllText(text2, contents);    
                }
                text2 = text2.Replace(Application.dataPath, "Assets");
                SceneCache.LoadDungeon(text2, text);
                SceneUtils.OpenScene();
                SceneEditorWindow.CreateDungeonEditor();
                this.Destroy();                                                  
            }
            else
            {
                base.ShowNotification(new GUIContent("Choose .unity"));
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }