Beispiel #1
0
        void UpdateAttachedLabel()
        {
            if (m_VFXView.controller?.graph != null)
            {
                var          isAttached           = m_VFXView.attachedComponent != null;
                VisualEffect selectedVisualEffect = null;
                Selection.activeGameObject?.TryGetComponent(out selectedVisualEffect);
                var isCompatible = selectedVisualEffect != null && selectedVisualEffect.visualEffectAsset == m_VFXView.controller.graph.visualEffectResource.asset;
                m_AttachButton.SetEnabled(isAttached || isCompatible);
                m_AttachButton.text       = isAttached ? "Detach" : "Attach to selection";
                m_pickedObjectLabel.value = m_VFXView.attachedComponent?.name ?? "None (Visual Effect Asset)";

                if (isAttached)
                {
                    m_VFXIcon.style.display = DisplayStyle.Flex;
                    m_pickedObjectLabel[0].style.paddingLeft = 18;
                    m_VFXIcon.style.backgroundImage          = VFXView.LoadImage(EditorGUIUtility.isProSkin ? "vfx_graph_icon_gray_dark" : "vfx_graph_icon_gray_light");
                }
                else
                {
                    m_pickedObjectLabel[0].style.paddingLeft = 3;
                    m_VFXIcon.style.display = DisplayStyle.None;
                }
            }
        }
Beispiel #2
0
        Texture2D GetIconForVFXType(VFXDataType type)
        {
            switch (type)
            {
            case VFXDataType.SpawnEvent:
                return(VFXView.LoadImage("Execution"));

            case VFXDataType.Particle:
            case VFXDataType.ParticleStrip:     // TODO Add an icon
                return(VFXView.LoadImage("Particles"));
            }
            return(null);
        }
        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");

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

            m_RecordBoundsButton = this.Query <Button>("record");
            m_RecordBoundsImage  = this.Query <Image>("record-icon");
            m_RecordBoundsButton.clickable.clicked += OnRecordBoundsButton;
            m_RecordIcon             = VFXView.LoadImage("d_Record");
            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));
        }