コード例 #1
0
        public override VisualElement InstantiateControl()
        {
            VisualElement element = new VisualElement();

            element.AddToClassList("Container");

            element.AddStyleSheetPath("Styles/Controls/TypeControl");
            var icon = new VisualElement();

            icon.AddToClassList("warrning-field");
            var typeObject = string.IsNullOrEmpty(base.value) ? null : Type.GetType(base.value);

            icon.EnableInClassList("valid", typeObject != null);
            var textField = new TextField();

            textField.value = typeObject != null ? typeObject.FullName : "";
            textField.OnValueChanged(e =>
            {
                var type = Type.GetType(e.newValue);
                base.SetValue(e.newValue);
                icon.EnableInClassList("valid", type != null);
                owner.Dirty(ModificationScope.Node);
            });
            element.Add(icon);
            element.Add(textField);
            return(element);
        }
コード例 #2
0
            private void UpdateIcon()
            {
                string typeName = m_Property.GetValue(m_Node) as string;

                if (string.IsNullOrEmpty(typeName))
                {
                    m_Icon.EnableInClassList("valid", false);
                    return;
                }

                List <NamespaceImportNode> imports = ListPool <NamespaceImportNode> .Get();

                List <string> finalNames = ListPool <string> .Get();

                m_Node.FindParentsOrFirstChildren(imports);
                foreach (var import in imports)
                {
                    finalNames.Add(import.importName + "." + typeName);
                }

                finalNames.Add(typeName);
                m_Icon.EnableInClassList("valid", CheckTypes(finalNames));

                ListPool <NamespaceImportNode> .Release(imports);

                ListPool <string> .Release(finalNames);
            }
コード例 #3
0
        public void SetHealth(float newHealth)
        {
            currentHealth = newHealth;
            isHidden      = newHealth >= originalHealth;

            float ratio = newHealth > 0f ? newHealth / originalHealth : 1e-5f;

            bar.transform.scale = new Vector3(ratio, 1, 1);

            // Hide the health bar after the position is set, otherwise it won't hide.
            wholeWidget.EnableInClassList(HiddenHealthBarStyleClass, isHidden);
        }
コード例 #4
0
        public void UpdateColors(bool active)
        {
            var inCallstack = Data.Node.Graph.IsInCallStack(Data.Node);
            var paused      = Data.Node.Graph.DebugState == Graph.PlaybackState.Paused;

            _callstackBorder.EnableInClassList(InCallstackUssClassName, inCallstack);
            _callstackBorder.EnableInClassList(ActiveInCallstackUssClassName, inCallstack && active);
            _callstackBorder.EnableInClassList(BreakUssClassName, paused && active);

            Input.UpdateColor(inCallstack);

            foreach (var output in Outputs)
            {
                output.UpdateColor();
            }
        }
コード例 #5
0
        public void Init()
        {
            if (childCount == 0)
            {
                return;
            }

            var           children     = Children().ToArray();
            VisualElement btnContainer = new VisualElement()
            {
                style = { flexDirection = FlexDirection.Row }
            };
            VisualElement viewContainer = new VisualElement();

            for (int i = 0; i < children.Length; i++)
            {
                VisualElement c   = children[i];
                Button        btn = new Button()
                {
                    text = c.name
                };
                btnContainer.Add(btn);
                btn.clicked += () => SetView(c);
                c.EnableInClassList("hidden", true);
                viewContainer.Add(c);
            }
            btnContainer.AddToClassList("buttons-container");
            Add(btnContainer);
            Add(viewContainer);

            SetView(children[0]);
        }
コード例 #6
0
 void ToggleNameOverrideBox(bool isOverridden)
 {
     m_InnerHeader.EnableInClassList(BuilderConstants.InspectorLocalStyleOverrideClassName, isOverridden);
     m_StatusIndicator.tooltip = isOverridden
         ? BuilderConstants.FieldStatusIndicatorInlineTooltip
         : BuilderConstants.FieldStatusIndicatorDefaultTooltip;
 }
コード例 #7
0
        private void RefreshToolbar()
        {
            var isEnabled  = Application.isPlaying && CurrentGraph != null && CurrentGraph.IsRunning;
            var isPlaying  = isEnabled && CurrentGraph.DebugState == Graph.PlaybackState.Running;
            var isPaused   = isEnabled && CurrentGraph.DebugState == Graph.PlaybackState.Paused;
            var isStepping = isEnabled && CurrentGraph.DebugState == Graph.PlaybackState.Step;
            var isStopping = isEnabled && CurrentGraph.DebugState == Graph.PlaybackState.Stopped;

            _graphButton.text = CurrentGraph == null ? "No Graph Selected" : CurrentGraph.name;
            _lockButton.image = IsLocked ? Icon.Locked.Texture : Icon.Unlocked.Texture;

            _editButton.SetEnabled(CurrentGraph != null);
            _viewButton.SetEnabled(CurrentGraph != null);

            _playButton.SetEnabled(isEnabled);
            _pauseButton.SetEnabled(isEnabled);
            _stepButton.SetEnabled(isEnabled);
            _stopButton.SetEnabled(isEnabled);

            _playButton.EnableInClassList(ToolbarButtonActiveUssClassName, isEnabled && isPlaying);
            _pauseButton.EnableInClassList(ToolbarButtonActiveUssClassName, isEnabled && isPaused);
            _stepButton.EnableInClassList(ToolbarButtonActiveUssClassName, isEnabled && isStepping);
            _stopButton.EnableInClassList(ToolbarButtonActiveUssClassName, isEnabled && isStopping);
            _breakButton.EnableInClassList(ToolbarButtonActiveUssClassName, Graph.IsDebugBreakEnabled);
            _loggingButton.EnableInClassList(ToolbarButtonActiveUssClassName, Graph.IsDebugLoggingEnabled);
            _lockButton.EnableInClassList(ToolbarButtonActiveUssClassName, IsLocked);
            EnableInClassList(BreakpointsDisabledUssClassName, !Graph.IsDebugBreakEnabled);
        }
        public static void ShowValueBadge(this IBadgeContainer self,
                                          VisualElement parent,
                                          VisualElement target,
                                          SpriteAlignment alignment,
                                          string description, Color badgeColor)
        {
            Assert.IsNotNull(parent);
            Assert.IsTrue(self is VisualElement);

            if (self.ValueBadge == null)
            {
                self.ValueBadge = new ValueBadge();
                self.ValueBadge.AddToClassList("valueBadge");
                parent.Add(self.ValueBadge);
                self.ValueBadge.AttachTo(target, alignment);
            }
            else
            {
                self.ValueBadge.style.visibility = Visibility.Visible;
            }

            self.ValueBadge.BadgeColor = badgeColor;
            self.ValueBadge.Text       = description;

            target.EnableInClassList(k_HasValueBadge, true);
        }
コード例 #9
0
    private void SetAnimationType(AnimationType value)
    {
        switch (value)
        {
        case AnimationType.Punch:
            _punchOptions.EnableInClassList("hidden", false);
            break;

        case AnimationType.State:
            _punchOptions.EnableInClassList("hidden", true);
            break;

        default:
            break;
        }
    }
コード例 #10
0
        void UpdateBackgroundControlsView()
        {
            m_BackgroundColorModeControls.EnableInClassList(BuilderConstants.HiddenStyleClassName,
                                                            settings.CanvasBackgroundMode != BuilderCanvasBackgroundMode.Color);

            m_BackgroundImageModeControls.EnableInClassList(BuilderConstants.HiddenStyleClassName,
                                                            settings.CanvasBackgroundMode != BuilderCanvasBackgroundMode.Image);

            m_BackgroundCameraModeControls.EnableInClassList(BuilderConstants.HiddenStyleClassName,
                                                             settings.CanvasBackgroundMode != BuilderCanvasBackgroundMode.Camera);
        }
コード例 #11
0
        void BindItem(VisualElement element, ITreeViewItem item)
        {
            var builderItem = item as BuilderLibraryTreeItem;

            Assert.IsNotNull(builderItem);

            // Pre-emptive cleanup.
            var row = element.parent.parent;

            row.RemoveFromClassList(BuilderConstants.ExplorerHeaderRowClassName);
            row.SetEnabled(true);

            var  listOfOpenDocuments   = m_PaneWindow.document.openUXMLFiles;
            bool isCurrentDocumentOpen = listOfOpenDocuments.Any(doc => doc.visualTreeAsset == builderItem.SourceAsset);

            row.EnableInClassList(BuilderConstants.LibraryCurrentlyOpenFileItemClassName, isCurrentDocumentOpen);
            element.SetEnabled(!isCurrentDocumentOpen);

            // Header
            if (builderItem.IsHeader)
            {
                row.AddToClassList(BuilderConstants.ExplorerHeaderRowClassName);
            }

            var editorOnlyLabel = element.Q <Label>(k_TreeItemEditorOnlyLabelName);

            editorOnlyLabel.text          = BuilderConstants.EditorOnlyTag;
            editorOnlyLabel.style.display = builderItem.IsEditorOnly ? DisplayStyle.Flex : DisplayStyle.None;

            // Set Icon
            AssignTreeItemIcon(element, builderItem.Icon);

            // Set label.
            var label = element.Q <Label>(k_TreeItemLabelName);

            Assert.IsNotNull(label);
            label.text = builderItem.data;

            // Set open button visibility.
            var openButton = element.Q <Button>(k_OpenButtonName);

            openButton.userData = item;
            var enableTreeViewItemWithButton = builderItem.SourceAsset != null && builderItem.SourceAsset != m_PaneWindow.document.visualTreeAsset;

            element.EnableInClassList(k_TreeViewItemWithButtonClassName, enableTreeViewItemWithButton);

            LinkToTreeViewItem(element, builderItem);
        }
コード例 #12
0
        void OnCameraModeChanged(SceneView.CameraMode mode)
        {
            // If the rootVisualElement hasn't yet been created, early out
            if (m_ContentRoot == null)
            {
                CreatePanelContent();
            }

            m_AlbedoContent.EnableInClassList(k_UnityHiddenClass, mode.drawMode != DrawCameraMode.ValidateAlbedo && mode.drawMode != DrawCameraMode.ValidateMetalSpecular);
            m_AlbedoContent.Q("Albedo").EnableInClassList(k_UnityHiddenClass, mode.drawMode != DrawCameraMode.ValidateAlbedo);
            m_LightExposureContent.EnableInClassList(k_UnityHiddenClass, !sceneView.showExposureSettings);
            m_GlobalIlluminationContent.EnableInClassList(k_UnityHiddenClass, mode.drawMode != DrawCameraMode.GIContributorsReceivers);
            m_ShouldDisplay = true;

            switch (mode.drawMode)
            {
            case DrawCameraMode.ValidateAlbedo:
            case DrawCameraMode.ValidateMetalSpecular:
                displayName = "PBR Validation Settings";
                m_AlbedoContent.Q <HelpBox>().EnableInClassList(k_UnityHiddenClass, PlayerSettings.colorSpace != ColorSpace.Gamma);
                m_SceneView.SetOverlayVisible(k_OverlayID, true);
                break;

            case DrawCameraMode.BakedEmissive:
            case DrawCameraMode.BakedLightmap:
            case DrawCameraMode.RealtimeEmissive:
            case DrawCameraMode.RealtimeIndirect:
                displayName = "Lightmap Exposure";
                m_SceneView.SetOverlayVisible(k_OverlayID, true);
                break;

            case DrawCameraMode.GIContributorsReceivers:
                displayName = "GI Contributors / Receivers";
                break;

            default:
                m_ShouldDisplay = false;
                break;
            }

            UpdateAlbedoMetalValidation();
            Handles.SetSceneViewModeGIContributorsReceiversColors(
                kSceneViewMaterialNoContributeGI.Color,
                kSceneViewMaterialReceiveGILightmaps.Color,
                kSceneViewMaterialReceiveGILightProbes.Color);
        }
コード例 #13
0
        private VisualElement CreateBreakpoint()
        {
            var breakpoint = new VisualElement();

            breakpoint.AddToClassList(BreakpointUssClassName);

            var breakpointContainer = new VisualElement {
                tooltip = "Toggle this node as a breakpoint"
            };

            breakpointContainer.AddToClassList(BreakpointUssContainerClassName);
            breakpointContainer.AddManipulator(new Clickable(ToggleBreakpoint));
            breakpointContainer.Add(breakpoint);

            breakpoint.EnableInClassList(BreakpointActiveUssClassName, Data.Node.IsBreakpoint);

            Input.Add(breakpointContainer);

            return(breakpoint);
        }
コード例 #14
0
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    {
        _container = ROJOEditor.LoadAssetTree(treePath);
        _container.AddToClassList("animation-field");
        _container.LoadStyleSheet(stylePath);
        _propertiesContainer = _container.Q <VisualElement>(name: "propertiesContainer");
        _punchOptions        = _container.Q <VisualElement>(name: "punchOptions");

        var ease      = _container.Q <EnumField>(name: "ease");
        var typeField = _container.Q <EnumField>(name: "typeField");

        ease.BindProperty(property.FindPropertyRelative("ease"));
        typeField.BindProperty(property.FindPropertyRelative("AnimationType"));
        typeField.RegisterValueChangedCallback(OnChangeType);

        var enabledToggle = _container.Q <Toggle>("enabledToggle");

        enabledToggle.BindProperty(property.FindPropertyRelative("Enabled"));
        enabledToggle.RegisterValueChangedCallback(OnEnbledToggle);

        var startDelayField = _container.Q <FloatField>(name: "startDelay");
        var durationField   = _container.Q <FloatField>(name: "duration");
        var elasticityField = _container.Q <FloatField>(name: "elasticity");
        var vibratoField    = _container.Q <IntegerField>(name: "vibrato");
        var byField         = _container.Q <Vector3Field>(name: "by");

        startDelayField.BindProperty(property.FindPropertyRelative("startDelay"));
        durationField.BindProperty(property.FindPropertyRelative("duration"));
        elasticityField.BindProperty(property.FindPropertyRelative("Elasticity"));
        vibratoField.BindProperty(property.FindPropertyRelative("Vibrato"));
        byField.BindProperty(property.FindPropertyRelative("By"));

        _propertiesContainer.EnableInClassList("hidden", !enabledToggle.value);

        SetAnimationType((AnimationType)typeField.value);
        return(_container);
    }
コード例 #15
0
            void BindBuildConfigurationItem(VisualElement visualElement, int index)
            {
                var configurationViewModel = m_FilteredBuildConfigurationViewModels[index];

                visualElement.userData = configurationViewModel;

                visualElement.EnableInClassList("unity-disabled", !configurationViewModel.IsLiveLinkCompatible);
                visualElement.tooltip = !configurationViewModel.IsLiveLinkCompatible ? "This Build Configuration is not compatible with Live Link. Please edit it to use a compatible build pipeline." : string.Empty;

                var icon = visualElement.Q <Image>(className: kNamePrefix + "item-template__device-icon");

                icon.ClearClassList();
                icon.AddToClassList(kNamePrefix + "item-template__device-icon");
                icon.AddToClassList(GetUssClass(configurationViewModel.Platform));
                icon.tooltip = $"Target: {configurationViewModel.Platform?.DisplayName ?? "None"}";

                var errorIcon = visualElement.Q <Image>(className: kNamePrefix + "item-template__error-icon");
                var canBuild  = configurationViewModel.Asset.CanBuild();

                errorIcon.ToggleVisibility(!canBuild);
                errorIcon.tooltip = canBuild ? string.Empty : $"This Build Configuration as an error preventing it from being built: {Environment.NewLine}{StripAnyHtmlTag(canBuild.Reason)}";

                visualElement.Q <Label>().text = configurationViewModel.Name;
            }
コード例 #16
0
    private void OnEnbledToggle(ChangeEvent <bool> evt)
    {
        bool value = evt.newValue;

        _propertiesContainer.EnableInClassList("hidden", !value);
    }
コード例 #17
0
        public void OnEnable()
        {
            if (s_Instance == null)
            {
                this.titleContent       = EditorGUIUtility.TrTextContentWithIcon("Undo History", "UnityEditor.HistoryWindow");
                Undo.undoRedoPerformed += OnUndoRedoPerformed;

                //root of the editorwindow
                VisualElement root = rootVisualElement;
                root.styleSheets.Add(EditorGUIUtility.Load(k_StyleCommon) as StyleSheet);
                root.styleSheets.Add(EditorGUIUtility.Load(EditorGUIUtility.isProSkin ? k_StyleDark : k_StyleLight) as StyleSheet);
                root.EnableInClassList("root", true);

                var theListView = EditorGUIUtility.Load("UXML/Undo/UndoListView.uxml") as VisualTreeAsset;
                theListView.CloneTree(root);

                var visualTree = EditorGUIUtility.Load("UXML/Undo/UndoListItem.uxml") as VisualTreeAsset;

                Func <VisualElement> makeItem = visualTree.Instantiate;

                Action <VisualElement, int> bindItem = (e, i) =>
                {
                    //get info on this action
                    var item = m_History[i];

                    //get the main container
                    var container = e.Q("HistoryItem");

                    //is this the the current state?
                    bool isCurrent = item.index == m_UndoCursor;

                    //set style class for the whole Container
                    container.EnableInClassList("current", isCurrent && m_ShowLatestFirst);
                    container.EnableInClassList("current-reverse", isCurrent && !m_ShowLatestFirst);
                    container.EnableInClassList("redo", !isCurrent && item.type == HistoryType.Redo);
                    container.EnableInClassList("undo", !isCurrent && (item.type == HistoryType.Undo || item.type == HistoryType.None));

                    //get the Action label and set it's text to this undo action
                    var label = e.Q("Text-Action") as Label;
                    label.text = item.undoName;

                    if (isCurrent)
                    {
                        m_HistoryListView.selectedIndex = i;
                    }
                };

                m_HistoryListView             = root.Q <ListView>();
                m_HistoryListView.bindItem    = bindItem;
                m_HistoryListView.makeItem    = makeItem;
                m_HistoryListView.itemsSource = m_History;
                m_HistoryListView.RefreshItems();

                m_HistoryListView.onSelectionChange += OnUndoSelectionChange;

                m_LastUndos.Clear();

                s_Instance = this;
            }
            wantsLessLayoutEvents = true;
        }
コード例 #18
0
 private void SetEnable(bool value)
 {
     _mainContainer.EnableInClassList("hidden", !value);
 }
コード例 #19
0
        VisualElement CreateVenueUi(TokenAuthWidget tokenAuth, VisualElement tokenAuthView, UserInfo?userInfo)
        {
            var container = new VisualElement()
            {
                style =
                {
                    flexDirection = FlexDirection.Row,
                    flexGrow      =                 1,
                }
            };
            var sidePane = new VisualElement()
            {
                style =
                {
                    borderColor      = new StyleColor(Color.gray),
                    borderRightWidth =                          1,
                    width            =                        250,
                }
            };

            sidePane.EnableInClassList("pane", true);
            var mainPane = new VisualElement()
            {
                style = { flexGrow = 1 }
            };

            mainPane.EnableInClassList("pane", true);
            container.Add(sidePane);
            container.Add(mainPane);

            // Side
            sidePane.Add(tokenAuthView);

            if (userInfo.HasValue)
            {
                var sideMenu = new SideMenuVenueList(userInfo.Value);
                sideMenu.AddView(sidePane);
                ReactiveBinder.Bind(sideMenu.reactiveForceLogout, forceLogout =>
                {
                    if (forceLogout)
                    {
                        tokenAuth.Logout();
                    }
                });

                // Main
                ReactiveBinder.Bind(sideMenu.reactiveCurrentVenue, currentVenue =>
                {
                    mainPane.Clear();
                    if (currentVenue != null)
                    {
                        var venueContent = new ScrollView(ScrollViewMode.Vertical)
                        {
                            style = { flexGrow = 1 }
                        };
                        new EditAndUploadVenueView(userInfo.Value, currentVenue, () =>
                        {
                            sideMenu.RefetchVenueWithoutChangingSelection();
                        }).AddView(venueContent);
                        mainPane.Add(venueContent);
                    }
                });
            }
            else
            {
                mainPane.Clear();
            }

            return(container);
        }
コード例 #20
0
        private void ResetStyleClasses()
        {
            m_Progress.EnableInClassList("unity-progress-bar__progress__unresponding", false);
            m_Progress.EnableInClassList("unity-progress-bar__progress__full", false);
            m_Progress.EnableInClassList("unity-progress-bar__progress__inactive", false);
            m_Progress.EnableInClassList("unity-progress-bar__progress__idle", false);

            m_PauseButton.EnableInClassList("resume-button", false);
            m_PauseButton.EnableInClassList("pause-button", true);
        }
コード例 #21
0
 public static void SetVisible(this VisualElement element, bool visible) => element.EnableInClassList("hidden", !visible);
コード例 #22
0
 public void SetView(VisualElement view)
 {
     currentView?.EnableInClassList("hidden", true);
     view.EnableInClassList("hidden", false);
     currentView = view;
 }
コード例 #23
0
 private void SetItemExpanded(bool expanded, VisualElement header, Object target, InspectorElement inspector)
 {
     inspector.style.display = expanded ? DisplayStyle.Flex : DisplayStyle.None;
     header.EnableInClassList(itemHeaderCollapsedUssClassName, !expanded);
     InternalEditorUtility.SetIsInspectorExpanded(target, expanded);
 }
コード例 #24
0
 private void SetEnabled(bool value)
 {
     _propertiesContainer.EnableInClassList("hidden", !value);
 }
コード例 #25
0
        private void ToggleBreakpoint()
        {
            Data.Node.IsBreakpoint = !Data.Node.IsBreakpoint;

            _breakpoint.EnableInClassList(BreakpointActiveUssClassName, Data.Node.IsBreakpoint);
        }
コード例 #26
0
 private void EnableElement(VisualElement element, bool value)
 {
     element.EnableInClassList("hidden", !value);
 }