Esempio n. 1
0
        public void OnGUI()
        {
            AltVRItemWidgets.BuildSelectorList(_known_items.Values, CreateKit, LoadItems <kitsJSON>, SelectItem, ref m_scrollPosition);

            void CreateKit()
            {
                CreateKitWindow window = CreateInstance <CreateKitWindow>();

                window.SetCommitAction(() =>
                {
                    AltspaceKitItem new_item = new AltspaceKitItem()
                    {
                        itemName    = window.kitName,
                        description = window.description,
                        imageFile   = window.imageFile
                    };

                    if (new_item.updateAltVRItem() && LoadSingleItem(new_item.id))
                    {
                        _selected_item          = _known_items[new_item.id];
                        _selected_item.itemPath = Path.Combine(
                            SettingsManager.settings.KitsRootDirectory,
                            Common.SanitizeFileName(_selected_item.itemName));

                        this.Close();
                        GetWindow <LoginManager>().Repaint();
                    }
                });
                window.Show();
            }
        }
        public void OnGUI()
        {
            GUILayout.BeginVertical(new GUIStyle {
                padding = new RectOffset(10, 10, 10, 10)
            });

            if (HasLoadedKits)
            {
                m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition);
                foreach (var kit in _known_kits)
                {
                    EditorGUILayout.BeginHorizontal(GUILayout.Width(120.0f));

                    EditorGUILayout.LabelField(kit.Value.kit_data.name);
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Select", EditorStyles.miniButton))
                    {
                        _selected_kit = _known_kits[kit.Value.kit_data.kit_id];
                        this.Close();
                        GetWindow <LoginManager>().Repaint();
                    }

                    EditorGUILayout.EndHorizontal();
                }

                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label(
                    "No kits loaded. Either press \"Load kits\"\n" +
                    "to load known kits from the account,\n" +
                    "Or press \"Create New Kit\" to create a new one.", new GUIStyle()
                {
                    fontStyle = FontStyle.Bold
                });
            }

            if (GUILayout.Button("Load Kits"))
            {
                LoadKits();
            }

            if (GUILayout.Button("Create New Kit"))
            {
                CreateKitWindow window = CreateInstance <CreateKitWindow>();
                window.ShowModalUtility();
                if (window.rc)
                {
                    string kit_id = CreateKit(window.kitName, window.description, window.imageFile);
                    if (LoadSingleKit(kit_id))
                    {
                        _selected_kit = _known_kits[kit_id];
                    }
                }
            }
            // CreateKit("__AUUTest", "This is a test for the AUU kit creation", "D:/Users/carsten/Pictures/Sweet-Fullscene.png");
            GUILayout.EndVertical();
        }