浏览代码
* Add individual properties to node search
* Add individual properties to node search
* Remove dropdown from property node * Add all compatible slots to node search when dragging into empty space */main
Peter Bay Bastian
7 年前
当前提交
484b4f58
共有 5 个文件被更改,包括 65 次插入 和 97 次删除
-
21MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs
-
82MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/SearchWindowProvider.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs.meta
-
53MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs
|
|||
fileFormatVersion: 2 |
|||
guid: bb1167be0ec94c0a849394d34df45a98 |
|||
timeCreated: 1507819549 |
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEditor.ShaderGraph; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing.Controls |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Property)] |
|||
public class PropertyControlAttribute : Attribute, IControlAttribute |
|||
{ |
|||
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
return new PropertyControlView(node); |
|||
} |
|||
} |
|||
|
|||
public class PropertyControlView : VisualElement, INodeModificationListener |
|||
{ |
|||
PropertyNode m_Node; |
|||
|
|||
public PropertyControlView(AbstractMaterialNode node) |
|||
{ |
|||
m_Node = (PropertyNode)node; |
|||
|
|||
Add(new IMGUIContainer(OnGUIHandler)); |
|||
} |
|||
|
|||
void OnGUIHandler() |
|||
{ |
|||
var graph = m_Node.owner as AbstractMaterialGraph; |
|||
var currentGUID = m_Node.propertyGuid; |
|||
var properties = graph.properties.ToList(); |
|||
var propertiesGUID = properties.Select(x => x.guid).ToList(); |
|||
var currentSelectedIndex = propertiesGUID.IndexOf(currentGUID); |
|||
using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) |
|||
{ |
|||
var value = EditorGUILayout.Popup(currentSelectedIndex, properties.Select(x => x.displayName).ToArray()); |
|||
if (changeCheckScope.changed) |
|||
{ |
|||
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name); |
|||
m_Node.propertyGuid = propertiesGUID[value]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void OnNodeModified(ModificationScope scope) |
|||
{ |
|||
Dirty(ChangeType.Repaint); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue