コード例 #1
0
        public ResultSet CreateShaderGraphs()
        {
            var resultSetBuilder = new ResultSetBuilder();

            AssetDatabase.StartAssetEditing();

            for (var i = 0; i < _materialList.Count; i++)
            {
                var document  = _materialList[i];
                var processor = new MaterialDocumentProcessor();

                RaiseStepEvent(document.FileName, i);

                var result   = processor.Convert(document);
                var material = result.RootNode;

                resultSetBuilder.AddProcessorProblems(result.Problems, document.FileName);

                if (material == null)
                {
                    continue;
                }

                var shaderGraph = ShaderGraphBuilder.FromMaterial(material);
                shaderGraph.ValidateGraph();

                var content    = JsonUtility.ToJson(shaderGraph);
                var outputPath = MakeOutputPathForShaderGraph(document);

                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
                File.WriteAllText(outputPath, content, Encoding.UTF8);
            }

            AssetDatabase.StopAssetEditing();
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);

            return(resultSetBuilder.ToResultSet());
        }
 public virtual void CreateConnections(T unrealNode, Material unrealMaterial, ShaderGraphBuilder builder)
 {
 }
        public override void CreateConnections(Node unrealNode, Material unrealMaterial, ShaderGraphBuilder builder)
        {
            var unrealNodeAsT = (T)unrealNode;

            if (unrealNodeAsT != null)
            {
                CreateConnections(unrealNodeAsT, unrealMaterial, builder);
            }
        }