Example #1
0
        internal static void RegisterManagedClass(IntPtr classAddress, Type type)
        {
            UClass existingClass;

            if (classes.TryGetValue(type, out existingClass))
            {
                classes.Remove(type);
                classesByAddress.Remove(existingClass.Address);
            }
            seenClasses.Remove(type);

            classesByAddress[classAddress] = type;
            UClass unrealClass = GCHelper.Find <UClass>(classAddress);

            if (unrealClass != null)
            {
                classes[type] = unrealClass;
            }
            else
            {
                classesByAddress.Remove(classAddress);
            }

            // If this is an interface add it to UnrealInterfacePool so that we can create instances of this
            // interface which are implemented in Blueprint
            if (type.IsInterface)
            {
                UnrealInterfacePool.LoadType(type);
            }
        }
Example #2
0
        /// <summary>
        /// Loads underlying native type info for the given generated type (types tagged with UMetaPath)
        /// This loads the class address/properties/functions/offsets
        /// </summary>
        private static void LoadNative(Type type, UMetaPathAttribute pathAttribute)
        {
            UnrealInterfacePool.LoadType(type);

            bool lazyLoad = LazyLoadingEnabled && !HasCCtorBeenCalled(type);

            if (!lazyLoad)
            {
                // If this is an interface get the default implementation type which will hold the loader method
                Type targetType = type;
                if (pathAttribute.InterfaceImpl != null)
                {
                    targetType = pathAttribute.InterfaceImpl;
                }

                MethodInfo method = targetType.GetMethod(CodeGeneratorSettings.LoadNativeTypeMethodName,
                                                         BindingFlags.Static | BindingFlags.NonPublic);

                if (method != null)
                {
                    method.Invoke(null, null);
                }
            }
        }