void BuildValue(VFXSlot slot) { foreach (var field in slot.property.type.GetFields()) { VFXSlot subSlot = slot.children.FirstOrDefault <VFXSlot>(t => t.name == field.Name); if (subSlot != null) { object result = null; if (subSlot.HasLink(true) && m_Controller.viewController.CanGetEvaluatedContent(subSlot) && (result = m_Controller.viewController.GetEvaluatedContent(subSlot)) != null) { m_ValueBuilder.Add(o => o.Add(m_Controller.viewController.GetEvaluatedContent(subSlot))); } else if (subSlot.HasLink(false) && VFXTypeUtility.GetComponentCount(subSlot) != 0) // replace by is VFXType { m_Indeterminate = true; return; } else { m_ValueBuilder.Add(o => o.Add(subSlot.value)); BuildValue(subSlot); if (m_Indeterminate) { return; } } m_ValueBuilder.Add(o => field.SetValue(o[o.Count - 2], o[o.Count - 1])); m_ValueBuilder.Add(o => o.RemoveAt(o.Count - 1)); } } }
protected override void InternalPrepare() { var type = m_Controller.portType; if (!type.IsValueType) { Debug.LogError("No support for class types in Gizmos"); return; } m_ValueBuilder.Clear(); m_ValueBuilder.Add(o => o.Add(m_Controller.value)); if (!m_Controller.viewController.CanGetEvaluatedContent(m_Controller.model)) { if (m_Controller.model.HasLink(false)) { if (VFXTypeUtility.GetComponentCount(m_Controller.model) != 0) { m_Indeterminate = true; return; } } BuildValue(m_Controller.model); } }
void BuildValue(VFXSlot slot) { foreach (var field in slot.property.type.GetFields()) { VFXSlot subSlot = slot.children.FirstOrDefault <VFXSlot>(t => t.name == field.Name); if (subSlot != null) { object result = null; if (subSlot.HasLink(true) && m_Controller.viewController.CanGetEvaluatedContent(subSlot) && (result = m_Controller.viewController.GetEvaluatedContent(subSlot)) != null) { m_ValueBuilder.Add(o => o.Add(m_Controller.viewController.GetEvaluatedContent(subSlot))); } else if (subSlot.HasLink(false) && VFXTypeUtility.GetComponentCount(subSlot) != 0) // replace by is VFXType { m_Indeterminate = true; return; } else { m_ValueBuilder.Add(o => o.Add(subSlot.value)); BuildValue(subSlot); if (m_Indeterminate) { return; } } m_ValueBuilder.Add(o => { var newValue = o[o.Count - 1]; var target = o[o.Count - 2]; if (newValue != null && field.FieldType != newValue.GetType()) { object convertedValue; if (!VFXConverter.TryConvertTo(newValue, field.FieldType, out convertedValue)) { throw new InvalidOperationException(string.Format("VFXDataAnchorGizmo is failing to convert from {0} to {1}", newValue.GetType(), field.FieldType)); } newValue = convertedValue; } field.SetValue(target, newValue); }); m_ValueBuilder.Add(o => o.RemoveAt(o.Count - 1)); } } }
public static System.Type GetDisplayAnchorType(VFXSlot slot) { System.Type newAnchorType = null; if (slot.property.type == typeof(FloatN) && slot.refSlot != null) { newAnchorType = VFXTypeUtility.GetFloatTypeFromComponentCount(VFXTypeUtility.GetComponentCount(slot.refSlot)); if (newAnchorType == null) { newAnchorType = typeof(FloatN); } } else { newAnchorType = slot.property.type; } return(newAnchorType); }
protected override bool CouldLinkMyInputTo(VFXDataAnchorController myInput, VFXDataAnchorController otherOutput, VFXDataAnchorController.CanLinkCache cache) { if (!myInput.model.IsMasterSlot()) { return(false); } if (otherOutput.direction == myInput.direction) { return(false); } if (!myInput.CanLinkToNode(otherOutput.sourceNode, cache)) { return(false); } int inputIndex = model.GetSlotIndex(myInput.model); IVFXOperatorNumericUnifiedConstrained constraintInterface = model as IVFXOperatorNumericUnifiedConstrained; var bestAffinityType = model.GetBestAffinityType(otherOutput.portType); if (bestAffinityType == null) { return(false); } if (constraintInterface.slotIndicesThatCanBeScalar.Contains(inputIndex)) { if (VFXTypeUtility.GetComponentCount(otherOutput.model) != 0) // If it is a vector or float type, then conversion to float exists { return(true); } } return(model.GetBestAffinityType(otherOutput.portType) != null); }