コード例 #1
0
        private void CreateVisualProgressItem(VisualTreeAsset visualProgressItemTask)
        {
            name = visualElementName;
            if (visualProgressItemTask == null)
            {
                return;
            }

            var ui = visualProgressItemTask.Instantiate();

            m_BackgroundTaskNameLabel        = ui.Q <Label>("BackgroundTaskNameLabel");
            m_ProgressionLabel               = ui.Q <Label>("ProgressionLabel");
            m_BackgroundTaskStatusIcon       = ui.Q <VisualElement>("BackgroundTaskStatusIcon");
            m_BackgroundTaskDescriptionLabel = ui.Q <Label>("BackgroundTaskDescriptionLabel");
            m_BackgroundTaskElapsedTimeLabel = ui.Q <Label>("BackgroundTaskElapsedTimeLabel");
            m_ProgressBar  = ui.Q <ProgressBar>("ProgressBar");
            m_Progress     = m_ProgressBar.Q(null, "unity-progress-bar__progress");
            m_PauseButton  = ui.Q <Button>("PauseButton");
            m_CancelButton = ui.Q <Button>("CancelButton");

            m_PauseButton.RemoveFromClassList("unity-text-element");
            m_PauseButton.RemoveFromClassList("unity-button");
            m_PauseButton.AddToClassList("pause-button");

            m_CancelButton.RemoveFromClassList("unity-text-element");
            m_CancelButton.RemoveFromClassList("unity-button");

            m_PauseButton.clickable.clickedWithEventInfo  -= PauseButtonClicked;
            m_CancelButton.clickable.clickedWithEventInfo -= CancelButtonClicked;
            m_PauseButton.clickable.clickedWithEventInfo  += PauseButtonClicked;
            m_CancelButton.clickable.clickedWithEventInfo += CancelButtonClicked;

            this.Add(ui);
        }
コード例 #2
0
        public void OnEnable()
        {
            _workingDirectory = GetWorkingDirectory();

            VisualElement root = rootVisualElement;

            var           visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(Path.Combine(_workingDirectory, "PluginManager.uxml"));
            VisualElement uxml       = visualTree.Instantiate();

            root.Add(uxml);

            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(Path.Combine(_workingDirectory, "PluginManager.uss"));

            root.styleSheets.Add(styleSheet);

            _pluginListItemTemplate = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(Path.Combine(_workingDirectory, "PluginListItem.uxml"));

            var listView = root.Q <ListView>("list-view");

            listView.makeItem           = () => _pluginListItemTemplate.Instantiate();
            listView.onSelectionChange += _ => SelectPlugin(listView.selectedIndex);

            var updateButton = root.Q <Button>("plugin-update-button");

            updateButton.clicked += () =>
            {
                ShowSpinner();
                GitHelper.UpdateSubmoduleAsync(Path.GetDirectoryName(_manifestPath), _pluginData.Data[listView.selectedIndex].path, () =>
                {
                    HideSpinner();
                    GetPluginList();
                });
            };

            var removeButton = root.Q <Button>("plugin-remove-button");

            removeButton.clicked += () =>
            {
                ShowSpinner();
                GitHelper.RemoveSubmodule(Path.GetDirectoryName(_manifestPath), _pluginData.Data[listView.selectedIndex].path);
                HideSpinner();
                GetPluginList();
            };

            root.Q <ToolbarButton>("refresh-button").clicked += GetPluginList;

            var searchBar = root.Q <ToolbarSearchField>("search-bar");

            searchBar.RegisterValueChangedCallback(e => FilterPlugins(e.newValue));

            GetPluginList();

            var dataContext = new SerializedObject(_filteredPluginData);

            root.Bind(dataContext);

            listView.selectedIndex = 0; //Auto-select first element
        }
コード例 #3
0
    public void AddLive()
    {
        VisualElement live = liveAsset.Instantiate();

        lives.Add(live);
    }