コード例 #1
0
        void HandleTexture2DProperty(PropertySheet propertySheet, Texture2DShaderProperty texture2DProperty)
        {
            var texture2DPropertyDrawer = new Texture2DPropertyDrawer();

            propertySheet.Add(texture2DPropertyDrawer.CreateGUI(
                                  newValue =>
            {
                this._preChangeValueCallback("Change property value");
                this._changeValueCallback(newValue);
                this._postChangeValueCallback();
            },
                                  texture2DProperty.value.texture,
                                  "Default",
                                  out var texture2DField
                                  ));

            if (!isSubGraph)
            {
                var enumPropertyDrawer = new EnumPropertyDrawer();
                propertySheet.Add(enumPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    this._preChangeValueCallback("Change Texture mode");
                    if (texture2DProperty.defaultType == (Texture2DShaderProperty.DefaultType)newValue)
                    {
                        return;
                    }
                    texture2DProperty.defaultType = (Texture2DShaderProperty.DefaultType)newValue;
                    this._postChangeValueCallback(false, ModificationScope.Graph);
                },
                                      texture2DProperty.defaultType,
                                      "Mode",
                                      Texture2DShaderProperty.DefaultType.White,
                                      out var textureModeField));

                textureModeField.SetEnabled(texture2DProperty.generatePropertyBlock);
            }
        }
コード例 #2
0
        void HandleColorProperty(PropertySheet propertySheet, ColorShaderProperty colorProperty)
        {
            var colorPropertyDrawer = new ColorPropertyDrawer();

            propertySheet.Add(colorPropertyDrawer.CreateGUI(
                                  newValue =>
            {
                this._preChangeValueCallback("Change property value");
                this._changeValueCallback(newValue);
                this._postChangeValueCallback();
            },
                                  colorProperty.value,
                                  "Default",
                                  out var propertyColorField));

            var colorField = (ColorField)propertyColorField;

            colorField.hdr = colorProperty.colorMode == ColorMode.HDR;

            if (!isSubGraph)
            {
                var enumPropertyDrawer = new EnumPropertyDrawer();

                propertySheet.Add(enumPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    this._preChangeValueCallback("Change Color Mode");
                    colorProperty.colorMode = (ColorMode)newValue;
                    this._postChangeValueCallback(true, ModificationScope.Graph);
                },
                                      colorProperty.colorMode,
                                      "Mode",
                                      ColorMode.Default,
                                      out var colorModeField));
            }
        }
コード例 #3
0
        internal VisualElement CreateGUI(GraphData graphData)
        {
            var propertySheet = new VisualElement()
            {
                name = "graphSettings"
            };

            if (graphData == null)
            {
                Debug.Log("Attempting to draw something that isn't of type GraphData with a GraphDataPropertyDrawer");
                return(propertySheet);
            }

            var enumPropertyDrawer = new EnumPropertyDrawer();

            propertySheet.Add(enumPropertyDrawer.CreateGUI(
                                  newValue => { m_postChangeConcretePrecisionCallback((ConcretePrecision)newValue); },
                                  graphData.concretePrecision,
                                  "Precision",
                                  ConcretePrecision.Float,
                                  out var propertyVisualElement));

            return(propertySheet);
        }
コード例 #4
0
        VisualElement CreateGUI(SampleVirtualTextureNode node, InspectableAttribute attribute,
                                out VisualElement propertyVisualElement)
        {
            PropertySheet propertySheet = new PropertySheet();

            var enumPropertyDrawer = new EnumPropertyDrawer();

            propertySheet.Add(enumPropertyDrawer.CreateGUI((newValue) =>
            {
                if (node.addressMode == (SampleVirtualTextureNode.AddressMode)newValue)
                {
                    return;
                }

                node.owner.owner.RegisterCompleteObjectUndo("Address Mode Change");
                node.addressMode = (SampleVirtualTextureNode.AddressMode)newValue;
            },
                                                           node.addressMode,
                                                           "Address Mode",
                                                           SampleVirtualTextureNode.AddressMode.VtAddressMode_Wrap,
                                                           out var addressModeVisualElement));

            propertySheet.Add(enumPropertyDrawer.CreateGUI((newValue) =>
            {
                if (node.lodCalculation == (SampleVirtualTextureNode.LodCalculation)newValue)
                {
                    return;
                }

                node.owner.owner.RegisterCompleteObjectUndo("Lod Mode Change");
                node.lodCalculation = (SampleVirtualTextureNode.LodCalculation)newValue;
            },
                                                           node.lodCalculation,
                                                           "Lod Mode",
                                                           SampleVirtualTextureNode.LodCalculation.VtLevel_Automatic,
                                                           out var lodCalculationVisualElement));

            propertySheet.Add(enumPropertyDrawer.CreateGUI((newValue) =>
            {
                if (node.sampleQuality == (SampleVirtualTextureNode.QualityMode)newValue)
                {
                    return;
                }

                node.owner.owner.RegisterCompleteObjectUndo("Quality Change");
                node.sampleQuality = (SampleVirtualTextureNode.QualityMode)newValue;
            },
                                                           node.sampleQuality,
                                                           "Quality",
                                                           SampleVirtualTextureNode.QualityMode.VtSampleQuality_High,
                                                           out var qualityVisualElement));

            var boolPropertyDrawer = new BoolPropertyDrawer();

            propertySheet.Add(boolPropertyDrawer.CreateGUI((newValue) =>
            {
                if (node.noFeedback == !newValue)
                {
                    return;
                }

                node.owner.owner.RegisterCompleteObjectUndo("Feedback Settings Change");
                node.noFeedback = !newValue;
            },
                                                           !node.noFeedback,
                                                           "Automatic Streaming",
                                                           out var propertyToggle));

            propertySheet.Add(boolPropertyDrawer.CreateGUI((newValue) =>
            {
                if (node.enableGlobalMipBias == newValue)
                {
                    return;
                }

                node.owner.owner.RegisterCompleteObjectUndo("Enable Global Mip Bias VT Change");
                node.enableGlobalMipBias = newValue;
            },
                                                           node.enableGlobalMipBias,
                                                           "Use Global Mip Bias",
                                                           out var enableGlobalMipBias));


            // display warning if the current master node doesn't support virtual texturing
            // TODO: Add warning when no active subTarget supports VT
            // if (!node.owner.isSubGraph)
            // {
            //     bool supportedByMasterNode =
            //         node.owner.GetNodes<IMasterNode>().FirstOrDefault()?.supportsVirtualTexturing ?? false;
            //     if (!supportedByMasterNode)
            //         propertySheet.Add(new HelpBoxRow(MessageType.Warning),
            //             (row) => row.Add(new Label(
            //                 "The current master node does not support Virtual Texturing, this node will do regular 2D sampling.")));
            // }

            // display warning if the current render pipeline doesn't support virtual texturing
            IVirtualTexturingEnabledRenderPipeline vtRp =
                GraphicsSettings.currentRenderPipeline as IVirtualTexturingEnabledRenderPipeline;

            if (vtRp == null)
            {
                propertySheet.Add(new HelpBoxRow(MessageType.Warning),
                                  (row) => row.Add(new Label(
                                                       "The current render pipeline does not support Virtual Texturing, this node will do regular 2D sampling.")));
            }
            else if (vtRp.virtualTexturingEnabled == false)
            {
                propertySheet.Add(new HelpBoxRow(MessageType.Warning),
                                  (row) => row.Add(new Label(
                                                       "The current render pipeline has disabled Virtual Texturing, this node will do regular 2D sampling.")));
            }
            else
            {
#if !ENABLE_VIRTUALTEXTURES
                propertySheet.Add(new HelpBoxRow(MessageType.Warning),
                                  (row) => row.Add(new Label(
                                                       "Virtual Texturing is disabled globally (possibly by the render pipeline settings), this node will do regular 2D sampling.")));
#endif
            }

            propertyVisualElement = propertySheet;
            return(propertySheet);
        }
コード例 #5
0
        void HandleVector1ShaderProperty(PropertySheet propertySheet, Vector1ShaderProperty vector1ShaderProperty)
        {
            // Handle vector 1 mode parameters
            switch (vector1ShaderProperty.floatType)
            {
            case FloatType.Slider:
                var floatPropertyDrawer = new FloatPropertyDrawer();
                // Default field
                propertySheet.Add(floatPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    _preChangeValueCallback("Change Property Value");
                    _changeValueCallback(newValue);
                    _postChangeValueCallback();
                },
                                      vector1ShaderProperty.value,
                                      "Default",
                                      out var propertyFloatField));

                // Min field
                propertySheet.Add(floatPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    if (newValue > vector1ShaderProperty.rangeValues.y)
                    {
                        propertySheet.warningContainer.Q <Label>().text = "Min cannot be greater than Max.";
                    }
                    _preChangeValueCallback("Change Range Property Minimum");
                    vector1ShaderProperty.rangeValues = new Vector2(newValue, vector1ShaderProperty.rangeValues.y);
                    _postChangeValueCallback();
                },
                                      vector1ShaderProperty.rangeValues.x,
                                      "Min",
                                      out var minFloatField));

                // Max field
                propertySheet.Add(floatPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    if (newValue < vector1ShaderProperty.rangeValues.x)
                    {
                        propertySheet.warningContainer.Q <Label>().text = "Max cannot be lesser than Min.";
                    }
                    this._preChangeValueCallback("Change Range Property Maximum");
                    vector1ShaderProperty.rangeValues = new Vector2(vector1ShaderProperty.rangeValues.x, newValue);
                    this._postChangeValueCallback();
                },
                                      vector1ShaderProperty.rangeValues.y,
                                      "Max",
                                      out var maxFloatField));

                var defaultField = (FloatField)propertyFloatField;
                var minField     = (FloatField)minFloatField;
                var maxField     = (FloatField)maxFloatField;

                minField.Q("unity-text-input").RegisterCallback <FocusOutEvent>(evt =>
                {
                    propertySheet.warningContainer.Q <Label>().text = "";
                    vector1ShaderProperty.value = Mathf.Max(Mathf.Min(vector1ShaderProperty.value, vector1ShaderProperty.rangeValues.y), vector1ShaderProperty.rangeValues.x);
                    defaultField.value          = vector1ShaderProperty.value;
                    _postChangeValueCallback();
                });

                maxField.Q("unity-text-input").RegisterCallback <FocusOutEvent>(evt =>
                {
                    propertySheet.warningContainer.Q <Label>().text = "";
                    vector1ShaderProperty.value = Mathf.Max(Mathf.Min(vector1ShaderProperty.value, vector1ShaderProperty.rangeValues.y), vector1ShaderProperty.rangeValues.x);
                    defaultField.value          = vector1ShaderProperty.value;
                    _postChangeValueCallback();
                });
                break;

            case FloatType.Integer:
                var integerPropertyDrawer = new IntegerPropertyDrawer();
                // Default field
                propertySheet.Add(integerPropertyDrawer.CreateGUI(
                                      newValue => this._changeValueCallback(newValue),
                                      (int)vector1ShaderProperty.value,
                                      "Default",
                                      out var integerPropertyField));
                break;

            default:
                var defaultFloatPropertyDrawer = new FloatPropertyDrawer();
                // Default field
                propertySheet.Add(defaultFloatPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    this._preChangeValueCallback("Change property value");
                    this._changeValueCallback(newValue);
                    this._postChangeValueCallback();
                },
                                      vector1ShaderProperty.value,
                                      "Default",
                                      out var defaultFloatPropertyField));
                break;
            }

            if (!isSubGraph)
            {
                var enumPropertyDrawer = new EnumPropertyDrawer();
                propertySheet.Add(enumPropertyDrawer.CreateGUI(
                                      newValue =>
                {
                    this._preChangeValueCallback("Change Vector1 Mode");
                    vector1ShaderProperty.floatType = (FloatType)newValue;
                    this._postChangeValueCallback(true);
                },
                                      vector1ShaderProperty.floatType,
                                      "Mode",
                                      FloatType.Default,
                                      out var modePropertyEnumField));
            }
        }