private static void SetMetaDataBlueprintability(Dictionary <FName, string> values, UMeta.Target target, ManagedUnrealTypeInfo typeInfo) { ManagedUnrealVisibility.Type defaultTypeVisibility = ManagedUnrealVisibility.Type.None; switch (target) { case UMeta.Target.Class: defaultTypeVisibility = ManagedUnrealVisibility.Class; break; case UMeta.Target.Interface: defaultTypeVisibility = ManagedUnrealVisibility.Interface; break; case UMeta.Target.Struct: defaultTypeVisibility = ManagedUnrealVisibility.Struct; break; case UMeta.Target.Enum: defaultTypeVisibility = ManagedUnrealVisibility.Enum; break; default: return; } if (defaultTypeVisibility == ManagedUnrealVisibility.Type.None) { return; } // Use whatever state is in typeInfo if default state is enabled. It should have been resolved // properly for our managed type (if the state was defined on a native type the default state config // should have overridden it) if (defaultTypeVisibility.HasFlag(ManagedUnrealVisibility.Type.BlueprintType)) { if (typeInfo.AdditionalFlags.HasFlag(ManagedUnrealTypeInfoFlags.BlueprintTypeHierarchical)) { values[UMeta.GetKeyName(MDClass.BlueprintType)] = "true"; values.Remove(UMeta.GetKeyName(MDClass.NotBlueprintType)); } else { values[UMeta.GetKeyName(MDClass.NotBlueprintType)] = "true"; values.Remove(UMeta.GetKeyName(MDClass.BlueprintType)); } } if (defaultTypeVisibility.HasFlag(ManagedUnrealVisibility.Type.Blueprintable)) { if (typeInfo.AdditionalFlags.HasFlag(ManagedUnrealTypeInfoFlags.BlueprintableHierarchical)) { values[UMeta.GetKeyName(MDClass.Blueprintable)] = "true"; values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "true"; values.Remove(UMeta.GetKeyName(MDClass.NotBlueprintable)); } else { values[UMeta.GetKeyName(MDClass.NotBlueprintType)] = "true"; values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "false"; values.Remove(UMeta.GetKeyName(MDClass.Blueprintable)); } } }
private static void SetAllMetaData(IntPtr obj, ManagedUnrealReflectionBase field, UMeta.Target target) { if (!FBuild.WithEditor || !metaDataEnabled || field == null || string.IsNullOrEmpty(field.Path)) { return; } IntPtr outermost = Native_UObjectBaseUtility.GetOutermost(obj); IntPtr metadata = outermost == IntPtr.Zero ? IntPtr.Zero : Native_UPackage.GetMetaData(outermost); if (metadata == IntPtr.Zero) { return; } Dictionary <FName, string> values = null; if (!metaDataMap.TryGetValue(field.Path.ToLower(), out values)) { values = new Dictionary <FName, string>(); } switch (target) { // Class / interface case UMeta.Target.Class: case UMeta.Target.Interface: // See GetMetadataKeyword (Engine\Source\Programs\UnrealHeaderTool\Private\BaseParser.cpp) // "NotBlueprintable" removes "NotBlueprintable" and adds "IsBlueprintBase=false" // "Blueprintable" and adds "IsBlueprintBase=true" // "BlueprintInternalUseOnly" adds "BlueprintType" if (!values.ContainsKey(UMeta.GetKeyName(MDClass.IsBlueprintBase))) { if (values.ContainsKey(UMeta.GetKeyName(MDClass.Blueprintable))) { values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "true"; } else if (values.ContainsKey(UMeta.GetKeyName(MDClass.NotBlueprintable))) { values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "false"; } } MetaDataMergeClassCategories(metadata, obj, values); break; case UMeta.Target.Function: ManagedUnrealFunctionInfo functionInfo = field as ManagedUnrealFunctionInfo; if (functionInfo.IsOverride && functionInfo.IsBlueprintEvent) { values[UMeta.GetKeyName(MDFunc.BlueprintInternalUseOnly)] = "true"; } break; } SetMetaDataBlueprintability(values, target, field as ManagedUnrealTypeInfo); if (values.Count > 0) { using (TArrayUnsafe <FName> keysUnsafe = new TArrayUnsafe <FName>()) using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>()) { keysUnsafe.AddRange(values.Keys.ToArray()); valuesUnsafe.AddRange(values.Values.ToArray()); Native_UMetaData.SetObjectValues(metadata, obj, keysUnsafe.Address, valuesUnsafe.Address); } } }