コード例 #1
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q <Button>(name: "addButton");

            m_DragIndicator = new VisualElement();


            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            m_AddButton.SetEnabled(false);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }
コード例 #2
0
        void IControlledElement.OnControllerChanged(ref ControllerChangedEvent e)
        {
            if (e.controller != controller && !(e.controller is VFXParameterController)) //optim : reorder only is only the order has changed
            {
                return;
            }

            if (e.controller == controller && e.change == VFXViewController.Change.assetName)
            {
                title = controller.name;
                return;
            }

            if (controller.model.subgraph is VisualEffectSubgraphOperator && m_OutputCategory == null)
            {
                m_OutputCategory = new VFXBlackboardCategory()
                {
                    title = "Output"
                };
                m_OutputCategory.headerVisible = true;
                m_OutputCategory.expanded      = PlayerPrefs.GetInt("VFX.blackboard.outputexpanded", 0) != 0;
                Add(m_OutputCategory);

                var addOutputButton = new Button()
                {
                    name = "addOutputButton", text = "+"
                };
                addOutputButton.clicked += OnAddOutputParameterMenu;
                var sectionHeader = m_OutputCategory.Q("sectionHeader");
                var spacer        = new VisualElement();
                spacer.style.flexGrow = 1;
                sectionHeader.Add(spacer);
                sectionHeader.Add(addOutputButton);

                m_OutputCategory.AddToClassList("output");
            }
            else if (!(controller.model.subgraph is VisualEffectSubgraphOperator) && m_OutputCategory != null)
            {
                Remove(m_OutputCategory);
                m_OutputCategory = null;
            }

            var actualControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => !t.isOutput && string.IsNullOrEmpty(t.model.category)));

            m_DefaultCategory.SyncParameters(actualControllers);

            var orderedCategories = controller.graph.UIInfos.categories;
            var newCategories     = new List <VFXBlackboardCategory>();

            if (orderedCategories != null)
            {
                foreach (var catModel in controller.graph.UIInfos.categories)
                {
                    VFXBlackboardCategory cat = null;
                    if (!m_Categories.TryGetValue(catModel.name, out cat))
                    {
                        cat = new VFXBlackboardCategory()
                        {
                            title = catModel.name
                        };
                        cat.SetSelectable();
                        m_Categories.Add(catModel.name, cat);
                    }
                    m_ExpandedStatus[catModel.name] = !catModel.collapsed;

                    newCategories.Add(cat);
                }

                foreach (var category in m_Categories.Keys.Except(orderedCategories.Select(t => t.name)).ToArray())
                {
                    m_Categories[category].RemoveFromHierarchy();
                    m_Categories.Remove(category);
                    m_ExpandedStatus.Remove(category);
                }
            }

            var prevCat = m_DefaultCategory;

            foreach (var cat in newCategories)
            {
                if (cat.parent == null)
                {
                    Insert(IndexOf(prevCat) + 1, cat);
                }
                else
                {
                    cat.PlaceInFront(prevCat);
                }
                prevCat = cat;
            }
            if (m_OutputCategory != null)
            {
                m_OutputCategory.PlaceInFront(prevCat);
            }

            foreach (var cat in newCategories)
            {
                actualControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => t.model.category == cat.title && !t.isOutput));
                cat.SyncParameters(actualControllers);
                cat.expanded = m_ExpandedStatus[cat.title];
            }

            if (m_OutputCategory != null)
            {
                var outputControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => t.isOutput));
                m_OutputCategory.SyncParameters(outputControllers);
            }

            m_PathLabel.text = controller.graph.categoryPath;
        }
コード例 #3
0
 public int GetCategoryIndex(VFXBlackboardCategory cat)
 {
     return(IndexOf(cat) - IndexOf(m_DefaultCategory) - 1);
 }
コード例 #4
0
        void IControlledElement.OnControllerChanged(ref ControllerChangedEvent e)
        {
            if (e.controller == controller || e.controller is VFXParameterController) //optim : reorder only is only the order has changed
            {
                if (e.controller == controller && e.change == VFXViewController.Change.assetName)
                {
                    title = controller.name;
                    return;
                }

                var orderedCategories = controller.graph.UIInfos.categories;
                var newCategories     = new List <VFXBlackboardCategory>();

                if (orderedCategories != null)
                {
                    foreach (var catModel in controller.graph.UIInfos.categories)
                    {
                        VFXBlackboardCategory cat = null;
                        if (!m_Categories.TryGetValue(catModel.name, out cat))
                        {
                            cat = new VFXBlackboardCategory()
                            {
                                title = catModel.name
                            };
                            cat.SetSelectable();
                            m_Categories.Add(catModel.name, cat);
                        }
                        m_ExpandedStatus[catModel.name] = !catModel.collapsed;

                        newCategories.Add(cat);
                    }

                    foreach (var category in m_Categories.Keys.Except(orderedCategories.Select(t => t.name)).ToArray())
                    {
                        m_Categories[category].RemoveFromHierarchy();
                        m_Categories.Remove(category);
                        m_ExpandedStatus.Remove(category);
                    }
                }

                var prevCat = m_DefaultCategory;

                foreach (var cat in newCategories)
                {
                    if (cat.parent == null)
                    {
                        Insert(IndexOf(prevCat) + 1, cat);
                    }
                    else
                    {
                        cat.PlaceInFront(prevCat);
                    }
                    prevCat = cat;
                }

                var actualControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => string.IsNullOrEmpty(t.model.category)));
                m_DefaultCategory.SyncParameters(actualControllers);


                foreach (var cat in newCategories)
                {
                    actualControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => t.model.category == cat.title));
                    cat.SyncParameters(actualControllers);
                    cat.expanded = m_ExpandedStatus[cat.title];
                }
            }
        }
コード例 #5
0
 public void SetCategoryExpanded(VFXBlackboardCategory category, bool expanded)
 {
     controller.SetCategoryExpanded(category.title, expanded);
 }
コード例 #6
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q <Button>(name: "addButton");

            m_DragIndicator = new VisualElement();


            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            m_LockedElement                      = new Label("Asset is locked");
            m_LockedElement.style.color          = Color.white * 0.75f;
            m_LockedElement.style.position       = PositionType.Absolute;
            m_LockedElement.style.left           = 0f;
            m_LockedElement.style.right          = new StyleLength(0f);
            m_LockedElement.style.top            = new StyleLength(0f);
            m_LockedElement.style.bottom         = new StyleLength(0f);
            m_LockedElement.style.unityTextAlign = TextAnchor.MiddleCenter;
            var fontSize = 54f;

            m_LockedElement.style.fontSize      = new StyleLength(fontSize);
            m_LockedElement.style.paddingBottom = fontSize / 2f;
            m_LockedElement.style.paddingTop    = fontSize / 2f;
            m_LockedElement.style.display       = DisplayStyle.None;
            m_LockedElement.focusable           = true;
            m_LockedElement.RegisterCallback <KeyDownEvent>(e => e.StopPropagation());
            Add(m_LockedElement);

            m_AddButton.SetEnabled(false);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }