-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |