コード例 #1
0
        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);
        }