您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
69 行
1.7 KiB
69 行
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.Graphs.Material
|
|
{
|
|
public abstract class PropertyNode : BaseMaterialNode, IGenerateProperties
|
|
{
|
|
[SerializeField]
|
|
private ShaderProperty m_BoundProperty;
|
|
|
|
public bool exposed
|
|
{
|
|
get { return m_BoundProperty != null; }
|
|
}
|
|
|
|
protected virtual bool HasBoundProperty() { return m_BoundProperty != null; }
|
|
public ShaderProperty boundProperty { get { return m_BoundProperty; } }
|
|
|
|
public virtual void BindProperty(ShaderProperty property, bool rebuildShaders)
|
|
{
|
|
m_BoundProperty = property;
|
|
}
|
|
|
|
public virtual void RefreshBoundProperty (ShaderProperty toRefresh, bool rebuildShader)
|
|
{
|
|
if (m_BoundProperty != null && m_BoundProperty == toRefresh)
|
|
{
|
|
BindProperty (toRefresh, rebuildShader);
|
|
}
|
|
}
|
|
|
|
public IEnumerable<ShaderProperty> FindValidPropertyBindings()
|
|
{
|
|
if (graph is IGenerateGraphProperties)
|
|
return (graph as IGenerateGraphProperties).GetPropertiesForPropertyType(propertyType);
|
|
|
|
return new ShaderProperty[0];
|
|
}
|
|
|
|
public virtual string GetPropertyName()
|
|
{
|
|
if (m_BoundProperty == null)
|
|
return name + "_" + Math.Abs(GetInstanceID());
|
|
|
|
return m_BoundProperty.name;
|
|
}
|
|
|
|
public abstract PropertyType propertyType { get; }
|
|
|
|
public abstract PreviewProperty GetPreviewProperty ();
|
|
|
|
public override void UpdatePreviewProperties ( )
|
|
{
|
|
base.UpdatePreviewProperties ();
|
|
MaterialWindow.DebugMaterialGraph ("In Property Node: " + this);
|
|
SetDependentPreviewMaterialProperty (GetPreviewProperty ());
|
|
}
|
|
|
|
public void UnbindProperty (ShaderProperty prop)
|
|
{
|
|
if (m_BoundProperty != null && m_BoundProperty == prop)
|
|
{
|
|
m_BoundProperty = null;
|
|
RegeneratePreviewShaders();
|
|
}
|
|
}
|
|
}
|
|
}
|