浏览代码

Ignore the subjected property when sanitizing name

/main
Peter Bay Bastian 6 年前
当前提交
ad7f7e58
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 6
      com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs
  2. 2
      com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs

6
com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs


m_AddedProperties.Add(property);
}
public string SanitizePropertyName(string displayName)
public string SanitizePropertyName(string displayName, Guid guid = default(Guid))
if (m_Properties.Any(p => p.displayName == displayName))
if (m_Properties.Any(p => p.displayName == displayName && p.guid != guid))
{
// Strip out the " (n)" part of the name.
var baseRegex = new Regex(@"^(.*) \((\d+)\)$");

var regex = new Regex(@"^" + Regex.Escape(displayName) + @" \((\d+)\)$");
var existingDuplicateNumbers = m_Properties.Select(p => regex.Match(p.displayName)).Where(m => m.Success).Select(m => int.Parse(m.Groups[1].Value)).Where(n => n > 0).Distinct().ToList();
var existingDuplicateNumbers = m_Properties.Where(p => p.guid != guid).Select(p => regex.Match(p.displayName)).Where(m => m.Success).Select(m => int.Parse(m.Groups[1].Value)).Where(n => n > 0).Distinct().ToList();
var duplicateNumber = 1;
existingDuplicateNumbers.Sort();

2
com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs


if (!string.IsNullOrEmpty(newText) && newText != property.displayName)
{
m_Graph.owner.RegisterCompleteObjectUndo("Edit Property Name");
newText = m_Graph.SanitizePropertyName(newText);
newText = m_Graph.SanitizePropertyName(newText, property.guid);
property.displayName = newText;
field.text = newText;
DirtyNodes();

正在加载...
取消
保存