Пример #1
0
 public void OnPreprocessBuild(BuildReport report)
 {
     if (StripSettings.StripFoldersFromPrefabsInBuild)
     {
         using (AssetImportGrouper.Init())
         {
             StripFoldersFromDependentPrefabs();
         }
     }
 }
Пример #2
0
        public static AssetImportGrouper Init()
        {
            AssetDatabase.StartAssetEditing();

            if (_instance == null)
            {
                _instance = new AssetImportGrouper();
            }

            return(_instance);
        }
 private static void OnPostprocessAllAssets(string[] importedAssets, string[] _, string[] __, string[] ___)
 {
     // Group imports into one to improve performance in case there are multiple prefabs that need a label change.
     using (AssetImportGrouper.Init())
     {
         foreach (string assetPath in importedAssets)
         {
             if (assetPath.EndsWith(".prefab"))
             {
                 HandlePrefabLabels(assetPath);
             }
         }
     }
 }
Пример #4
0
        private static void HandlePrefabsOnPlayMode(PlayModeStateChange state)
        {
            if (!StripSettings.StripFoldersFromPrefabsInPlayMode || StripSettings.PlayMode == StrippingMode.DoNothing)
            {
                return;
            }

            // Calling it not in EnteredPlayMode because scripts may instantiate prefabs in Awake or OnEnable
            // which happens before EnteredPlayMode.
            if (state == PlayModeStateChange.ExitingEditMode)
            {
                // Stripping folders from all prefabs in the project instead of only the ones referenced in the scenes
                // because a prefab may be hot-swapped in Play Mode.
                using (AssetImportGrouper.Init())
                {
                    StripFoldersFromAllPrefabs();
                }
            }
            else if (state == PlayModeStateChange.ExitingPlayMode)
            {
                RevertChanges();
            }
        }