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);
                }
            }
        }
        /// <summary>
        /// Scans the entire project for types to support AOT serialization for.
        /// </summary>
        public void ScanProject()
        {
            List <Type> serializedTypes;

            if (AOTSupportUtilities.ScanProjectForSerializedTypes(out serializedTypes))
            {
                this.RegisterTypes(this.supportSerializedTypes, serializedTypes);
                this.SortTypes();

                this.lastScan = DateTime.Now.Ticks;
                EditorUtility.SetDirty(this);
            }
        }
Example #3
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 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();
            }
        }