Пример #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(Resources.Load <StyleSheet>("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);

            cacheAsBitmap = true;
            SetDragIndicatorVisible(false);

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

            hierarchy.Add(new ResizableElement());

            style.position = PositionType.Absolute;

            subTitle = "Parameters";

            resizer.RemoveFromHierarchy();

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

            m_AddButton.SetEnabled(false);
        }
Пример #2
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);
        }
Пример #3
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;

            AddStyleSheetPath("VFXBlackboard");

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


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

            focusIndex = 0;


            m_DragIndicator = new VisualElement();

            m_DragIndicator.name = "dragIndicator";
            m_DragIndicator.style.positionType = PositionType.Absolute;
            shadow.Add(m_DragIndicator);

            clippingOptions = ClippingOptions.ClipContents;
            SetDragIndicatorVisible(false);

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

            shadow.Add(new ResizableElement());

            style.positionType = PositionType.Absolute;

            subTitle = "Parameters";

            resizer.RemoveFromHierarchy();
        }
 public void OnResized()
 {
     BoardPreferenceHelper.SavePosition(BoardPreferenceHelper.Board.componentBoard, GetPosition());
 }
 public override void UpdatePresenterPosition()
 {
     BoardPreferenceHelper.SavePosition(BoardPreferenceHelper.Board.componentBoard, GetPosition());
 }
 public void ValidatePosition()
 {
     BoardPreferenceHelper.ValidatePosition(this, m_View, defaultRect);
 }
        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));
        }
Пример #8
0
 public void OnMoved()
 {
     BoardPreferenceHelper.SavePosition(BoardPreferenceHelper.Board.blackboard, GetPosition());
 }
Пример #9
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_ContentContainer = this.Q <VisualElement>("contentContainer");

            m_AddButton              = this.Q <Button>(name: "addButton");
            m_AddButton.style.width  = 27;
            m_AddButton.style.height = 27;

            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(); }, TrickleDown.TrickleDown);
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed, TrickleDown.TrickleDown);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

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

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));

            // Workaround: output category is in a scrollview which can lead to get the Add button invisible (moved out of the visible viewport of the scrollviewer)
            var scrollView = this.Q <ScrollView>();

            if (scrollView != null)
            {
                scrollView.RegisterCallback <GeometryChangedEvent, ScrollView>(OnGeometryChanged, scrollView);
                scrollView.horizontalScroller.valueChanged += x => OnOutputCategoryScrollChanged(scrollView);
            }
        }
Пример #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
        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));
        }