public void Strip(string path, StrippingOperationType op) { Undo.RecordObject(this, "Strip Assets"); var step = BuildStrippingStep(path, op); Execute(step); _steps.Add(step); _shadowSteps.Add(step); }
private static void StripSelected(StrippingOperationType operation) { try { AssetDatabase.StartAssetEditing(); foreach (var path in GetAssetPathsFromSelection()) { Session.DefaultSession.Strip(path, operation); } } finally { AssetDatabase.StopAssetEditing(); AssetDatabase.Refresh(); } }
private StrippingStep BuildStrippingStep(string path, StrippingOperationType operation) { var result = new StrippingStep(); result.rootPath = path; result.operation = operation; switch (operation) { case StrippingOperationType.StripAll: { CollectWorkFromPath(result.files, path); break; } case StrippingOperationType.StripTextures: { CollectWorkByAssetType <Texture> (result.files, path); break; } case StrippingOperationType.StripModels: { CollectWorkByAssetType(result.files, path, "Model"); break; } case StrippingOperationType.StripMaterials: { CollectWorkByAssetType <Material> (result.files, path); break; } case StrippingOperationType.StripAudio: { CollectWorkByAssetType <AudioClip> (result.files, path); break; } case StrippingOperationType.StripShaders: { CollectWorkByAssetType <Shader> (result.files, path); break; } case StrippingOperationType.StripArtNotInSceneView: { CollectWorkByAssetType <Texture> (result.files, path); CollectWorkByAssetType(result.files, path, "Model"); CollectWorkByAssetType <Material> (result.files, path); CollectWorkByAssetType <Shader> (result.files, path); HashSet <Renderer> visibleRenderers = new HashSet <Renderer> (); foreach (var camera in SceneView.GetAllSceneCameras()) { CollectVisibleRenderersToCamera(camera, visibleRenderers); } var exclusionList = new HashSet <string>(); CollectAssetsUsedByRenderers(visibleRenderers, exclusionList); // Also collect cookies from any lights in the scene, and cubemaps from any reflection probes CollectPathsForObjects(FindObjectsOfType <Light>() .Where(l => l.enabled && l.gameObject.activeInHierarchy && l.cookie) .Select(l => l.cookie), exclusionList); foreach (var p in FindObjectsOfType <ReflectionProbe>()) { CollectPathForObject(p.bakedTexture, exclusionList); CollectPathForObject(p.customBakedTexture, exclusionList); } RemovePathsAndMetas(result.files, exclusionList); break; } case StrippingOperationType.StripArtNotInLoadedScenes: { CollectWorkByAssetType <Texture> (result.files, path); CollectWorkByAssetType(result.files, path, "Model"); CollectWorkByAssetType <Material> (result.files, path); CollectWorkByAssetType <Shader> (result.files, path); var scenePaths = UnityEditor.SceneManagement.EditorSceneManager.GetAllScenes().Where(s => s.isLoaded).Select(s => s.path).ToArray(); var assets = new HashSet <string>(AssetDatabase.GetDependencies(scenePaths, true)); RemovePathsAndMetas(result.files, assets); break; } default: throw new ArgumentOutOfRangeException("operation"); } return(result); }