static void UpdateMenuItem()
 {
     if (ModuleMetadata.GetModuleIncludeSettingForModule("Physics2D") == ModuleIncludeSetting.ForceExclude)
     {
         Menu.RemoveMenuItem(k_CreatePhysicsMaterial2DMenuPath);
     }
 }
        static public void WriteBuildData(string buildDataPath, BuildReport report, string[] scenes, string[] prefabs)
        {
            var developmentBuild = report.summary.options.HasFlag(BuildOptions.Development);
            var inputScenes      = new List <BuildDataInputFile>();

            foreach (var scene in scenes)
            {
                inputScenes.Add(new BuildDataInputFile(scene, developmentBuild));
            }

            var inputFiles = new List <BuildDataInputFile>();

            foreach (var scene in scenes)
            {
                inputFiles.Add(new BuildDataInputFile(scene, developmentBuild));
            }
            foreach (var prefab in prefabs)
            {
                inputFiles.Add(new BuildDataInputFile(prefab, developmentBuild));
            }
            foreach (var assetInfo in report.packedAssets.SelectMany(a => a.contents))
            {
                if (assetInfo.sourceAssetPath.ToNPath().FileExists() && !assetInfo.sourceAssetPath.StartsWith("."))
                {
                    inputFiles.Add(new BuildDataInputFile(assetInfo.sourceAssetPath, developmentBuild));
                }
            }
            foreach (var projectSetting in new NPath("ProjectSettings").Files("*.asset"))
            {
                inputFiles.Add(new BuildDataInputFile(projectSetting, developmentBuild));
            }

            var buildData = new BuildData()
            {
                scenes         = inputScenes.ToArray(),
                inputFiles     = inputFiles.ToArray(),
                buildOptions   = report.summary.options & BuildData.BuildOptionsMask,
                unityVersion   = Application.unityVersion,
                resourcePaths  = ResourcesAPIInternal.GetAllPaths("").OrderBy(p => p).ToArray(),
                enabledModules = ModuleMetadata.GetModuleNames()
                                 .Where(m => ModuleMetadata.GetModuleIncludeSettingForModule(m) != ModuleIncludeSetting.ForceExclude)
                                 .ToArray()
            };

            buildDataPath.ToNPath().WriteAllText(JsonUtility.ToJson(buildData));
        }
        bool DoCheckDirty()
        {
            if (Application.unityVersion != buildData.unityVersion)
            {
                Console.WriteLine($"Rebuilding Data files because they were built with a different Unity version {Application.unityVersion} vs {buildData.unityVersion}");
                return(true);
            }

            if (!scenes.SequenceEqual(buildData.scenes.Select(f => f.path)))
            {
                Console.WriteLine("Rebuilding Data files because the scene list is dirty");
                return(true);
            }

            if ((buildOptions & BuildData.BuildOptionsMask) != buildData.buildOptions)
            {
                Console.WriteLine("Rebuilding Data files because the build options have changed");
                return(true);
            }

            if (buildData.inputFiles.Any(CheckAssetDirty))
            {
                return(true);
            }

            var resourcePaths = ResourcesAPIInternal.GetAllPaths("").OrderBy(p => p).ToArray();

            if (!resourcePaths.SequenceEqual(buildData.resourcePaths))
            {
                for (int i = 0; i < resourcePaths.Length || i < buildData.resourcePaths.Length; i++)
                {
                    string path;
                    if (i >= resourcePaths.Length)
                    {
                        path = buildData.resourcePaths[i];
                    }
                    else if (i >= buildData.resourcePaths.Length)
                    {
                        path = resourcePaths[i];
                    }
                    else if (buildData.resourcePaths[i] != resourcePaths[i])
                    {
                        path = resourcePaths[i];
                    }
                    else
                    {
                        continue;
                    }

                    Console.WriteLine($"Rebuilding Data files because {path} is dirty (Resource file added or removed)");
                    return(true);
                }
            }

            var enabledModules = ModuleMetadata.GetModuleNames()
                                 .Where(m => ModuleMetadata.GetModuleIncludeSettingForModule(m) != ModuleIncludeSetting.ForceExclude);

            if (!enabledModules.SequenceEqual(buildData.enabledModules))
            {
                Console.WriteLine($"Rebuilding Data files because enabled modules have changed");
                return(true);
            }

            Console.WriteLine("Not rebuilding Data files -- no changes");
            return(false);
        }