private static void Clear()
 {
     AotPreBuilder.DeleteLinker();
     AotPreBuilder.DeleteStubScript();
     AssetDatabase.Refresh();
     Debug.Log("AOT pre-build data has been cleared.\n");
 }
예제 #2
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            var label = "Every Unity build target except Standalone requires 'ahead of time' (AOT) compilation. ";

            label += "Before building for these platforms, you should always run this step to create AOT stubs for reflection and generics. ";
            label += "Otherwise, there may be runtime errors in your builds.";

            var label2 = "This pre-build step will scan all the assets and scenes in the project to generate the required AOT stubs. ";

            label2 += "Make sure you save the current scene before starting.";

            LudiqGUI.FlexibleSpace();
            GUILayout.Label(label, LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(label2, LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Pre-Build", Styles.nextButton))
            {
                try
                {
                    AotPreBuilder.GenerateLinker();
                    AotPreBuilder.GenerateStubScript();
                    EditorUtility.DisplayDialog("AOT Pre-Build", $"AOT pre-build has completed.\n\nThe generated linker file is located at:\n'{PathUtility.FromProject(AotPreBuilder.aotStubsPath)}'\n\nThe generated stubs script is located at:\n'{PathUtility.FromProject(AotPreBuilder.linkerPath)}'", "OK");
                    Complete();
                }
                catch (Exception ex)
                {
                    EditorUtility.DisplayDialog("AOT Pre-Build Error", $"AOT pre-build has failed: \n{ex.Message}", "OK");
                    Debug.LogException(ex);
                    AotPreBuilder.DeleteLinker();
                    AotPreBuilder.DeleteStubScript();
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            EditorGUILayout.HelpBox("AOT Pre-build is in Beta. Please report any compile-time or runtime error you may encounter.", MessageType.Warning);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }