public static void OnPreprocessBuild()
        {
            var scriptingBackend  = AssemblyImportSettingsUtilities.GetCurrentScriptingBackend();
            var activeBuildTarget = EditorUserBuildSettings.activeBuildTarget;
            var compileForAOT     = scriptingBackend == ScriptingImplementation.IL2CPP || !AssemblyImportSettingsUtilities.JITPlatforms.Contains(activeBuildTarget);

            // The EditorOnly dll should aways have the same import settings. But lets just make sure.
            AssemblyImportSettingsUtilities.SetAssemblyImportSettings(EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly);

            if (compileForAOT)
            {
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);
            }
            else
            {
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
            }

            if (compileForAOT)
            {
                // Generates dll that contains all serialized generic type variants needed at runtime.
                List <Type> types;
                if (AOTSupportUtilities.ScanProjectForSerializedTypes(out types))
                {
                    AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "OdinAOTSupport", types);
                }
            }
        }
        public void GenerateDLL(string folderPath, bool generateLinkXML = true)
        {
            var generateForTypes = this.supportSerializedTypes.Where(n => n.Emit && n.Type != null).Select(n => n.Type).ToList();

            FixUnityAboutWindowBeforeEmit.Fix();
            AOTSupportUtilities.GenerateDLL(folderPath, FormatterEmitter.PRE_EMITTED_ASSEMBLY_NAME, generateForTypes, generateLinkXML);
        }
Exemple #3
0
    public static void GenerateSerializedTypesDLL()
    {
        List <Type> serializedTypes = new List <Type>();

        DependentTypesFinder.FindDependentTypes(typeof(PlayerData), ref serializedTypes);
        AOTSupportUtilities.GenerateDLL(Application.dataPath, assemblyName, serializedTypes);
    }
Exemple #4
0
        public static void OnPreprocessBuild()
        {
            BuildTarget platform = EditorUserBuildSettings.activeBuildTarget;

            try
            {
                // The EditorOnly dll should aways have the same import settings. But lets just make sure.
                //AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly);

                if (AssemblyImportSettingsUtilities.IsJITSupported(
                        platform,
                        AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(),
                        AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()))
                {
                    //    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);
                    //    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                }
                else
                {
                    //    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                    //    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);

                    // Generates dll that contains all serialized generic type variants needed at runtime.
                    List <Type> types;

                    UnityEngine.Debug.Log(GenerateAssembliesDir);

                    if (AOTSupportUtilities.ScanProjectForSerializedTypes(out types))
                    {
                        types.Add(typeof(OrderedDictionary <Guid, FRVariable>));
                        types.Add(typeof(Dictionary <string, FRVariable>));
                        types.Add(typeof(List <BlackBoard.VariablesData>));
                        types.Add(typeof(BlackBoard.VariablesData));
                        types.Add(typeof(Graph.Blackboards));
                        types.Add(typeof(System.Collections.Generic.Dictionary <Guid, Graph.Blackboards>));
                        types.Add(typeof(System.Collections.Generic.KeyValuePair <Guid, FRVariable>));
                        types.Add(typeof(System.Guid));
                        types.Add(typeof(FlowReactor.FRVariable));
                        types.Add(typeof(FlowReactor.FRVariable.VariableType));

                        AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "FlowReactorOdinAOTSupport", types);
                    }
                }
            }
            finally
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
        public void OnPreprocessBuild(BuildReport report)
        {
            var platform = EditorUserBuildSettings.activeBuildTarget;

            _path = Directory.CreateDirectory("Assets/OdinAOT").FullName;

            try
            {
                if (!AssemblyImportSettingsUtilities.IsJITSupported(
                        platform,
                        AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(),
                        AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()) &&
                    AOTSupportUtilities.ScanProjectForSerializedTypes(out var types))
                {
                    types.Add(typeof(byte[]));
                    types.Add(typeof(Item));

                    var providers = AppDomain
                                    .CurrentDomain
                                    .GetAssemblies()
                                    .SelectMany(x => x.GetTypes())
                                    .Where(x => x.GetInterfaces().Contains(typeof(ITypeProvider)))
                                    .ToList();

                    var instances = providers.Select(x => (ITypeProvider)Activator.CreateInstance(x));

                    foreach (var provider in instances)
                    {
                        var userTypes = provider
                                        .GetTypes()
                                        .Where(x => !types.Contains(x));

                        types.AddRange(userTypes);
                    }

                    AOTSupportUtilities.GenerateDLL(_path, "OdinAOTSupport", types);
                }
            }
            finally
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
Exemple #6
0
        public static void GenerateDLL(bool p_generateLinkXml = true, bool p_includeOdin = false)
        {
            if (DashEditorCore.EditorConfig.scannedAOTTypes == null)
            {
                DashEditorCore.EditorConfig.scannedAOTTypes = new List <Type>();
            }
            if (DashEditorCore.EditorConfig.explicitAOTTypes == null)
            {
                DashEditorCore.EditorConfig.explicitAOTTypes = new List <Type>();
            }

            DashEditorCore.EditorConfig.AOTAssemblyGeneratedTime = DateTime.Now;

            if (p_generateLinkXml)
            {
                if (p_includeOdin)
                {
                    File.WriteAllText(DashEditorCore.EditorConfig.AOTAssemblyPath + "/link.xml",
                                      @"<linker>                    
                         <assembly fullname=""" + DashEditorCore.EditorConfig.AOTAssemblyName + @""" preserve=""all""/>
                         <assembly fullname=""DashRuntime"" preserve=""all""/>
                         <assembly fullname=""OdinSerializer"" preserve=""all""/>
                      </linker>");
                }
                else
                {
                    File.WriteAllText(DashEditorCore.EditorConfig.AOTAssemblyPath + "/link.xml",
                                      @"<linker>                    
                         <assembly fullname=""" + DashEditorCore.EditorConfig.AOTAssemblyName + @""" preserve=""all""/>
                         <assembly fullname=""DashRuntime"" preserve=""all""/>
                      </linker>");
                }
            }

            List <Type> aotTypes = DashEditorCore.EditorConfig.scannedAOTTypes.Concat(DashEditorCore.EditorConfig.explicitAOTTypes)
                                   .ToList();

            AOTSupportUtilities.GenerateDLL(DashEditorCore.EditorConfig.AOTAssemblyPath,
                                            DashEditorCore.EditorConfig.AOTAssemblyName, aotTypes, false);
        }
        public static void OnPreprocessBuild()
        {
            BuildTarget platform = EditorUserBuildSettings.activeBuildTarget;

            try
            {
                // The EditorOnly dll should aways have the same import settings. But lets just make sure.
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly);

                if (AssemblyImportSettingsUtilities.IsJITSupported(
                        platform,
                        AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(),
                        AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()))
                {
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                }
                else
                {
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);

                    uNodeAOTScanMethod = "MaxyGames.uNode.Editors.uNodeEditorInitializer".ToType().GetMethod("AOTScan", new Type[] { typeof(List <Type>).MakeByRefType() });
                    // Generates dll that contains all serialized generic type variants needed at runtime.
                    object[]    param = new object[] { null };
                    bool        flag  = (bool)uNodeAOTScanMethod.Invoke(null, param);
                    List <Type> types = param[0] as List <Type>;
                    if (flag)
                    {
                        AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "OdinAOTSupport", types);
                    }
                }
            }
            finally
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
        public static void OnPreprocessBuild()
        {
            BuildTarget platform = EditorUserBuildSettings.activeBuildTarget;

            AssetDatabase.StartAssetEditing();

            try
            {
                // The EditorOnly dll should aways have the same import settings. But lets just make sure.
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly);

                if (AssemblyImportSettingsUtilities.IsJITSupported(
                        platform,
                        AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(),
                        AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()))
                {
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                }
                else
                {
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);

                    // Generates dll that contains all serialized generic type variants needed at runtime.
                    List <Type> types;
                    if (AOTSupportUtilities.ScanProjectForSerializedTypes(out types))
                    {
                        AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "OdinAOTSupport", types);
                    }
                }
            }
            finally
            {
                AssetDatabase.StopAssetEditing();
            }
        }
        public static void OnPreprocessBuild()
        {
            BuildTarget platform = EditorUserBuildSettings.activeBuildTarget;

            try
            {
                // The EditorOnly dll should aways have the same import settings. But lets just make sure.
                AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly);

                if (AssemblyImportSettingsUtilities.IsJITSupported(
                        platform,
                        AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(),
                        AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()))
                {
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                }
                else
                {
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly);
                    AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll);

                    // Generates dll that contains all serialized generic type variants needed at runtime.
                    List <Type> types;
                    if (AOTSupportUtilities.ScanProjectForSerializedTypes(out types))
                    {
                        Type type = typeof(List <RobotDataEntry>);
                        types.Add(type);
                        type = typeof(Int32);
                        types.Add(type);
                        type = typeof(RobotDataEntry);
                        types.Add(type);
                        type = typeof(string);
                        types.Add(type);
                        type = typeof(Vector3);
                        types.Add(type);
                        type = typeof(Quaternion);
                        types.Add(type);
                        type = typeof(RobotDataEntrySettings);
                        types.Add(type);
                        type = typeof(List <float>);
                        types.Add(type);
                        type = typeof(List <bool>);
                        types.Add(type);
                        type = typeof(List <string>);
                        types.Add(type);
                        type = typeof(SingleSerializer);
                        types.Add(type);
                        type = typeof(StringSerializer);
                        types.Add(type);
                        type = typeof(BooleanSerializer);
                        types.Add(type);

                        Debug.Log("TypesStart:");
                        foreach (Type t in types)
                        {
                            Debug.Log(t);
                        }
                        Debug.Log("TypesEnd");

                        AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "OdinAOTSupport", types);
                    }
                }
            }
            finally
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }