Skip to content

Commit

Permalink
First Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Nidonocu committed Mar 27, 2023
1 parent c4ee924 commit 386a993
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
45 changes: 45 additions & 0 deletions Editor/DeCrunchTextures.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.IO;
using UnityEditor;
using UnityEngine;

/**
* Performs automatic search and turns off crunch compression setting on all texture files
*
* Created by Nidonocu and Bing AI 2023
*
* See README and LICENCE for more details.
*/

public class DeCrunchTextures : MonoBehaviour
{
[MenuItem("Tools/Turn Off Crunch Compression")]
public static void TurnOffCrunchCompression()
{
string[] extensions = new string[] { "*.tga", "*.png", "*.jpg", "*.psd" };
int totalFiles = 0;
foreach (string extension in extensions)
{
string[] textureFiles = Directory.GetFiles(Application.dataPath, extension, SearchOption.AllDirectories);
totalFiles += textureFiles.Length;
}

int processedFiles = 0;
foreach (string extension in extensions)
{
string[] textureFiles = Directory.GetFiles(Application.dataPath, extension, SearchOption.AllDirectories);
foreach (string textureFile in textureFiles)
{
string relativePath = "Assets" + textureFile.Substring(Application.dataPath.Length);
TextureImporter textureImporter = AssetImporter.GetAtPath(relativePath) as TextureImporter;
if (textureImporter != null)
{
textureImporter.crunchedCompression = false;
textureImporter.SaveAndReimport();
}
processedFiles++;
EditorUtility.DisplayProgressBar("Turning Off Crunch Compression", "Processing file " + processedFiles + " of " + totalFiles, (float)processedFiles / totalFiles);
}
}
EditorUtility.ClearProgressBar();
}
}
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Nidonocu
Copyright (c) 2023 Nidonocu & Bing AI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
🖼🗜↩ Unity Texture DeCruncher
==============================

Following a change in [VRChat Guidelines](https://ask.vrchat.com/t/developer-update-16-march-2023/16950#sdk-warning-improvements-6) about the use of Crunch Compressed textures in projects, I wanted a script to quickly update all texture files in my project to turn off Crunch Compression.

While this feature will likely be built in to future versions of the SDK, this stand-alone script can check every file of your project, regardless of if it is part of your avatar or world currently, and fix the setting in advance.

## ✅ Requirements

* Tested in `Unity 2019.4.31f1`

## 💾 Installation

Download this repo using GIT or by clicking **Code** and then **Download ZIP** above.

In your project, create a folder called `Editor`, and copy the `DeCrunchTextures.cs` file from this repository or the ZIP file into that folder.

**Important:** Unity treats files within folders called *Editor* as special and knows that the script should be run as an Editor Add-On, not part of the project's game code, so don't just stick the file anywhere!

## ▶ Running the Tool

### ***Backup your Projects!!!***

If this tool does something unexpected due to a conflict with another script, power loss or bug and corrupts your project, that's on you!

### How to Run

Once imported, an item named **Turn Off Crunch Compression** will be added to Unity's **Tools** menu. Select this menu option to begin the process.

A progress dialog will appear with the number of files to process, if you have a lot of image files in your project and a slow system, this may take some time.

Once the progress dialog is complete, all files will now be set uncrunched. You can now remove the script file from the project by just deleting the script file.

0 comments on commit 386a993

Please sign in to comment.