void OnChangeType(object type) { var op = controller.model; op.SetOperandType(m_CurrentIndex, (Type)type); IVFXOperatorNumericUnifiedConstrained constraintInterface = op as IVFXOperatorNumericUnifiedConstrained; if (constraintInterface != null) { if (!constraintInterface.slotIndicesThatCanBeScalar.Contains(m_CurrentIndex)) { foreach (var index in constraintInterface.slotIndicesThatMustHaveSameType) { if (index != m_CurrentIndex && (!constraintInterface.slotIndicesThatCanBeScalar.Contains(index) || VFXUnifiedConstraintOperatorController.GetMatchingScalar((Type)type) != op.GetOperandType(index))) { op.SetOperandType(index, (Type)type); } } } } }
void OnTypeMenu(Label button, int index) { var op = controller.model; GenericMenu menu = new GenericMenu(); var selectedType = op.GetOperandType(index); IVFXOperatorNumericUnifiedConstrained constraintInterface = op as IVFXOperatorNumericUnifiedConstrained; if (constraintInterface != null && constraintInterface.slotIndicesThatCanBeScalar.Contains(index)) { VFXSlot otherSlotWithConstraint = op.inputSlots.Where((t, i) => constraintInterface.slotIndicesThatMustHaveSameType.Contains(i) && !constraintInterface.slotIndicesThatCanBeScalar.Contains(i)).FirstOrDefault(); foreach (var type in op.validTypes) { if (otherSlotWithConstraint == null || otherSlotWithConstraint.property.type == type || VFXUnifiedConstraintOperatorController.GetMatchingScalar(otherSlotWithConstraint.property.type) == type) { menu.AddItem(EditorGUIUtility.TrTextContent(type.UserFriendlyName()), selectedType == type, OnChangeType, type); } } } else { foreach (var type in op.validTypes) { menu.AddItem(EditorGUIUtility.TrTextContent(type.UserFriendlyName()), selectedType == type, OnChangeType, type); } } m_CurrentIndex = index; menu.DropDown(button.worldBound); }