GitHub
7 年前
当前提交
eb5b5a85
共有 13 个文件被更改,包括 284 次插入 和 99 次删除
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialGraphAsset.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightUnlitSubShader.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs
-
57MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/FunctionRegistry.cs
-
90MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs
-
88MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderStringBuilder.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
-
21MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GenerationResults.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GenerationResults.cs.meta
-
64MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderSourceMap.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderSourceMap.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public class GenerationResults |
|||
{ |
|||
public string shader { get; set; } |
|||
public List<PropertyCollector.TextureInfo> configuredTextures; |
|||
public PreviewMode previewMode { get; set; } |
|||
public FloatShaderProperty outputIdProperty { get; set; } |
|||
public Dictionary<Guid, int> ids { get; set; } |
|||
public ShaderSourceMap sourceMap { get; set; } |
|||
|
|||
public GenerationResults() |
|||
{ |
|||
configuredTextures = new List<PropertyCollector.TextureInfo>(); |
|||
ids = new Dictionary<Guid, int>(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c922293e622b43f4a1cd25a1246a17dc |
|||
timeCreated: 1513866299 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public class ShaderSourceMap |
|||
{ |
|||
// Indicates where a new node begins
|
|||
List<int> m_LineStarts; |
|||
List<INode> m_Nodes; |
|||
int m_LineCount; |
|||
|
|||
internal ShaderSourceMap(string source, List<ShaderStringMapping> mappings) |
|||
{ |
|||
m_LineStarts = new List<int>(); |
|||
m_Nodes = new List<INode>(); |
|||
|
|||
var line = 0; |
|||
var currentIndex = 0; |
|||
foreach (var mapping in mappings) |
|||
{ |
|||
var stopIndex = mapping.startIndex + mapping.count; |
|||
if (currentIndex >= stopIndex) |
|||
continue; |
|||
|
|||
m_LineStarts.Add(line); |
|||
m_Nodes.Add(mapping.node); |
|||
|
|||
while (currentIndex < stopIndex && currentIndex != -1) |
|||
{ |
|||
currentIndex = source.IndexOf('\n', currentIndex+1); |
|||
line++; |
|||
} |
|||
|
|||
if (currentIndex == -1) |
|||
break; |
|||
} |
|||
|
|||
m_LineCount = line; |
|||
} |
|||
|
|||
public INode FindNode(int line) |
|||
{ |
|||
if (line >= m_LineCount || line < 0) |
|||
return null; |
|||
var l = 0; |
|||
var r = m_LineStarts.Count - 1; |
|||
while (l <= r) |
|||
{ |
|||
var m = (l + r) / 2; |
|||
var lineStart = m_LineStarts[m]; |
|||
var lineStop = m == m_LineStarts.Count ? m_LineCount : m_LineStarts[m + 1]; |
|||
if (line >= lineStop) |
|||
l = m + 1; |
|||
else if (line < lineStart) |
|||
r = m - 1; |
|||
else |
|||
return m_Nodes[m]; |
|||
} |
|||
throw new Exception("Something went wrong in binary search"); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f6c222989d9946e8a85c01ba541f4b41 |
|||
timeCreated: 1513867574 |
撰写
预览
正在加载...
取消
保存
Reference in new issue