コード例 #1
0
//----------------------------------------------------------------------------------------------------------------------

        private MeshSyncUserSettingsProvider() : base(USER_SETTINGS_MENU_PATH, SettingsScope.User)
        {
            //activateHandler is called when the user clicks on the Settings item in the Settings window.

            activateHandler = (string searchContext, VisualElement root) => {
                m_dccToolsSettingsTab = new DCCToolsSettingsTab();


                //Main Tree
                VisualTreeAsset main = UIElementsEditorUtility.LoadVisualTreeAsset(MeshSyncEditorConstants.MAIN_USER_SETTINGS_PATH);
                Assert.IsNotNull(main);
                main.CloneTree(root);

                //Style
                UIElementsEditorUtility.LoadAndAddStyle(root.styleSheets, MeshSyncEditorConstants.USER_SETTINGS_STYLE_PATH);

                VisualElement content = root.Query <VisualElement>("Content");
                if (null == content)
                {
                    Debug.LogError("MeshSync: Can't create User Settings");
                    return;
                }
                m_dccToolsSettingsTab.Setup(content);
            };

            deactivateHandler = () => {
            };

            //keywords
            HashSet <string> meshSyncKeywords = new HashSet <string>(new[] { "MeshSync", });

            keywords = meshSyncKeywords;
        }
コード例 #2
0
//----------------------------------------------------------------------------------------------------------------------

        MeshSyncSettingsProvider() : base(PROJECT_SETTINGS_MENU_PATH, SettingsScope.Project)
        {
            m_tabs = new IMeshSyncSettingsTab[MeshSyncEditorConstants.MAX_SETTINGS_TAB];
            Button[] tabButtons = new Button[MeshSyncEditorConstants.MAX_SETTINGS_TAB];
            m_tabs[MeshSyncEditorConstants.GENERAL_SETTINGS_TAB]   = new GeneralSettingsTab();
            m_tabs[MeshSyncEditorConstants.DCC_TOOLS_SETTINGS_TAB] = new DCCToolsSettingsTab();

            //activateHandler is called when the user clicks on the Settings item in the Settings window.
            activateHandler = (string searchContext, VisualElement root) => {
                //Main Tree
                VisualTreeAsset main = UIElementsEditorUtility.LoadVisualTreeAsset(
                    Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "ProjectSettings_Main")
                    );
                main.CloneTree(root);


                //Tab Buttons
                VisualElement   tabsContainer     = root.Query <VisualElement>("TabsContainer");
                VisualTreeAsset tabButtonTemplate = UIElementsEditorUtility.LoadVisualTreeAsset(
                    Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "TabButtonTemplate")
                    );

                tabButtons[0] = CreateButton(tabButtonTemplate, Contents.GeneralSettings, OnGeneralSettingsTabClicked);
                tabButtons[1] = CreateButton(tabButtonTemplate, Contents.DCCTools, OnDCCToolsTabClicked);

                foreach (Button tabButton in tabButtons)
                {
                    tabsContainer.Add(tabButton);
                }

                //Style
                UIElementsEditorUtility.LoadAndAddStyle(
                    root.styleSheets,
                    Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "ProjectSettings_Style")
                    );


                m_content = root.Query <VisualElement>("Content");
                UpdateSelectedTabButton(tabButtons[0]);
                SetupTab(MeshSyncEditorConstants.GENERAL_SETTINGS_TAB);
            };


            deactivateHandler = () => {
                SetupTab(MeshSyncEditorConstants.UNINITIALIZED_TAB);
            };

            //keywords
            HashSet <string> meshSyncKeywords = new HashSet <string>(new[] { "MeshSync", });

            meshSyncKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <MeshSyncSettingsProvider.Contents>());
            meshSyncKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <GeneralSettingsTab.Contents>());

            keywords = meshSyncKeywords;
        }
コード例 #3
0
//----------------------------------------------------------------------------------------------------------------------

        MeshSyncProjectSettingsProvider() : base(PROJECT_SETTINGS_MENU_PATH, SettingsScope.Project)
        {
            m_tabs = new IMeshSyncSettingsTab[MeshSyncEditorConstants.MAX_SETTINGS_TAB];
            Button[] tabButtons = new Button[MeshSyncEditorConstants.MAX_SETTINGS_TAB];
            m_tabs[MeshSyncEditorConstants.SERVER_SETTINGS_TAB]             = new ServerSettingsTab();
            m_tabs[MeshSyncEditorConstants.SCENE_CACHE_PLAYER_SETTINGS_TAB] = new SceneCachePlayerSettingsTab();

            //activateHandler is called when the user clicks on the Settings item in the Settings window.
            activateHandler = (string searchContext, VisualElement root) => {
                //Main Tree
                VisualTreeAsset main = UIElementsEditorUtility.LoadVisualTreeAsset(Constants.MAIN_PROJECT_SETTINGS_PATH);
                main.CloneTree(root);

                //Tab Buttons
                VisualElement   tabsContainer = root.Query <VisualElement>("TabsContainer");
                VisualTreeAsset btnTemplate   = UIElementsEditorUtility.LoadVisualTreeAsset(Constants.TAB_BUTTON_TEMPLATE_PATH);

                tabButtons[0] = CreateButton(btnTemplate, Contents.Server, OnServerSettingsTabClicked);
                tabButtons[1] = CreateButton(btnTemplate, Contents.SceneCachePlayer, OnSceneCachePlayerTabClicked);

                foreach (Button tabButton in tabButtons)
                {
                    tabsContainer.Add(tabButton);
                }

                //Style
                UIElementsEditorUtility.LoadAndAddStyle(root.styleSheets, Constants.PROJECT_SETTINGS_STYLE_PATH);


                m_content = root.Query <VisualElement>("Content");
                UpdateSelectedTabButton(tabButtons[0]);
                SetupTab(MeshSyncEditorConstants.SERVER_SETTINGS_TAB);
            };


            deactivateHandler = () => {
                SetupTab(MeshSyncEditorConstants.UNINITIALIZED_TAB);
            };

            //keywords
            HashSet <string> meshSyncKeywords = new HashSet <string>(new[] { "MeshSync", });

            meshSyncKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <MeshSyncProjectSettingsProvider.Contents>());
            meshSyncKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <ServerSettingsTab.Contents>());
            meshSyncKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <SceneCachePlayerSettingsTab.Contents>());
            meshSyncKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <MeshSyncPlayerConfigSection.Contents>());

            keywords = meshSyncKeywords;
        }
//----------------------------------------------------------------------------------------------------------------------

        private SISUserSettingsProvider() : base(USER_SETTINGS_MENU_PATH, SettingsScope.User)
        {
            //activateHandler is called when the user clicks on the Settings item in the Settings window.

            activateHandler = (string searchContext, VisualElement root) => {
                //Main Tree
                VisualTreeAsset main = UIElementsEditorUtility.LoadVisualTreeAsset(SISEditorConstants.MAIN_USER_SETTINGS_PATH);
                Assert.IsNotNull(main);
                main.CloneTree(root);

                //Style
                UIElementsEditorUtility.LoadAndAddStyle(root.styleSheets, SISEditorConstants.USER_SETTINGS_STYLE_PATH);
                VisualElement content = root.Query <VisualElement>("Content");
                Assert.IsNotNull(content);

                //Fields
                InitMaxMemoryForImagesField(content);
                InitDefaultSISPlayableAssetFPSField(content);

                m_activated = true;
            };

            deactivateHandler = () => {
                if (m_activated)
                {
                    m_maxMemoryForImagesSliderInt.Unbind();
                    m_maxMemoryForImagesIntField.Unbind();

                    Object.DestroyImmediate(m_maxMemoryForImagesScriptableObject);
                    m_maxMemoryForImagesScriptableObject = null;
                    m_activated = false;
                }
            };

            //keywords
            HashSet <string> sisKeywords = new HashSet <string>(new[] { "StreamingImageSequence", });

            sisKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <SISUserSettingsProvider.Contents>());

            keywords = sisKeywords;
        }
コード例 #5
0
//----------------------------------------------------------------------------------------------------------------------

        private SISUserSettingsProvider() : base(USER_SETTINGS_MENU_PATH, SettingsScope.User)
        {
            //activateHandler is called when the user clicks on the Settings item in the Settings window.

            activateHandler = (string searchContext, VisualElement root) => {
                //Main Tree
                VisualTreeAsset main = UIElementsEditorUtility.LoadVisualTreeAsset(SISEditorConstants.MAIN_USER_SETTINGS_PATH);
                Assert.IsNotNull(main);
                main.CloneTree(root);

                //Style
                UIElementsEditorUtility.LoadAndAddStyle(root.styleSheets, SISEditorConstants.USER_SETTINGS_STYLE_PATH);

                VisualElement content = root.Query <VisualElement>("Content");
                Assert.IsNotNull(content);
                SISUserSettings userSettings      = SISUserSettings.GetInstance();
                int             maxImagesMemoryMB = userSettings.GetMaxImagesMemoryMB();

                //Prepare objects for binding
                m_maxMemoryForImagesScriptableObject       = ScriptableObject.CreateInstance <IntScriptableObject>();
                m_maxMemoryForImagesScriptableObject.Value = userSettings.GetMaxImagesMemoryMB();
                SerializedObject maxMemoryForImagesSerializedObject = new SerializedObject(m_maxMemoryForImagesScriptableObject);

                //Slider
                VisualElement fieldContainer = UIElementsUtility.AddElement <VisualElement>(content, "field-container");
                m_maxMemoryForImagesSliderInt = UIElementsUtility.AddField <SliderInt, int>(fieldContainer, Contents.MAX_MEMORY_FOR_IMAGES_MB,
                                                                                            maxImagesMemoryMB);

                m_maxMemoryForImagesSliderInt.lowValue    = 4096;
                m_maxMemoryForImagesSliderInt.highValue   = 131072;
                m_maxMemoryForImagesSliderInt.bindingPath = nameof(IntScriptableObject.Value);
                m_maxMemoryForImagesSliderInt.Bind(maxMemoryForImagesSerializedObject);

                m_maxMemoryForImagesIntField = UIElementsUtility.AddField <IntegerField, int>(fieldContainer, null,
                                                                                              maxImagesMemoryMB);
                m_maxMemoryForImagesIntField.bindingPath = nameof(IntScriptableObject.Value);
                m_maxMemoryForImagesIntField.Bind(maxMemoryForImagesSerializedObject);

                Label sliderIntValuePostLabel = UIElementsUtility.AddElement <Label>(fieldContainer);
                sliderIntValuePostLabel.text = "MB     ";

                m_curMaxMemoryForImagesLabel      = UIElementsUtility.AddElement <Label>(fieldContainer);
                m_curMaxMemoryForImagesLabel.text = $"({maxImagesMemoryMB} MB)";


                //Buttons setup
                Button saveButton = root.Query <Button>("SaveButton");
                saveButton.clicked += () => {
                    userSettings.SetMaxImagesMemoryMB(m_maxMemoryForImagesSliderInt.value);
                    m_curMaxMemoryForImagesLabel.text = $"({userSettings.GetMaxImagesMemoryMB()} MB)";
                    userSettings.SaveUserSettings();
                };

                m_activated = true;
            };

            deactivateHandler = () => {
                if (m_activated)
                {
                    m_maxMemoryForImagesSliderInt.Unbind();
                    m_maxMemoryForImagesIntField.Unbind();

                    Object.DestroyImmediate(m_maxMemoryForImagesScriptableObject);
                    m_maxMemoryForImagesScriptableObject = null;
                    m_activated = false;
                }
            };

            //keywords
            HashSet <string> sisKeywords = new HashSet <string>(new[] { "StreamingImageSequence", });

            sisKeywords.UnionWith(GetSearchKeywordsFromGUIContentProperties <SISUserSettingsProvider.Contents>());

            keywords = sisKeywords;
        }