|
|
|
|
|
|
|
|
|
|
public void RemoveShaderProperty(Guid guid) |
|
|
|
{ |
|
|
|
var propertyNodes = GetNodes<PropertyNode>().Where(x => x.propertyGuid == guid).ToArray(); |
|
|
|
foreach (var pNode in propertyNodes) |
|
|
|
pNode.ReplaceWithConcreteNode(); |
|
|
|
RemoveShaderPropertyNoValidate(guid); |
|
|
|
ValidateGraph(); |
|
|
|
} |
|
|
|
void RemoveShaderPropertyNoValidate(Guid guid) |
|
|
|
{ |
|
|
|
public void ReplacePropertyNodeWithConcreteNode(PropertyNode propertyNode) |
|
|
|
{ |
|
|
|
var property = properties.FirstOrDefault(x => x.guid == propertyNode.propertyGuid); |
|
|
|
if (property != null) |
|
|
|
{ |
|
|
|
AbstractMaterialNode node = null; |
|
|
|
int slotId = -1; |
|
|
|
if (property is FloatShaderProperty) |
|
|
|
{ |
|
|
|
var createdNode = new Vector1Node(); |
|
|
|
createdNode.value = ((FloatShaderProperty) property).value; |
|
|
|
slotId = Vector1Node.OutputSlotId; |
|
|
|
node = createdNode; |
|
|
|
} |
|
|
|
else if (property is Vector2ShaderProperty) |
|
|
|
{ |
|
|
|
var createdNode = new Vector2Node(); |
|
|
|
createdNode.value = ((Vector2ShaderProperty) property).value; |
|
|
|
slotId = Vector2Node.OutputSlotId; |
|
|
|
node = createdNode; |
|
|
|
} |
|
|
|
else if (property is Vector3ShaderProperty) |
|
|
|
{ |
|
|
|
var createdNode = new Vector3Node(); |
|
|
|
createdNode.value = ((Vector3ShaderProperty) property).value; |
|
|
|
slotId = Vector3Node.OutputSlotId; |
|
|
|
node = createdNode; |
|
|
|
} |
|
|
|
else if (property is Vector4ShaderProperty) |
|
|
|
{ |
|
|
|
var createdNode = new Vector4Node(); |
|
|
|
createdNode.value = ((Vector4ShaderProperty) property).value; |
|
|
|
slotId = Vector4Node.OutputSlotId; |
|
|
|
node = createdNode; |
|
|
|
} |
|
|
|
else if (property is ColorShaderProperty) |
|
|
|
{ |
|
|
|
var createdNode = new ColorNode(); |
|
|
|
createdNode.color = ((ColorShaderProperty) property).value; |
|
|
|
slotId = ColorNode.OutputSlotId; |
|
|
|
node = createdNode; |
|
|
|
} |
|
|
|
|
|
|
|
if (node == null) |
|
|
|
return; |
|
|
|
|
|
|
|
var slot = propertyNode.FindOutputSlot<MaterialSlot>(PropertyNode.OutputSlotId); |
|
|
|
node.drawState = propertyNode.drawState; |
|
|
|
AddNodeNoValidate(node); |
|
|
|
|
|
|
|
foreach (var edge in GetEdges(slot.slotReference).ToArray()) |
|
|
|
ConnectNoValidate(node.GetSlotReference(slotId), edge.inputSlot); |
|
|
|
|
|
|
|
RemoveNodeNoValidate(propertyNode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public override void ValidateGraph() |
|
|
|
{ |
|
|
|
var propertyNodes = GetNodes<PropertyNode>().Where(n => !m_Properties.Any(p => p.guid == n.propertyGuid)).ToArray(); |
|
|
|
foreach (var pNode in propertyNodes) |
|
|
|
ReplacePropertyNodeWithConcreteNode(pNode); |
|
|
|
base.ValidateGraph(); |
|
|
|
} |
|
|
|
|
|
|
|
public override Dictionary<SerializationHelper.TypeSerializationInfo, SerializationHelper.TypeSerializationInfo> GetLegacyTypeRemapping() |
|
|
|
{ |
|
|
|
var result = base.GetLegacyTypeRemapping(); |
|
|
|
|
|
|
foreach (var property in m_Properties) |
|
|
|
removedPropertyGuids.Add(property.guid); |
|
|
|
foreach (var propertyGuid in removedPropertyGuids) |
|
|
|
RemoveShaderProperty(propertyGuid); |
|
|
|
RemoveShaderPropertyNoValidate(propertyGuid); |
|
|
|
} |
|
|
|
foreach (var otherProperty in otherMG.properties) |
|
|
|
{ |
|
|
|