浏览代码

Add text field on properties to allow a custom reference name

/main
Jens Holm 7 年前
当前提交
b68215c9
共有 3 个文件被更改,包括 53 次插入0 次删除
  1. 28
      com.unity.shadergraph/Editor/Data/Graphs/AbstractShaderProperty.cs
  2. 2
      com.unity.shadergraph/Editor/Data/Graphs/IShaderProperty.cs
  3. 23
      com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs

28
com.unity.shadergraph/Editor/Data/Graphs/AbstractShaderProperty.cs


private string m_Name;
[SerializeField]
private string m_CustomReferenceName;
[SerializeField]
[SerializeField]
private bool m_UseCustomReferenceName = false;
[SerializeField]
private SerializableGuid m_Guid = new SerializableGuid();

set { m_Name = value; }
}
public string customReferenceName
{
get
{
if (string.IsNullOrEmpty(m_CustomReferenceName))
m_CustomReferenceName = "_" + displayName;
return m_CustomReferenceName;
}
set { m_CustomReferenceName = value; }
}
string m_DefaultReferenceName;
public string referenceName

if (useCustomReferenceName)
{
return customReferenceName;
}
if (string.IsNullOrEmpty(overrideReferenceName))
{
if (string.IsNullOrEmpty(m_DefaultReferenceName))

{
get { return m_GeneratePropertyBlock; }
set { m_GeneratePropertyBlock = value; }
}
public bool useCustomReferenceName
{
get { return m_UseCustomReferenceName; }
set { m_UseCustomReferenceName = value; }
}
public abstract Vector4 defaultValue { get; }

2
com.unity.shadergraph/Editor/Data/Graphs/IShaderProperty.cs


PropertyType propertyType { get; }
Guid guid { get; }
bool generatePropertyBlock { get; set; }
bool useCustomReferenceName { get; set; }
string customReferenceName { get; set; }
Vector4 defaultValue { get; }
string overrideReferenceName { get; set; }

23
com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs


using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using Toggle = UnityEngine.Experimental.UIElements.Toggle;
namespace UnityEditor.ShaderGraph.Drawing
{

Toggle m_UseCustomReferenceNameToggle;
TextField m_ReferenceNameField;
m_ReferenceNameField = new TextField(30, false, false, ' ');
AddRow("Reference name", m_ReferenceNameField);
m_UseCustomReferenceNameToggle = new Toggle(() =>
{
property.useCustomReferenceName = m_UseCustomReferenceNameToggle.on;
m_ReferenceNameField.SetEnabled(property.useCustomReferenceName);
m_Graph.ValidateGraph();
});
m_UseCustomReferenceNameToggle.on = property.useCustomReferenceName;
m_ReferenceNameField.value = property.customReferenceName;
m_ReferenceNameField.SetEnabled(property.useCustomReferenceName);
m_ReferenceNameField.OnValueChanged(newName =>
{
property.customReferenceName = newName.newValue;
});
AddRow("Specify reference name", m_UseCustomReferenceNameToggle);
if (property is Vector1ShaderProperty)
{
VisualElement floatRow = new VisualElement();

// AddRow("Range", new Toggle(null));
// AddRow("Default", new TextField());
// AddRow("Tooltip", new TextField());
AddToClassList("sgblackboardFieldPropertyView");
}

正在加载...
取消
保存