예제 #1
0
    private void OnGUI()
    {
        float width  = Screen.width;
        float height = Screen.height;

        if (showMenu && sampleSet != null)
        {
            var y = 0f;

            GUI.BeginGroup(new Rect(0, 0, width, GlobalGui.barHeightWidth));

            float urlFieldWidth = width - GlobalGui.buttonWidth;

#if UNITY_EDITOR
            if (GUI.Button(new Rect(width - GlobalGui.buttonWidth * 2, 0, GlobalGui.buttonWidth, GlobalGui.barHeightWidth), "Open"))
            {
                string path = EditorUtility.OpenFilePanel("Select glTF", "", "glb");
                if (path.Length != 0)
                {
                    LoadUrlAsync("file://" + path);
                }
            }
            urlFieldWidth -= GlobalGui.buttonWidth;
#endif

            urlField = GUI.TextField(new Rect(0, 0, urlFieldWidth, GlobalGui.barHeightWidth), urlField);
            if (GUI.Button(new Rect(width - GlobalGui.buttonWidth, 0, GlobalGui.buttonWidth, GlobalGui.barHeightWidth), "Load"))
            {
                LoadUrlAsync(urlField);
            }
            GUI.EndGroup();
            y += GlobalGui.barHeightWidth;

            float listItemWidth = GlobalGui.listWidth - 16;
            local = GUI.Toggle(new Rect(GlobalGui.listWidth, GlobalGui.barHeightWidth, GlobalGui.listWidth * 2, GlobalGui.barHeightWidth), local, local?"local":"http");

            if (sceneDropDown != null || cameraDropDown != null)
            {
                bool somethingShown = false;

                if (GUI.Button(new Rect(0, y, listItemWidth, GlobalGui.listItemHeight), "back to set"))
                {
                    sceneNames     = null;
                    sceneDropDown  = null;
                    cameraDropDown = null;
                    return;
                }

                var dropdownHeight = Screen.height - y;
                y += GlobalGui.listItemHeight;

                if (sceneDropDown != null)
                {
                    sceneDropDown.DrawGUI(
                        new Rect(0, y, listItemWidth, dropdownHeight),
                        i => SetSceneIndex(i));
                    y += GlobalGui.listItemHeight;
                    somethingShown = sceneDropDown.show;
                }

                dropdownHeight = Screen.height - y;
                if (!somethingShown && cameraDropDown != null)
                {
                    cameraDropDown?.DrawGUI(
                        new Rect(0, y, listItemWidth, dropdownHeight),
                        i => SetCameraIndex(i));
                    somethingShown = cameraDropDown.show;
                }
            }
            else
            {
                var items = local ? testItemsLocal : testItems;
                scrollPos = GUI.BeginScrollView(
                    new Rect(0, GlobalGui.barHeightWidth, GlobalGui.listWidth, height - GlobalGui.barHeightWidth),
                    scrollPos,
                    new Rect(0, 0, listItemWidth, GlobalGui.listItemHeight * items.Count)
                    );
                if (GUI.Button(new Rect(0, 0, listItemWidth, GlobalGui.listItemHeight), "change set"))
                {
                    ResetSampleSet();
                    return;
                }
                GUIDrawItems(items, listItemWidth, GlobalGui.listItemHeight);
                GUI.EndScrollView();
            }
        }
    }