浏览代码

Fix shader include paths, update gitignore, add meta files and replace UNITY_SHADERGRAPH_DEVMODE with an optional DebugOutput directory

/main
Peter Bay Bastian 7 年前
当前提交
00564880
共有 7 个文件被更改,包括 66 次插入31 次删除
  1. 24
      .gitignore
  2. 3
      com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs
  3. 28
      com.unity.shadergraph/Editor/DefaultShaderIncludes.cs
  4. 21
      com.unity.shadergraph/Editor/Drawing/PreviewManager.cs
  5. 7
      LICENSE.meta
  6. 7
      README.md.meta
  7. 7
      build.py.meta

24
.gitignore


artifacts/**
build/**
MaterialGraphProject/.vs
MaterialGraphProject/.vscode
MaterialGraphProject/Library
MaterialGraphProject/obj
MaterialGraphProject/MaterialGraphProject.CSharp.csproj
MaterialGraphProject/MaterialGraphProject.sln.DotSettings.user
*.csproj
MaterialGraphProject/MaterialGraphProject.sln
MaterialGraphProject/Temp
MaterialGraphProject/MaterialGraphProject.userprefs
MaterialGraphProject/.idea
MaterialGraphProject/Assets/Plugins*
.vs
.vscode
.idea
MaterialGraphProject/Assets/_MingWai/New Custom Texture.asset.meta
MaterialGraphProject/Packages/*
MaterialGraphProject/GeneratedShader.shader
MaterialGraphProject/UberShader.shader
!MaterialGraphProject/Packages/manifest.json
.npmrc
.npmrc
DebugOutput.meta
DebugOutput/**

3
com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs


var path = new List<string>
{
Application.dataPath,
"UnityShaderEditor",
"ShaderGraph",
"com.unity.shadergraph",
"Editor",
"Templates"
};

28
com.unity.shadergraph/Editor/DefaultShaderIncludes.cs


using System.IO;
using System.Linq;
using UnityEngine;
public static string GetAssetsPackagePath()
{
var packageDirectories = Directory.GetDirectories(Application.dataPath, "com.unity.shadergraph", SearchOption.AllDirectories);
return packageDirectories.Length == 0 ? null : Path.GetFullPath(packageDirectories.First());
}
public static string GetRepositoryPath()
{
var path = GetAssetsPackagePath();
if (path == null)
return null;
return Path.GetFullPath(Directory.GetParent(path).ToString());
}
public static string GetDebugOutputPath()
{
var path = GetRepositoryPath();
if (path == null)
return null;
path = Path.Combine(path, "DebugOutput");
return Directory.Exists(path) ? path : null;
}
Path.GetFullPath("Assets/UnityShaderEditor"),
Path.GetFullPath("Packages/com.unity.shadergraph"),
GetAssetsPackagePath() ?? Path.GetFullPath("Packages/com.unity.shadergraph")
};
}
}

21
com.unity.shadergraph/Editor/Drawing/PreviewManager.cs


var results = m_Graph.GetUberPreviewShader();
m_OutputIdName = results.outputIdProperty.referenceName;
ShaderUtil.UpdateShaderAsset(m_UberShader, results.shader);
#if UNITY_SHADER_GRAPH_DEVMODE
File.WriteAllText(Application.dataPath + "/../UberShader.shader", (results.shader ?? "null").Replace("UnityEngine.MaterialGraph", "Generated"));
#endif
var debugOutputPath = DefaultShaderIncludes.GetDebugOutputPath();
if (debugOutputPath != null)
File.WriteAllText(debugOutputPath + "/UberShader.shader", (results.shader ?? "null").Replace("UnityEngine.MaterialGraph", "Generated"));
bool uberShaderHasError = false;
if (MaterialGraphAsset.ShaderHasError(m_UberShader))
{

shaderData.shaderString = m_Graph.GetPreviewShader(node).shader;
}
#if UNITY_SHADER_GRAPH_DEVMODE
File.WriteAllText(Application.dataPath + "/../GeneratedShader.shader", (shaderData.shaderString ?? "null").Replace("UnityEngine.MaterialGraph", "Generated"));
#endif
var debugOutputPath = DefaultShaderIncludes.GetDebugOutputPath();
if (debugOutputPath != null)
File.WriteAllText(debugOutputPath + "/GeneratedShader.shader", (shaderData.shaderString ?? "null").Replace("UnityEngine.MaterialGraph", "Generated"));
if (string.IsNullOrEmpty(shaderData.shaderString))
{

}
// Debug output
#if UNITY_SHADER_GRAPH_DEVMODE
var message = "RecreateShader: " + node.GetVariableNameForNode() + Environment.NewLine + shaderData.shaderString;
#endif
Debug.LogWarning(message);
if (debugOutputPath != null)
{
var message = "RecreateShader: " + node.GetVariableNameForNode() + Environment.NewLine + shaderData.shaderString;
Debug.LogWarning(message);
}
ShaderUtil.ClearShaderErrors(shaderData.shader);
Object.DestroyImmediate(shaderData.shader, true);
shaderData.shader = null;

7
LICENSE.meta


fileFormatVersion: 2
guid: ccd80e6f5d1fa7e4dbe10a0163abd393
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
README.md.meta


fileFormatVersion: 2
guid: 08534868baca5cc4092711da8c94e981
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
build.py.meta


fileFormatVersion: 2
guid: 7b1a0d0e4b2baea45969a56eca979c72
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存