示例#1
0
        public static VFXMaterialSerializedSettings CreateFromMaterial(Material material)
        {
            VFXMaterialSerializedSettings settings = new VFXMaterialSerializedSettings();

            settings.SyncFromMaterial(material);
            return(settings);
        }
        public override void SetupMaterial(Material material)
        {
            var shaderGraph = GetOrRefreshShaderGraphObject();

            if (shaderGraph != null && shaderGraph.generatesWithShaderGraph)
            {
                // In certain scenarios the context might not be configured with any serialized material information
                // when assigned a shader graph for the first time. In this case we sync the settings to the incoming material,
                // which will be pre-configured by shader graph with the render state & other properties (i.e. a SG with Transparent surface).
                if (materialSettings.NeedsSync())
                {
                    materialSettings.SyncFromMaterial(material);
                    Invalidate(InvalidationCause.kSettingChanged);
                    return;
                }

                materialSettings.ApplyToMaterial(material);
                VFXLibrary.currentSRPBinder.SetupMaterial(material, hasMotionVector, hasShadowCasting, shaderGraph);

                transientMaterial = material;
                OnMaterialChange?.Invoke();
            }
        }