浏览代码

Shader name is now the name of the file.

/main
Tim Cooper 7 年前
当前提交
e3f06249
共有 7 个文件被更改,包括 10 次插入13 次删除
  1. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
  2. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/shader.template
  3. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs
  4. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
  5. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Remapper/RemapMasterNode.cs
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
  7. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/ExportTextureMasterNode.cs

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs


if (masterNode == null)
return null;
var name = Path.GetFileNameWithoutExtension(path);
var shaderString = masterNode.GetFullShader(GenerationMode.ForReals, graph.name, out configuredTextures);
var shaderString = masterNode.GetFullShader(GenerationMode.ForReals, string.Format("graphs/{0}", name), out configuredTextures);
return shaderString;
}
catch (Exception)

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/shader.template


Shader "Graph/${ShaderName}"
Shader "${ShaderName}"
{
Properties
{

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs


Assert.IsNotNull(graph.masterNode, "No master node in graph.");
//var graphAsset = AssetDatabase.LoadAssetAtPath<MaterialGraphAsset>(filePath);
//
//Assert.IsNotNull(graphAsset, "Graph asset not found");

// Generate the shader
List<PropertyGenerator.TextureInfo> configuredTextures;
var shaderString =
graph.masterNode.GetFullShader(GenerationMode.ForReals, graph.name, out configuredTextures);
graph.masterNode.GetFullShader(GenerationMode.ForReals, Path.GetFileNameWithoutExtension(filePath), out configuredTextures);
var rootPath = Directory.GetParent(Directory.GetParent(Application.dataPath).ToString());
var shaderTemplatePath = Path.Combine(rootPath.ToString(), "ShaderTemplates");

7
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs


m_ActiveMasterNodeGUID = Guid.NewGuid();
else
m_ActiveMasterNodeGUID = value.guid;
}
public string name
{
get { return "Graph_ " + masterNode.GetVariableNameForNode(); }
}
public override void OnBeforeSerialize()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Remapper/RemapMasterNode.cs


var subShaders = remapAsset.masterRemapGraph.GetSubShadersFor(this, mode, shaderPropertiesVisitor);
var templateText = File.ReadAllText(shaderTemplateLocation);
var resultShader = templateText.Replace("${ShaderName}", GetType() + guid.ToString());
var resultShader = templateText.Replace("${ShaderName}", name);
resultShader = resultShader.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
if (subShaders != null)
resultShader = resultShader.Replace("${SubShader}", subShaders.Aggregate(string.Empty, (i, j) => i + Environment.NewLine + j));

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs


var templateText = File.ReadAllText(templateLocation);
var shaderPropertiesVisitor = new PropertyGenerator();
var resultShader = templateText.Replace("${ShaderName}", GetType() + guid.ToString());
var resultShader = templateText.Replace("${ShaderName}", name);
resultShader = resultShader.Replace("${SubShader}", GetSubShader(mode, shaderPropertiesVisitor));
resultShader = resultShader.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
configuredTextures = shaderPropertiesVisitor.GetConfiguredTexutres();

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/ExportTextureMasterNode.cs


ListPool<INode>.Release(activeNodeList);
template = template.Replace("${ShaderName}", GetType() + guid.ToString());
template = template.Replace("${ShaderName}", name);
template = template.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
template = template.Replace("${ShaderPropertyUsages}", shaderPropertyUsagesVisitor.GetShaderString(3));
template = template.Replace("${ShaderFunctions}", shaderFunctionVisitor.GetShaderString(3));

正在加载...
取消
保存