private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
                                                   string[] movedAssets, string[] movedFromAssetPaths)
        {
            if (ProtoPrefs.enabled == false)
            {
                return;
            }
            ProtoPrefs.UpdateCachedVariables();

            new Thread(() =>
            {
                var compiledFilesList = importedAssets
                                        .Where(f => Path.GetExtension(f) == ".proto")
                                        .Select(Path.GetFullPath)
                                        .CompiledFiles()
                                        .ToList();
                if (!compiledFilesList.Any())
                {
                    return;
                }

                var includePaths = AllProtoFiles.IncludePaths().ToList();

                var logStandard = ProtoPrefs.logStandard;
                var logError    = ProtoPrefs.logError;
                CompileAssets(compiledFilesList, includePaths, logStandard, logError);
                Debug.Log("Compiled changed .proto files");
                ProtoPrefs.QueueOnMainThread(AssetDatabase.Refresh);
            }).Start();
        }
 public static void OnScriptsReloaded()
 {
     if (ProtoPrefs.enabled == false)
     {
         return;
     }
     ProtoPrefs.UpdateCachedVariables();
     CompileUncompiledFilesOnly();
 }
        public static void CompileUncompiledFilesOnly()
        {
            void compileCode()
            {
                if (ProtoPrefs.logStandard)
                {
                    Debug.Log("Protobuf Unity : Compiling uncompiled .proto files in the project...");
                }

                var files           = AllProtoFiles.ToList();
                var includePaths    = files.IncludePaths().ToList();
                var uncompiledFiles = files.UncompiledFiles().ToList();

                if (!uncompiledFiles.Any())
                {
                    return;
                }

                var logStandard = ProtoPrefs.logStandard;
                var logError    = ProtoPrefs.logError;

                CompileAssets(uncompiledFiles, includePaths, logStandard, logError);

                Debug.Log("Compiled uncompiled .proto files");
                if (ShouldMultithreadUncompiledFiles)
                {
                    ProtoPrefs.QueueOnMainThread(AssetDatabase.Refresh);
                }
                else
                {
                    AssetDatabase.Refresh();
                }
            }

            if (ShouldMultithreadUncompiledFiles)
            {
                new Thread(compileCode).Start();
            }
            else
            {
                compileCode();
            }
        }
        /// <summary>
        ///     Force compiles all proto files and refreshes asset database
        /// </summary>
        public static void CompileAllInProject()
        {
            new Thread(() =>
            {
                if (ProtoPrefs.logStandard)
                {
                    Debug.Log("Protobuf Unity : Compiling all .proto files in the project...");
                }

                var files         = AllProtoFiles.ToList();
                var includePaths  = files.IncludePaths().ToList();
                var compiledFiles = files.CompiledFiles().ToList();

                var logStandard = ProtoPrefs.logStandard;
                var logError    = ProtoPrefs.logError;
                CompileAssets(compiledFiles, includePaths, logStandard, logError);

                Debug.Log("Compiled all .proto files");
                ProtoPrefs.QueueOnMainThread(AssetDatabase.Refresh);
            }).Start();
        }