summaryrefslogtreecommitdiff
path: root/VRCSDK3Worlds/Assets/MeshBaker/Editor/MB3_MeshBakerEditorWindow.cs
blob: faad34dc105372851f811f6ac20a2aed18883fe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//----------------------------------------------
//            MeshBaker
// Copyright © 2011-2012 Ian Deane
//----------------------------------------------
using UnityEditor;
using UnityEngine;
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using DigitalOpus.MB.Core;

namespace DigitalOpus.MB.MBEditor
{
    public class MB3_MeshBakerEditorWindow : EditorWindow
    {
        MB3_MeshBakerEditorWindowAddObjectsTab addObjectsTab;
        MB3_MeshBakerEditorWindowAnalyseSceneTab analyseSceneTab;
        Vector2 scrollPos = Vector2.zero;
        int selectedTab = 0;
        GUIContent[] tabs = new GUIContent[] { new GUIContent("Analyse Scene & Generate Bakers"), new GUIContent("Search For Meshes To Add") };

        [MenuItem("Window/Mesh Baker/Mesh Baker")]
        static void Init()
        {
            MB3_MeshBakerEditorWindow me = (MB3_MeshBakerEditorWindow) EditorWindow.GetWindow(typeof(MB3_MeshBakerEditorWindow));
        }

        public void SetTarget(MB3_MeshBakerRoot targ)
        {
            if (addObjectsTab == null) addObjectsTab = new MB3_MeshBakerEditorWindowAddObjectsTab();
            addObjectsTab.target = targ;
        }

        void OnGUI()
        {
            selectedTab = GUILayout.Toolbar(selectedTab, tabs);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height));

            if (selectedTab == 0)
            {
                analyseSceneTab.drawTabAnalyseScene(position);
            }
            else
            {
                addObjectsTab.drawTabAddObjectsToBakers();
            }

            EditorGUILayout.EndScrollView();
        }

        void OnEnable()
        {
            if (addObjectsTab == null) addObjectsTab = new MB3_MeshBakerEditorWindowAddObjectsTab();
            if (analyseSceneTab == null) analyseSceneTab = new MB3_MeshBakerEditorWindowAnalyseSceneTab();
            addObjectsTab.OnEnable();
        }

        void OnDisable()
        {
            addObjectsTab.OnDisable();
        }
    }
}