示例#1
0
        public ResizableElement(string uiFile)
        {
            var tpl   = VFXView.LoadUXML(uiFile);
            var sheet = VFXView.LoadStyleSheet("Resizable");

            styleSheets.Add(sheet);

            tpl.CloneTree(this);

            foreach (Resizer value in System.Enum.GetValues(typeof(Resizer)))
            {
                VisualElement resizer = this.Q(value.ToString().ToLower() + "-resize");
                if (resizer != null)
                {
                    resizer.AddManipulator(new ElementResizer(this, value));
                }
                m_Resizers[value] = resizer;
            }

            foreach (Resizer vertical in new[] { Resizer.Top, Resizer.Bottom })
            {
                foreach (Resizer horizontal in new[] { Resizer.Left, Resizer.Right })
                {
                    VisualElement resizer = this.Q(vertical.ToString().ToLower() + "-" + horizontal.ToString().ToLower() + "-resize");
                    if (resizer != null)
                    {
                        resizer.AddManipulator(new ElementResizer(this, vertical | horizontal));
                    }
                    m_Resizers[vertical | horizontal] = resizer;
                }
            }
        }
示例#2
0
        public VFXSystemBorder()
        {
            RecreateResources();

            var tpl = VFXView.LoadUXML("VFXSystemBorder");

            tpl.CloneTree(this);

            this.AddStyleSheetPath("VFXSystemBorder");

            this.style.overflow = Overflow.Visible;

            m_Title      = this.Query <Label>("title");
            m_TitleField = this.Query <TextField>("title-field");

            m_TitleField.style.display = DisplayStyle.None;

            m_Title.RegisterCallback <MouseDownEvent>(OnTitleMouseDown);

            m_TitleField.Q("unity-text-input").RegisterCallback <FocusOutEvent>(OnTitleBlur, TrickleDown.TrickleDown);
            m_TitleField.RegisterCallback <ChangeEvent <string> >(OnTitleChange);
            m_Title.RegisterCallback <GeometryChangedEvent>(OnTitleRelayout);

            Content content = new Content(this);

            content.style.position = UnityEngine.UIElements.Position.Absolute;
            content.style.top      = content.style.left = content.style.right = content.style.bottom = 0f;
            content.pickingMode    = PickingMode.Ignore;

            pickingMode = PickingMode.Ignore;
            Add(content);
            RegisterCallback <CustomStyleResolvedEvent>(OnCustomStyleResolved);
            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
            visible = false;
        }
示例#3
0
        public VFXEdgeDragInfo(VFXView view)
        {
            m_View = view;
            var tpl = VFXView.LoadUXML("VFXEdgeDragInfo");

            tpl.CloneTree(this);

            this.styleSheets.Add(VFXView.LoadStyleSheet("VFXEdgeDragInfo"));

            m_Text = this.Q <Label>("title");

            pickingMode        = PickingMode.Ignore;
            m_Text.pickingMode = PickingMode.Ignore;
        }
示例#4
0
        public StickyNote(string uiFile, Vector2 position)
        {
            var tpl = VFXView.LoadUXML(uiFile);

            tpl.CloneTree(this);

            capabilities = Capabilities.Movable | Capabilities.Deletable | Capabilities.Ascendable | Capabilities.Selectable;

            m_Title = this.Q <Label>(name: "title");
            if (m_Title != null)
            {
                m_Title.RegisterCallback <MouseDownEvent>(OnTitleMouseDown);
            }

            m_TitleField = this.Q <TextField>(name: "title-field");
            if (m_TitleField != null)
            {
                m_TitleField.style.display = DisplayStyle.None;
                m_TitleField.Q("unity-text-input").RegisterCallback <BlurEvent>(OnTitleBlur);
                m_TitleField.RegisterCallback <ChangeEvent <string> >(OnTitleChange);
            }


            m_Contents = this.Q <Label>(name: "contents");
            if (m_Contents != null)
            {
                m_ContentsField = m_Contents.Q <TextField>(name: "contents-field");
                if (m_ContentsField != null)
                {
                    m_ContentsField.style.display = DisplayStyle.None;
                    m_ContentsField.multiline     = true;
                    m_ContentsField.Q("unity-text-input").RegisterCallback <BlurEvent>(OnContentsBlur);
                }
                m_Contents.RegisterCallback <MouseDownEvent>(OnContentsMouseDown);
            }

            SetPosition(new Rect(position, defaultSize));

            AddToClassList("sticky-note");
            AddToClassList("selectable");
            UpdateThemeClasses();
            UpdateSizeClasses();

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }
示例#5
0
        protected void CreateGUI()
        {
            rootVisualElement.styleSheets.Add(VFXView.LoadStyleSheet("VFXAttachPanel"));

            var tpl           = VFXView.LoadUXML("VFXAttachPanel");
            var mainContainer = tpl.CloneTree();

            m_AttachButton          = mainContainer.Q <Button>("AttachButton");
            m_AttachButton.clicked += OnAttach;
            var button = mainContainer.Q <Button>("PickButton");

            button.clicked                += OnPickObject;
            m_pickedObjectLabel            = mainContainer.Q <TextField>("PickLabel");
            m_pickedObjectLabel.isReadOnly = true;
            m_VFXIcon = mainContainer.Q <VisualElement>("VFXIcon");
            UpdateAttachedLabel();
            rootVisualElement.Add(mainContainer);
        }
        public void UpdateEventList()
        {
            if (m_AttachedComponent == null)
            {
                if (m_EventsContainer != null)
                {
                    m_EventsContainer.Clear();
                }
                m_Events.Clear();
            }
            else
            {
                var eventNames = GetEventNames().ToArray();

                foreach (var removed in m_Events.Keys.Except(eventNames).ToArray())
                {
                    var ui = m_Events[removed];
                    m_EventsContainer.Remove(ui);
                    m_Events.Remove(removed);
                }

                foreach (var added in eventNames.Except(m_Events.Keys).ToArray())
                {
                    var tpl = VFXView.LoadUXML("VFXComponentBoard-event");

                    tpl.CloneTree(m_EventsContainer);

                    VFXComponentBoardEventUI newUI = m_EventsContainer.Children().Last() as VFXComponentBoardEventUI;
                    if (newUI != null)
                    {
                        newUI.Setup();
                        newUI.name = added;
                        m_Events.Add(added, newUI);
                    }
                }

                if (!m_Events.Values.Any(t => t.nameHasFocus))
                {
                    SortEventList();
                }
            }
        }
示例#7
0
 void UpdateBoundsRecorder()
 {
     if (m_AttachedComponent != null)
     {
         controller.RecompileExpressionGraphIfNeeded();
         bool wasRecording = false;
         if (m_BoundsRecorder != null)
         {
             wasRecording = m_BoundsRecorder.isRecording;
             m_BoundsRecorder.CleanUp();
         }
         m_BoundsRecorder = new VFXBoundsRecorder(m_AttachedComponent, m_View);
         if (wasRecording && !m_View.controller.isReentrant) //If this is called during an Undo/Redo, toggling the recording will cause a reentrant invalidation
         {
             m_BoundsRecorder.ToggleRecording();
         }
         var systemNames = m_BoundsRecorder.systemNames;
         if (m_SystemBoundsContainer != null)
         {
             foreach (var elem in m_SystemBoundsContainer.Children())
             {
                 if (elem is VFXComponentBoardBoundsSystemUI)
                 {
                     (elem as VFXComponentBoardBoundsSystemUI).ReleaseBoundsRecorder();
                 }
             }
             m_SystemBoundsContainer.Clear();
             m_SystemBoundsContainer.AddStyleSheetPath("VFXComponentBoard-bounds-list");
         }
         foreach (var system in systemNames)
         {
             var tpl = VFXView.LoadUXML("VFXComponentBoard-bounds-list");
             tpl.CloneTree(m_SystemBoundsContainer);
             VFXComponentBoardBoundsSystemUI newUI = m_SystemBoundsContainer.Children().Last() as VFXComponentBoardBoundsSystemUI;
             if (newUI != null)
             {
                 newUI.Setup(system, m_BoundsRecorder);
             }
         }
     }
 }
示例#8
0
        public VFXBlackboardCategory()
        {
            var tpl = VFXView.LoadUXML("VFXBlackboardSection");

            m_MainContainer = tpl.CloneTree();
            m_MainContainer.AddToClassList("mainContainer");

            m_Header        = m_MainContainer.Q <VisualElement>("sectionHeader");
            m_TitleLabel    = m_MainContainer.Q <Label>("sectionTitleLabel");
            m_RowsContainer = m_MainContainer.Q <VisualElement>("rowsContainer");

            m_ExpandButton = m_Header.Q <Button>("expandButton");
            m_ExpandButton.clickable.clicked += ToggleExpand;

            hierarchy.Add(m_MainContainer);
            hierarchy.Add(m_MainContainer);


            m_DragIndicator = new VisualElement();

            m_DragIndicator.name = "dragIndicator";
            hierarchy.Add(m_DragIndicator);
            m_DragIndicator.style.display = DisplayStyle.None;

            ClearClassList();
            AddToClassList("blackboardSection");
            AddToClassList("selectable");

            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));

            m_InsertIndex = -1;
        }
        public VFXComponentBoard(VFXView view)
        {
            m_View = view;
            var tpl = VFXView.LoadUXML("VFXComponentBoard");

            tpl.CloneTree(contentContainer);

            contentContainer.AddStyleSheetPath("VFXComponentBoard");

            m_AttachButton = this.Query <Button>("attach");
            m_AttachButton.clickable.clicked += ToggleAttach;

            m_SelectButton = this.Query <Button>("select");
            m_SelectButton.clickable.clicked += Select;

            m_ComponentPath = this.Query <Label>("component-path");

            m_ComponentContainer       = this.Query("component-container");
            m_ComponentContainerParent = m_ComponentContainer.parent;

            RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
            RegisterCallback <DetachFromPanelEvent>(OnDetachToPanel);

            m_Stop = this.Query <Button>("stop");
            m_Stop.clickable.clicked += EffectStop;
            m_Play = this.Query <Button>("play");
            m_Play.clickable.clicked += EffectPlay;
            m_Step = this.Query <Button>("step");
            m_Step.clickable.clicked += EffectStep;
            m_Restart = this.Query <Button>("restart");
            m_Restart.clickable.clicked += EffectRestart;

            m_PlayRateSlider           = this.Query <Slider>("play-rate-slider");
            m_PlayRateSlider.lowValue  = Mathf.Pow(VisualEffectControl.minSlider, 1 / VisualEffectControl.sliderPower);
            m_PlayRateSlider.highValue = Mathf.Pow(VisualEffectControl.maxSlider, 1 / VisualEffectControl.sliderPower);
            m_PlayRateSlider.RegisterValueChangedCallback(evt => OnEffectSlider(evt.newValue));
            m_PlayRateField = this.Query <IntegerField>("play-rate-field");
            m_PlayRateField.RegisterCallback <ChangeEvent <int> >(OnPlayRateField);

            m_PlayRateMenu = this.Query <Button>("play-rate-menu");
            m_PlayRateMenu.AddStyleSheetPathWithSkinVariant("VFXControls");

            m_PlayRateMenu.clickable.clicked += OnPlayRateMenu;

            m_ParticleCount = this.Query <Label>("particle-count");

            Button button = this.Query <Button>("on-play-button");

            button.clickable.clicked += () => SendEvent(VisualEffectAsset.PlayEventName);
            button = this.Query <Button>("on-stop-button");
            button.clickable.clicked += () => SendEvent(VisualEffectAsset.StopEventName);

            m_EventsContainer = this.Query("events-container");

            Detach();
            this.AddManipulator(new Dragger {
                clampToParentEdges = true
            });

            capabilities |= Capabilities.Movable;

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);

            style.position = PositionType.Absolute;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.componentBoard, defaultRect));
        }
示例#10
0
        public VFXComponentBoard(VFXView view)
        {
            m_View = view;
            var tpl = VFXView.LoadUXML("VFXComponentBoard");

            tpl.CloneTree(contentContainer);

            contentContainer.AddStyleSheetPath("VFXComponentBoard");

            m_RootElement        = this.Query <VisualElement>("component-container");
            m_SubtitleIcon       = this.Query <Image>("subTitle-icon");
            m_Subtitle           = this.Query <Label>("subTitleLabel");
            m_SubtitleIcon.image = EditorGUIUtility.LoadIcon(EditorResources.iconsPath + "console.warnicon.sml.png");

            m_Stop = this.Query <Button>("stop");
            m_Stop.clickable.clicked += EffectStop;
            m_Play = this.Query <Button>("play");
            m_Play.clickable.clicked += EffectPlay;
            m_Step = this.Query <Button>("step");
            m_Step.clickable.clicked += EffectStep;
            m_Restart = this.Query <Button>("restart");
            m_Restart.clickable.clicked += EffectRestart;

            m_PlayRateSlider           = this.Query <Slider>("play-rate-slider");
            m_PlayRateSlider.lowValue  = Mathf.Pow(VisualEffectControl.minSlider, 1 / VisualEffectControl.sliderPower);
            m_PlayRateSlider.highValue = Mathf.Pow(VisualEffectControl.maxSlider, 1 / VisualEffectControl.sliderPower);
            m_PlayRateSlider.RegisterValueChangedCallback(evt => OnEffectSlider(evt.newValue));
            m_PlayRateField = this.Query <IntegerField>("play-rate-field");
            m_PlayRateField.RegisterCallback <ChangeEvent <int> >(OnPlayRateField);

            m_PlayRateMenu = this.Query <Button>("play-rate-menu");
            m_PlayRateMenu.AddStyleSheetPathWithSkinVariant("VFXControls");

            m_PlayRateMenu.clickable.clicked += OnPlayRateMenu;

            m_ParticleCount = this.Query <Label>("particle-count");

            Button button = this.Query <Button>("on-play-button");

            button.clickable.clicked += () => SendEvent(VisualEffectAsset.PlayEventName);
            button = this.Query <Button>("on-stop-button");
            button.clickable.clicked += () => SendEvent(VisualEffectAsset.StopEventName);

            m_EventsContainer = this.Query("events-container");

            m_DebugModes = this.Query <Button>("debug-modes");
            m_DebugModes.clickable.clicked += OnDebugModes;

            m_RecordIcon         = VFXView.LoadImage("d_Record");
            m_RecordBoundsButton = this.Query <Button>("record");
            m_RecordBoundsImage  = m_RecordBoundsButton.Query <Image>("record-icon");
            m_RecordBoundsImage.style.backgroundImage = m_RecordIcon;
            m_RecordBoundsButton.clickable.clicked   += OnRecordBoundsButton;
            m_BoundsActionLabel      = this.Query <Label>("bounds-label");
            m_BoundsToolContainer    = this.Query("bounds-tool-container");
            m_BackgroundDefaultColor = m_BoundsToolContainer.style.backgroundColor;
            m_SystemBoundsContainer  = this.Query <VFXBoundsSelector>("system-bounds-container");
            m_SystemBoundsContainer.RegisterCallback <MouseDownEvent>(OnMouseClickBoundsContainer);

            m_ApplyBoundsButton = this.Query <Button>("apply-bounds-button");
            m_ApplyBoundsButton.clickable.clicked += ApplyCurrentBounds;

            Detach();
            this.AddManipulator(new Dragger {
                clampToParentEdges = true
            });

            capabilities |= Capabilities.Movable;

            RegisterCallback <MouseDownEvent>(OnMouseClick);

            style.position = PositionType.Absolute;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.componentBoard, defaultRect));
        }
示例#11
0
        protected DropDownButtonBase(
            VFXView view,
            string uxmlSource,
            string mainButtonLabel,
            string mainButtonName,
            string iconPath,
            bool hasSeparatorBefore = false,
            bool hasSeparatorAfter  = false)
        {
            m_VFXView           = view;
            style.flexDirection = new StyleEnum <FlexDirection>(FlexDirection.Row);

            if (hasSeparatorBefore)
            {
                m_HasLeftSeparator = true;
                var divider = new VisualElement();
                divider.AddToClassList("separator");
                Add(divider);
            }

            m_MainButton = new Button(OnMainButton)
            {
                name = mainButtonName
            };
            m_MainButton.AddToClassList("dropdown-button");
            m_MainButton.AddToClassList("unity-toolbar-toggle");
            if (!string.IsNullOrEmpty(iconPath))
            {
                var icon = new Image {
                    image = EditorGUIUtility.LoadIcon(iconPath)
                };
                m_MainButton.Add(icon);
                m_MainButton.tooltip = mainButtonLabel;
            }
            else
            {
                m_MainButton.text = mainButtonLabel;
            }
            Add(m_MainButton);

            var separator = new VisualElement();

            separator.AddToClassList("dropdown-separator");
            Add(separator);

            var dropDownButton = new Button(OnTogglePopup);

            dropDownButton.AddToClassList("dropdown-arrow");
            dropDownButton.AddToClassList("unity-toolbar-toggle");
            dropDownButton.Add(new VisualElement());
            Add(dropDownButton);

            if (hasSeparatorAfter)
            {
                var divider = new VisualElement();
                divider.AddToClassList("separator");
                Add(divider);
            }

            m_PopupContent = new VisualElement();
            var tpl = VFXView.LoadUXML(uxmlSource);

            tpl.CloneTree(m_PopupContent);
            contentContainer.AddStyleSheetPath("VFXToolbar");
        }