Peter Bay Bastian
7 年前
当前提交
5fe33b9e
共有 8 个文件被更改,包括 184 次插入 和 179 次删除
-
128MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs
-
15MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/SerializationTests.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/SerializedGraphTests.cs
-
33MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/TestSlot.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/TestSlot.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/SerializableGraph/Implementation/SerializableSlot.cs.meta
-
134MaterialGraphProject/Assets/UnityShaderEditor/Editor/SerializableGraph/Implementation/SerializableSlot.cs
|
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public class TestSlot : MaterialSlot |
|||
{ |
|||
public TestSlot(int slotId, string displayName, SlotType slotType, ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false) |
|||
: base(slotId, displayName, displayName, slotType, shaderStage, hidden) {} |
|||
|
|||
public TestSlot(int slotId, string displayName, SlotType slotType, int priority, ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false) |
|||
: base(slotId, displayName, displayName, slotType, priority, shaderStage, hidden) {} |
|||
|
|||
public override SlotValueType valueType |
|||
{ |
|||
get { throw new System.NotImplementedException(); } |
|||
} |
|||
|
|||
public override ConcreteSlotValueType concreteValueType |
|||
{ |
|||
get { throw new System.NotImplementedException(); } |
|||
} |
|||
|
|||
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
|
|||
public override void CopyValuesFrom(MaterialSlot foundSlot) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e7e4d50a46ff471096f3c60fb06a364d |
|||
timeCreated: 1513346708 |
|
|||
fileFormatVersion: 2 |
|||
guid: 236912145b2fff1409d2b69157f5de23 |
|||
timeCreated: 1464264924 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Linq; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.Graphing |
|||
{ |
|||
[Serializable] |
|||
public class SerializableSlot : ISlot |
|||
{ |
|||
private const string kNotInit = "Not Initilaized"; |
|||
|
|||
[SerializeField] |
|||
private int m_Id; |
|||
|
|||
[SerializeField] |
|||
private string m_DisplayName = kNotInit; |
|||
|
|||
[SerializeField] |
|||
private SlotType m_SlotType = SlotType.Input; |
|||
|
|||
[SerializeField] |
|||
private int m_Priority = int.MaxValue; |
|||
|
|||
[SerializeField] |
|||
private bool m_Hidden; |
|||
|
|||
public SlotReference slotReference |
|||
{ |
|||
get { return new SlotReference(owner.guid, m_Id); } |
|||
} |
|||
|
|||
public INode owner { get; set; } |
|||
|
|||
public bool hidden |
|||
{ |
|||
get { return m_Hidden; } |
|||
set { m_Hidden = value; } |
|||
} |
|||
|
|||
public int id |
|||
{ |
|||
get { return m_Id; } |
|||
} |
|||
|
|||
public virtual string displayName |
|||
{ |
|||
get { return m_DisplayName; } |
|||
set { m_DisplayName = value; } |
|||
} |
|||
|
|||
public int priority |
|||
{ |
|||
get { return m_Priority; } |
|||
set { m_Priority = value; } |
|||
} |
|||
|
|||
public bool isInputSlot |
|||
{ |
|||
get { return m_SlotType == SlotType.Input; } |
|||
} |
|||
|
|||
public bool isOutputSlot |
|||
{ |
|||
get { return m_SlotType == SlotType.Output; } |
|||
} |
|||
|
|||
public SlotType slotType |
|||
{ |
|||
get { return m_SlotType; } |
|||
} |
|||
|
|||
// used via reflection / serialization after deserialize
|
|||
// to reconstruct this slot.
|
|||
public SerializableSlot() |
|||
{} |
|||
|
|||
public SerializableSlot(int id, string displayName, SlotType slotType, int priority, bool hidden = false) |
|||
{ |
|||
m_Id = id; |
|||
m_DisplayName = displayName; |
|||
m_SlotType = slotType; |
|||
m_Priority = priority; |
|||
m_Hidden = hidden; |
|||
} |
|||
|
|||
public SerializableSlot(int id, string displayName, SlotType slotType, bool hidden = false) |
|||
{ |
|||
m_Id = id; |
|||
m_DisplayName = displayName; |
|||
m_SlotType = slotType; |
|||
m_Hidden = hidden; |
|||
} |
|||
|
|||
protected bool Equals(SerializableSlot other) |
|||
{ |
|||
return m_Id == other.m_Id && owner.guid.Equals(other.owner.guid); |
|||
} |
|||
|
|||
public bool Equals(ISlot other) |
|||
{ |
|||
return Equals(other as object); |
|||
} |
|||
|
|||
public override bool Equals(object obj) |
|||
{ |
|||
if (ReferenceEquals(null, obj)) return false; |
|||
if (ReferenceEquals(this, obj)) return true; |
|||
if (obj.GetType() != this.GetType()) return false; |
|||
return Equals((SerializableSlot)obj); |
|||
} |
|||
|
|||
public override int GetHashCode() |
|||
{ |
|||
unchecked |
|||
{ |
|||
return (m_Id * 397) ^ (owner != null ? owner.GetHashCode() : 0); |
|||
} |
|||
} |
|||
|
|||
public bool isConnected |
|||
{ |
|||
get |
|||
{ |
|||
// node and graph respectivly
|
|||
if (owner == null || owner.owner == null) |
|||
return false; |
|||
|
|||
var graph = owner.owner; |
|||
var edges = graph.GetEdges(slotReference); |
|||
return edges.Any(); |
|||
} |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue