private void UpdateAvailableTypes(UField field) { if (field == null) { return; } System.Diagnostics.Debug.Assert(!field.IsA <UProperty>(), "Shouldn't have UProperty here"); if (field.IsA <UStruct>() || field.IsA <UEnum>()) { bool isNewElement = availableTypes.Add(field); if (!isNewElement) { return; } } if (Settings.ExportMode != CodeGeneratorSettings.CodeExportMode.Referenced) { return; } // Get all of the references from this struct UStruct unrealStruct = field as UStruct; if (unrealStruct != null) { bool isBlueprintType = unrealStruct.IsA <UUserDefinedStruct>() || unrealStruct.IsA <UBlueprintGeneratedClass>(); // Get struct references from parent class chain UStruct parentStruct = unrealStruct.GetSuperStruct(); while (parentStruct != null) { UpdateAvailableTypes(parentStruct); parentStruct = parentStruct.GetSuperStruct(); } // Get references from interfaces UClass unrealClass = field as UClass; if (unrealClass != null) { foreach (FImplementedInterface implementedInterface in unrealClass.Interfaces) { UpdateAvailableTypes(implementedInterface.InterfaceClass); } } // Get struct references from members foreach (UProperty property in unrealStruct.GetFields <UProperty>(false)) { if (CanExportProperty(property, unrealStruct, isBlueprintType)) { UpdateAvailableTypesProp(property); } } // Get struct references from function params (and return type) foreach (UFunction unrealFunction in unrealStruct.GetFields <UFunction>(false)) { if (CanExportFunction(unrealFunction, isBlueprintType)) { foreach (UProperty parameter in unrealFunction.GetFields <UProperty>()) { UpdateAvailableTypesProp(parameter); } } } } // This should be for global functions only (delegates) UFunction function = field as UFunction; if (function != null) { if (CanExportFunction(function, false)) { UStruct functionOwner = function.GetOuter() as UStruct; if (functionOwner != null) { UpdateAvailableTypes(functionOwner); } foreach (UProperty parameter in function.GetFields <UProperty>()) { UpdateAvailableTypesProp(parameter); } } } }
private bool CanExportFunction(UFunction function, bool isBlueprintType) { UClass ownerClass = function.GetOuter() as UClass; if (ownerClass != null && function.HasAnyFunctionFlags(EFunctionFlags.BlueprintEvent) && function.GetSuperFunction() == null) { UFunction originalFunction; bool isInterfaceImplementation; UClass originalOwner = GetOriginalFunctionOwner(function, out originalFunction, out isInterfaceImplementation); // Let interface implementation functions through as we need them for implementing the interface. if (originalOwner != ownerClass && !isInterfaceImplementation) { // BlueprintEvent function is defined twice in the hierarchy (this should only be possible in // C++. Blueprint will have SuperFunction set). There isn't any logical code to output for this // and Blueprint seems to just access the base-most function anyway. Debug.Assert(function.HasAnyFunctionFlags(EFunctionFlags.Native)); return(false); } } // Make sure we use the GetOriginalFunctionOwner check before ExportAllFunctions as we aren't handling the // "new" keyword properly yet for redefined virtual functions. if (Settings.ExportAllFunctions) { return(true); } // Should we allow deprecated functions and tag them with [Obsolete]? if (function.HasMetaData(MDFunc.DeprecatedFunction)) { return(false); } if (function.GetBoolMetaData(MDFunc.BlueprintInternalUseOnly)) { return(false); } if (function.HasAnyFunctionFlags(EFunctionFlags.Delegate | EFunctionFlags.MulticastDelegate)) { return(true); } if (isBlueprintType && function.HasAnyFunctionFlags(EFunctionFlags.BlueprintEvent)) { // Skip events such as input events which can be implemented many times // which are hard to generate code for // "InpAxisEvt_LookUpRate_K2Node_InputAxisEvent_62" // // NOTE: This check may not be enough, we may need to check the UEdGraph nodes // for additional information bool isNativeEvent = function.HasAnyFunctionFlags(EFunctionFlags.Event); bool isCallable = function.HasAnyFunctionFlags(EFunctionFlags.BlueprintCallable); bool hasSuperFunc = function.GetSuperFunction() != null; // Check bIsNativeEvent if we want events such as ReceiveBeginPlay / ReceiveHit if (/*!isNativeEvent && */ !isCallable) { return(false); } } // Maybe check metadata "BlueprintProtected" for true? In blueprint how do the // dropdowns private/protected/public impact the UFunction? // Functions don't need to be marked as FUNC_Public to be visible by blueprint? // The FUNC_BlueprintCallable and other all that matters? return(function.HasAnyFunctionFlags(EFunctionFlags.BlueprintCallable | EFunctionFlags.BlueprintEvent | EFunctionFlags.BlueprintPure));// && //function.HasAnyFunctionFlags(EFunctionFlags.Public | EFunctionFlags.Protected); }