public void ConvertToInline() { VFXInlineOperator op = ScriptableObject.CreateInstance <VFXInlineOperator>(); op.SetSettingValue("m_Type", (SerializableType)parentController.model.type); viewController.graph.AddChild(op); op.position = position; if (infos.linkedSlots != null) { foreach (var link in infos.linkedSlots.ToArray()) { var ancestors = new List <VFXSlot>(); ancestors.Add(link.outputSlot); VFXSlot parent = link.outputSlot.GetParent(); while (parent != null) { ancestors.Add(parent); parent = parent.GetParent(); } int index = parentController.model.GetSlotIndex(ancestors.Last()); if (index >= 0 && index < op.GetNbOutputSlots()) { VFXSlot slot = op.outputSlots[index]; for (int i = ancestors.Count() - 2; i >= 0; --i) { int subIndex = ancestors[i + 1].GetIndex(ancestors[i]); if (subIndex >= 0 && subIndex < slot.GetNbChildren()) { slot = slot[subIndex]; } else { slot = null; break; } } if (slot.path != link.outputSlot.path.Substring(1)) // parameters output are still named 0, inline outputs have no name. { Debug.LogError("New inline don't have the same subslot as old parameter"); } else { link.outputSlot.Unlink(link.inputSlot); slot.Link(link.inputSlot); } } } } op.inputSlots[0].value = value; viewController.LightApplyChanges(); viewController.PutInSameGroupNodeAs(viewController.GetNodeController(op, 0), this); viewController.RemoveElement(this); }
private void CheckVectorSlotCreation(Type type, VFXSlot.Direction direction, int expectionChildrenNb) { VFXSlot slot = VFXSlot.Create(new VFXProperty(type, "test"), direction); Assert.IsNotNull(slot); Assert.AreEqual(expectionChildrenNb, slot.GetNbChildren()); Assert.IsInstanceOf <VFXExpressionCombine>(slot.GetExpression()); foreach (var child in slot.children) { Assert.IsNotNull(child); Assert.AreEqual(0, child.GetNbChildren()); Assert.IsInstanceOf <VFXExpressionExtractComponent>(child.GetExpression()); } }
static VFXSlot FetchSlot(IVFXSlotContainer container, int[] slotPath, bool input) { int containerSlotIndex = slotPath[slotPath.Length - 1]; VFXSlot slot = null; if (input) { if (container.GetNbInputSlots() > containerSlotIndex) { slot = container.GetInputSlot(slotPath[slotPath.Length - 1]); } } else { if (container.GetNbOutputSlots() > containerSlotIndex) { slot = container.GetOutputSlot(slotPath[slotPath.Length - 1]); } } if (slot == null) { return(null); } for (int i = slotPath.Length - 2; i >= 0; --i) { if (slot.GetNbChildren() > slotPath[i]) { slot = slot[slotPath[i]]; } else { return(null); } } return(slot); }