示例#1
0
        void AddRealtimeFields(MixtureNode node, MixtureGraphView owner)
        {
            doubleBuffered = new Toggle("Double Buffered")
            {
                value = node.rtSettings.doubleBuffered,
            };
            doubleBuffered.RegisterValueChangedCallback(e => {
                owner.RegisterCompleteObjectUndo("Set Double Buffered " + e.newValue);
                node.rtSettings.doubleBuffered = e.newValue;
                onChanged?.Invoke();
            });

            Add(doubleBuffered);

            refreshMode = new EnumField("Refresh Mode", node.rtSettings.refreshMode);
            refreshMode.RegisterValueChangedCallback(e => {
                owner.RegisterCompleteObjectUndo("Set Refresh Mode " + e.newValue);
                node.rtSettings.refreshMode = (RefreshMode)e.newValue;
                onChanged?.Invoke();
            });

            Add(refreshMode);

            period = new FloatField("Period")
            {
                value = node.rtSettings.period
            };
            period.RegisterValueChangedCallback(e => {
                owner.RegisterCompleteObjectUndo("Set Period " + e.newValue);
                node.rtSettings.period = e.newValue;
                onChanged?.Invoke();
            });

            Add(period);
        }
示例#2
0
        void UpdateSettings(SerializableEdge edge)
        {
            // Update nodes used to infere settings values
            parentSettingsNode = GetInputNodes().FirstOrDefault(n => IsNodeUsingSettings(n)) as MixtureNode;
            childSettingsNode  = GetOutputNodes().FirstOrDefault(n => IsNodeUsingSettings(n)) as MixtureNode;

            settings.ResolveAndUpdate(this);
        }
示例#3
0
        public MixtureRTSettingsView(MixtureNode node, MixtureGraphView owner)
        {
            this.graph = owner.graph as MixtureGraph;
            this.node  = node;
            this.owner = owner;

            ReloadSettingsView();

            onChanged += ReloadSettingsView;
        }
示例#4
0
        // TODO: move interactive preview to another class
        public override void OnPreviewSettings()
        {
            var options = nodeWithPreviews.Select(n => n.name).ToArray();

            if (options.Length == 0)
            {
                EditorGUILayout.PrefixLabel("Nothing Selected");
                return;
            }

            if (GUILayout.Button(MixtureEditorUtils.fitIcon, EditorStyles.toolbarButton, buttonLayout))
            {
                Fit();
            }

            GUILayout.Space(2);

            if (!lockFirstPreview)
            {
                firstLockedPreviewTarget = nodeWithPreviews.FirstOrDefault();
            }
            if (!lockSecondPreview)
            {
                if (lockFirstPreview)
                {
                    secondLockedPreviewTarget = nodeWithPreviews.FirstOrDefault();
                }
                else
                {
                    secondLockedPreviewTarget = nodeWithPreviews.Count > 1 ? nodeWithPreviews[1] : nodeWithPreviews.FirstOrDefault();
                }
            }

            GUILayout.Label(firstLockedPreviewTarget.name, EditorStyles.toolbarButton);
            lockFirstPreview = GUILayout.Toggle(lockFirstPreview, GetLockIcon(lockFirstPreview), EditorStyles.toolbarButton, buttonLayout);
            if (compareEnabled)
            {
                var style = EditorStyles.toolbarButton;
                style.alignment = TextAnchor.MiddleLeft;
                compareMode     = (CompareMode)EditorGUILayout.Popup((int)compareMode, new string[] { " 1  -  Side By Side", " 2  -  Onion Skin", " 3  -  Difference", " 4  -  Swap" }, style, buttonLayout, GUILayout.Width(24));
                GUILayout.Label(secondLockedPreviewTarget.name, EditorStyles.toolbarButton);
                lockSecondPreview = GUILayout.Toggle(lockSecondPreview, GetLockIcon(lockSecondPreview), EditorStyles.toolbarButton, buttonLayout);
            }

            compareEnabled = GUILayout.Toggle(compareEnabled, MixtureEditorUtils.compareIcon, EditorStyles.toolbarButton, buttonLayout);

            GUILayout.Space(2);

            if (GUILayout.Button(MixtureEditorUtils.settingsIcon, EditorStyles.toolbarButton, buttonLayout))
            {
                comparisonWindow = new NodeInspectorSettingsPopupWindow(this);
                UnityEditor.PopupWindow.Show(new Rect(EditorGUIUtility.currentViewWidth - NodeInspectorSettingsPopupWindow.width, -NodeInspectorSettingsPopupWindow.height, 0, 0), comparisonWindow);
            }
        }
示例#5
0
        protected virtual void DrawImGUIPreview(MixtureNode node, Rect previewRect, float currentSlice)
        {
            var outputNode = node as OutputNode;

            switch (node.previewTexture.dimension)
            {
            case TextureDimension.Tex2D:
                MixtureUtils.texture2DPreviewMaterial.SetTexture("_MainTex", node.previewTexture);
                MixtureUtils.texture2DPreviewMaterial.SetVector("_Size", new Vector4(node.previewTexture.width, node.previewTexture.height, 1, 1));
                MixtureUtils.texture2DPreviewMaterial.SetVector("_Channels", MixtureEditorUtils.GetChannelsMask(nodeTarget.previewMode));
                MixtureUtils.texture2DPreviewMaterial.SetFloat("_PreviewMip", nodeTarget.previewMip);
                MixtureUtils.texture2DPreviewMaterial.SetFloat("_EV100", nodeTarget.previewEV100);
                MixtureUtils.texture2DPreviewMaterial.SetFloat("_IsSRGB", outputNode != null && outputNode.mainOutput.sRGB ? 1 : 0);

                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DrawPreviewTexture(previewRect, node.previewTexture, MixtureUtils.texture2DPreviewMaterial, ScaleMode.ScaleToFit, 0, 0);
                }
                break;

            case TextureDimension.Tex3D:
                MixtureUtils.texture3DPreviewMaterial.SetTexture("_Texture3D", node.previewTexture);
                MixtureUtils.texture3DPreviewMaterial.SetVector("_Channels", MixtureEditorUtils.GetChannelsMask(nodeTarget.previewMode));
                MixtureUtils.texture3DPreviewMaterial.SetFloat("_PreviewMip", nodeTarget.previewMip);
                MixtureUtils.texture3DPreviewMaterial.SetFloat("_Depth", (currentSlice + 0.5f) / nodeTarget.rtSettings.GetDepth(owner.graph));
                MixtureUtils.texture3DPreviewMaterial.SetFloat("_EV100", nodeTarget.previewEV100);
                MixtureUtils.texture3DPreviewMaterial.SetFloat("_IsSRGB", outputNode != null && outputNode.mainOutput.sRGB ? 1 : 0);

                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DrawPreviewTexture(previewRect, Texture2D.whiteTexture, MixtureUtils.texture3DPreviewMaterial, ScaleMode.ScaleToFit, 0, 0, ColorWriteMask.Red);
                }
                break;

            case TextureDimension.Cube:
                MixtureUtils.textureCubePreviewMaterial.SetTexture("_Cubemap", node.previewTexture);
                MixtureUtils.textureCubePreviewMaterial.SetVector("_Channels", MixtureEditorUtils.GetChannelsMask(nodeTarget.previewMode));
                MixtureUtils.textureCubePreviewMaterial.SetFloat("_PreviewMip", nodeTarget.previewMip);
                MixtureUtils.textureCubePreviewMaterial.SetFloat("_EV100", nodeTarget.previewEV100);
                MixtureUtils.textureCubePreviewMaterial.SetFloat("_IsSRGB", outputNode != null && outputNode.mainOutput.sRGB ? 1 : 0);

                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DrawPreviewTexture(previewRect, Texture2D.whiteTexture, MixtureUtils.textureCubePreviewMaterial, ScaleMode.ScaleToFit, 0, 0);
                }
                break;

            default:
                Debug.LogError(node.previewTexture + " is not a supported type for preview");
                break;
            }
        }
示例#6
0
        void AddRealtimeFields(MixtureNode node, MixtureGraphView owner)
        {
            doubleBuffered = new Toggle("Double Buffered")
            {
                value = node.rtSettings.doubleBuffered,
            };
            doubleBuffered.RegisterValueChangedCallback(e => {
                owner.RegisterCompleteObjectUndo("Set Double Buffered " + e.newValue);
                node.rtSettings.doubleBuffered = e.newValue;
                onChanged?.Invoke();
            });

            Add(doubleBuffered);
        }
示例#7
0
        void UpdateFieldVisibility(MixtureNode node)
        {
            var rtSettings = node.rtSettings;

            SetVisible(outputWidthMode, rtSettings.CanEdit(EditFlags.WidthMode));
            SetVisible(potSize, rtSettings.CanEdit(EditFlags.POTSize));
            SetVisible(outputHeightMode, rtSettings.CanEdit(EditFlags.HeightMode));
            SetVisible(outputDepthMode, rtSettings.CanEdit(EditFlags.DepthMode));
            SetVisible(outputWidth, rtSettings.CanEdit(EditFlags.Width) && rtSettings.widthMode == OutputSizeMode.Fixed && (rtSettings.potSize == POTSize.Custom || !rtSettings.CanEdit(EditFlags.POTSize)));
            SetVisible(outputWidthPercentage, rtSettings.CanEdit(EditFlags.Width) && rtSettings.widthMode == OutputSizeMode.PercentageOfOutput);
            SetVisible(outputHeight, rtSettings.CanEdit(EditFlags.Height) && rtSettings.heightMode == OutputSizeMode.Fixed && (rtSettings.potSize == POTSize.Custom || !rtSettings.CanEdit(EditFlags.POTSize)));
            SetVisible(outputHeightPercentage, rtSettings.CanEdit(EditFlags.Height) && rtSettings.heightMode == OutputSizeMode.PercentageOfOutput);
            SetVisible(outputDepth, rtSettings.CanEdit(EditFlags.Depth) && rtSettings.depthMode == OutputSizeMode.Fixed && (rtSettings.potSize == POTSize.Custom || !rtSettings.CanEdit(EditFlags.POTSize)));
            SetVisible(outputDepthPercentage, rtSettings.CanEdit(EditFlags.Depth) && rtSettings.depthMode == OutputSizeMode.PercentageOfOutput);
            SetVisible(outputDimension, rtSettings.CanEdit(EditFlags.Dimension));
            SetVisible(outputFormat, rtSettings.CanEdit(EditFlags.TargetFormat));
        }
示例#8
0
        protected void CreateTexturePreview(VisualElement previewContainer, MixtureNode node)
        {
            previewContainer.Clear();

            if (node.previewTexture == null)
            {
                return;
            }

            VisualElement texturePreview = new VisualElement();

            previewContainer.Add(texturePreview);

            CreateTexturePreviewImGUI(texturePreview, node);

            previewContainer.name = node.previewTexture.dimension.ToString();

            Button togglePreviewButton = null;

            togglePreviewButton = new Button(() => {
                nodeTarget.isPreviewCollapsed = !nodeTarget.isPreviewCollapsed;
                UpdatePreviewCollapseState();
            });
            togglePreviewButton.ClearClassList();
            togglePreviewButton.AddToClassList("PreviewToggleButton");
            previewContainer.Add(togglePreviewButton);

            UpdatePreviewCollapseState();

            void UpdatePreviewCollapseState()
            {
                if (!nodeTarget.isPreviewCollapsed)
                {
                    texturePreview.style.display = DisplayStyle.Flex;
                    togglePreviewButton.RemoveFromClassList("Collapsed");
                    nodeTarget.previewVisible = true;
                }
                else
                {
                    texturePreview.style.display = DisplayStyle.None;
                    togglePreviewButton.AddToClassList("Collapsed");
                    nodeTarget.previewVisible = false;
                }
            }
        }
示例#9
0
        void CreateTexturePreviewImGUI(VisualElement previewContainer, MixtureNode node)
        {
            if (node.showPreviewExposure)
            {
                var previewExposure = new Slider(0, 10)
                {
                    label = "Preview EV100",
                    value = node.previewEV100,
                };
                previewExposure.RegisterValueChangedCallback(e => {
                    node.previewEV100 = e.newValue;
                });
                previewContainer.Add(previewExposure);
            }

            var previewImageSlice = new IMGUIContainer(() => {
                if (node.previewTexture == null)
                {
                    return;
                }

                if (node.previewTexture.dimension == TextureDimension.Tex3D)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUIUtility.labelWidth = 70;
                    node.previewSlice           = EditorGUILayout.Slider("3D Slice", node.previewSlice, 0, TextureUtils.GetSliceCount(node.previewTexture) - 1);
                    EditorGUIUtility.labelWidth = 0;
                    if (EditorGUI.EndChangeCheck())
                    {
                        MarkDirtyRepaint();
                    }
                }

                DrawPreviewCommonSettings(node.previewTexture);

                Rect previewRect = GetPreviewRect(node.previewTexture);
                DrawImGUIPreview(node, previewRect, node.previewSlice);

                DrawTextureInfoHover(previewRect, node.previewTexture);
            });

            previewContainer.Add(previewImageSlice);
        }
示例#10
0
        void CreateTexturePreviewImGUI(VisualElement previewContainer, MixtureNode node, int currentSlice)
        {
            // Add slider for texture 3D
            if (node.previewTexture.dimension == TextureDimension.Tex3D)
            {
                var previewSliceIndex = new SliderInt(0, TextureUtils.GetSliceCount(node.previewTexture) - 1)
                {
                    label = "Slice",
                    value = currentSlice,
                };
                previewSliceIndex.RegisterValueChangedCallback((ChangeEvent <int> a) => {
                    currentSlice = a.newValue;
                });
                previewContainer.Add(previewSliceIndex);
            }

            var previewImageSlice = new IMGUIContainer(() => {
                if (node.previewTexture == null)
                {
                    return;
                }

                DrawPreviewCommonSettings(node.previewTexture);

                Rect previewRect = GetPreviewRect(node.previewTexture);
                DrawImGUIPreview(node, previewRect, currentSlice);

                DrawTextureInfoHover(previewRect, node.previewTexture);
            });

            // Force the ImGUI preview to refresh
            EditorApplication.update -= previewImageSlice.MarkDirtyRepaint;
            EditorApplication.update += previewImageSlice.MarkDirtyRepaint;

            previewContainer.Add(previewImageSlice);
        }
示例#11
0
        void UpdateFieldVisibility(MixtureNode node)
        {
            var rtSettings = node.rtSettings;

            SetVisible(sizeHeader, rtSettings.CanEdit(EditFlags.Size));
            SetVisible(formatHeader, rtSettings.CanEdit(EditFlags.Format));
            SetVisible(outputWidthMode, rtSettings.CanEdit(EditFlags.WidthMode));
            SetVisible(potSize, rtSettings.CanEdit(EditFlags.POTSize));
            SetVisible(outputHeightMode, rtSettings.CanEdit(EditFlags.HeightMode));
            SetVisible(outputDepthMode, rtSettings.CanEdit(EditFlags.DepthMode));
            SetVisible(outputWidth, rtSettings.CanEdit(EditFlags.Width) && rtSettings.widthMode == OutputSizeMode.Fixed && (rtSettings.potSize == POTSize.Custom || !rtSettings.CanEdit(EditFlags.POTSize)));
            SetVisible(outputWidthPercentage, rtSettings.CanEdit(EditFlags.Width) && rtSettings.widthMode == OutputSizeMode.PercentageOfOutput);
            SetVisible(outputHeight, rtSettings.CanEdit(EditFlags.Height) && rtSettings.heightMode == OutputSizeMode.Fixed && (rtSettings.potSize == POTSize.Custom || !rtSettings.CanEdit(EditFlags.POTSize)));
            SetVisible(outputHeightPercentage, rtSettings.CanEdit(EditFlags.Height) && rtSettings.heightMode == OutputSizeMode.PercentageOfOutput);
            SetVisible(outputDepth, rtSettings.CanEdit(EditFlags.Depth) && rtSettings.depthMode == OutputSizeMode.Fixed && (rtSettings.potSize == POTSize.Custom || !rtSettings.CanEdit(EditFlags.POTSize)));
            SetVisible(outputDepthPercentage, rtSettings.CanEdit(EditFlags.Depth) && rtSettings.depthMode == OutputSizeMode.PercentageOfOutput);
            SetVisible(outputDimension, rtSettings.CanEdit(EditFlags.Dimension));
            SetVisible(outputChannels, rtSettings.CanEdit(EditFlags.TargetFormat));
            SetVisible(outputPrecision, rtSettings.CanEdit(EditFlags.TargetFormat));

            // GraphicsFormatUtility.GetComponentCount((GraphicsFormat)rtSettings.targetFormat);
            // GraphicsFormatUtility.Get((GraphicsFormat)rtSettings.targetFormat);
            // GraphicsFormatUtility.GetBlockWidth()
        }