|
|
|
|
|
|
|
|
|
|
static Type s_ContextualMenuManipulator = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypesOrNothing()).FirstOrDefault(t => t.FullName == "UnityEngine.Experimental.UIElements.ContextualMenuManipulator"); |
|
|
|
|
|
|
|
IManipulator m_ResetReferenceMenu; |
|
|
|
|
|
|
|
public BlackboardFieldPropertyView(AbstractMaterialGraph graph, IShaderProperty property) |
|
|
|
{ |
|
|
|
m_Graph = graph; |
|
|
|
|
|
|
AddRow("Reference name", m_ReferenceNameField); |
|
|
|
AddRow("Reference", m_ReferenceNameField); |
|
|
|
string newReferenceName = m_Graph.SanitizePropertyReferenceName(newName.newValue); |
|
|
|
string newReferenceName = m_Graph.SanitizePropertyReferenceName(newName.newValue, property.guid); |
|
|
|
m_ReferenceNameField.value = newReferenceName; |
|
|
|
m_ReferenceNameField.style.fontStyle = StyleValue<FontStyle>.Create(FontStyle.Bold); |
|
|
|
m_ReferenceNameField.value = property.referenceName; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(property.overrideReferenceName)) |
|
|
|
m_ReferenceNameField.style.fontStyle = StyleValue<FontStyle>.Create(FontStyle.Normal); |
|
|
|
else |
|
|
|
m_ReferenceNameField.style.fontStyle = StyleValue<FontStyle>.Create(FontStyle.Bold); |
|
|
|
|
|
|
|
UpdateReferenceNameResetMenu(); |
|
|
|
}); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(property.overrideReferenceName)) |
|
|
|
|
|
|
|
|
|
|
AddToClassList("sgblackboardFieldPropertyView"); |
|
|
|
|
|
|
|
this.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu)); |
|
|
|
UpdateReferenceNameResetMenu(); |
|
|
|
} |
|
|
|
|
|
|
|
void UpdateReferenceNameResetMenu() |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(m_Property.overrideReferenceName)) |
|
|
|
{ |
|
|
|
this.RemoveManipulator(m_ResetReferenceMenu); |
|
|
|
m_ResetReferenceMenu = null; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
m_ResetReferenceMenu = (IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu); |
|
|
|
this.AddManipulator(m_ResetReferenceMenu); |
|
|
|
} |
|
|
|
evt.menu.AppendAction("Reset reference name", e => |
|
|
|
evt.menu.AppendAction("Reset reference", e => |
|
|
|
{ |
|
|
|
m_Property.overrideReferenceName = null; |
|
|
|
m_ReferenceNameField.value = m_Property.referenceName; |
|
|
|