void UK2Node_AddComponent::AllocatePinsForExposedVariables()
{
	const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();

	const UActorComponent* TemplateComponent = GetTemplateFromNode();
	const UClass* ComponentClass = TemplateComponent ? TemplateComponent->GetClass() : nullptr;

	if (ComponentClass != nullptr)
	{
		const UObject* ClassDefaultObject = ComponentClass ? ComponentClass->ClassDefaultObject : nullptr;

		for (TFieldIterator<UProperty> PropertyIt(ComponentClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt)
		{
			UProperty* Property = *PropertyIt;
			const bool bNotDelegate = !Property->IsA(UMulticastDelegateProperty::StaticClass());
			const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property);
			const bool bIsVisible = Property->HasAllPropertyFlags(CPF_BlueprintVisible);
			const bool bNotParam = !Property->HasAllPropertyFlags(CPF_Parm);
			if(bNotDelegate && bIsExposedToSpawn && bIsVisible && bNotParam)
			{
				FEdGraphPinType PinType;
				K2Schema->ConvertPropertyToPinType(Property, /*out*/ PinType);	
				const bool bIsUnique = (NULL == FindPin(Property->GetName()));
				if (K2Schema->FindSetVariableByNameFunction(PinType) && bIsUnique)
				{
					UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName());
					Pin->PinType = PinType;
					bHasExposedVariable = true;

					if ((ClassDefaultObject != nullptr) && K2Schema->PinDefaultValueIsEditable(*Pin))
					{
						FString DefaultValueAsString;
						const bool bDefaultValueSet = FBlueprintEditorUtils::PropertyValueToString(Property, reinterpret_cast<const uint8*>(ClassDefaultObject), DefaultValueAsString);
						check(bDefaultValueSet);
						K2Schema->TrySetDefaultValue(*Pin, DefaultValueAsString);
					}

					// Copy tooltip from the property.
					K2Schema->ConstructBasicPinTooltip(*Pin, Property->GetToolTipText(), Pin->PinToolTip);
				}
			}
		}
	}

	// Hide transform and attachment pins if it is not a scene component
	const bool bHideTransformPins = (ComponentClass != nullptr) ? !ComponentClass->IsChildOf(USceneComponent::StaticClass()) : false;

	UEdGraphPin* ManualAttachmentPin = GetManualAttachmentPin();
	ManualAttachmentPin->SafeSetHidden(bHideTransformPins);

	UEdGraphPin* TransformPin = GetRelativeTransformPin();
	TransformPin->SafeSetHidden(bHideTransformPins);
}
Esempio n. 2
0
void UK2Node_Helios::AllocateDefaultPins()
{
	Super::AllocateDefaultPins();
	UEdGraphPin* HeliosClassPin = FindPin(TEXT("HeliosClass"));
	if (HeliosClassPin != NULL)
	{
		HeliosClassPin->DefaultValue = MyHeliosClass.ToString();
		HeliosClassPin->SafeSetHidden(true);
	}

	UEdGraphPin* ServerUrlPin = FindPin(TEXT("ServerUrl"));
	if (ServerUrlPin != NULL)
	{
		ServerUrlPin->DefaultValue = MyServerUrl.ToString();
		ServerUrlPin->SafeSetHidden(true);
	}

	UEdGraphPin* InputValuePin = FindPin(TEXT("InputValue"));
	if (InputValuePin != NULL)
	{
		InputValuePin->PinFriendlyName = FText::FromName(MyHeliosClass);
	}

	UEdGraphPin* OutputValuePin = FindPin(TEXT("OutputValue"));
	if (OutputValuePin != NULL)
	{
		switch (MyRequestVerb)
		{
		case ERequestVerb::Get:
			OutputValuePin->PinFriendlyName = FText::FromName(MyHeliosClass);
			break;
		case ERequestVerb::Post:
			OutputValuePin->SafeSetHidden(true);
			break;
		}
	}
}