Beispiel #1
0
        private static void StripFoldersFromAllPrefabs()
        {
            var prefabGUIDs = AssetDatabase.FindAssets($"l: {LabelHandler.FolderPrefabLabel}");

            ChangedPrefabs.Initialize(prefabGUIDs.Length);

            for (int i = 0; i < prefabGUIDs.Length; i++)
            {
                string guid = prefabGUIDs[i];
                string path = AssetDatabase.GUIDToAssetPath(guid);

                ChangedPrefabs.Instance[i] = (guid, File.ReadAllText(path));
                StripFoldersFromPrefab(path, StripSettings.PlayMode);
            }

            // If domain reload is enabled in Play Mode Options, serialization of the changed prefabs is necessary
            // so that changes can be reverted after leaving play mode.
            ChangedPrefabs.SerializeIfNeeded();
        }
Beispiel #2
0
        private static void StripFoldersFromDependentPrefabs()
        {
            var scenePaths           = EditorBuildSettings.scenes.Select(scene => scene.path).ToArray();
            var dependentAssetsPaths = AssetDatabase.GetDependencies(scenePaths, true);

            var prefabsWithLabel = dependentAssetsPaths.Where(path =>
                                                              AssetDatabase.GetLabels(GetAssetForLabel(path)).Contains(LabelHandler.FolderPrefabLabel))
                                   .ToArray();

            ChangedPrefabs.Initialize(prefabsWithLabel.Length);

            for (int i = 0; i < prefabsWithLabel.Length; i++)
            {
                string path = prefabsWithLabel[i];
                ChangedPrefabs.Instance[i] = (AssetDatabase.AssetPathToGUID(path), File.ReadAllText(path));
                StripFoldersFromPrefab(path, StripSettings.Build);
            }

            // Serialization of ChangedPrefabs is not needed here because domain doesn't reload before changes are reverted.
        }