Update Unity Splash Remover
This commit is contained in:
parent
a261ed1185
commit
1618d8aee2
@ -13,7 +13,7 @@ namespace USSR.Core
|
||||
{
|
||||
public int callbackOrder => 100;
|
||||
|
||||
static void ProcessFile(string selectedFile, string tpkFile)
|
||||
public static void ProcessBundle(string unity3dFile, string tpkFile)
|
||||
{
|
||||
AssetTypes assetType = AssetTypes.Bundle; // data.unity3d
|
||||
|
||||
@ -22,7 +22,7 @@ namespace USSR.Core
|
||||
return; // Prompt for action again
|
||||
|
||||
List<string> temporaryFiles = new();
|
||||
string inspectedFile = selectedFile;
|
||||
string inspectedFile = unity3dFile;
|
||||
|
||||
AssetsFileInstance assetFileInstance = null;
|
||||
BundleFileInstance bundleFileInstance = null;
|
||||
@ -53,7 +53,7 @@ namespace USSR.Core
|
||||
assetFileInstance.file.Metadata.UnityVersion
|
||||
);
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Unity Version: [bold green]{assetFileInstance.file.Metadata.UnityVersion}[/]"
|
||||
$"( INFO ) Unity Version: {assetFileInstance.file.Metadata.UnityVersion}"
|
||||
);
|
||||
|
||||
assetFileInstance.file = RemoveSplashScreenAndWatermark(
|
||||
@ -74,7 +74,7 @@ namespace USSR.Core
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Error when loading asset class types database! {ex.Message}"
|
||||
$"( ERR! ) Error when loading asset class types database! {ex.Message}"
|
||||
);
|
||||
return; // Prompt for action again
|
||||
}
|
||||
@ -85,6 +85,64 @@ namespace USSR.Core
|
||||
Utility.CleanUp(temporaryFiles);
|
||||
}
|
||||
|
||||
public static void ProcessFile(string globalManagerFile, string tpkFile)
|
||||
{
|
||||
AssetTypes assetType = AssetTypes.Asset; // globalmanagers
|
||||
|
||||
AssetsManager assetsManager = new AssetsManager();
|
||||
if (!LoadClassPackage(assetsManager, tpkFile))
|
||||
return; // Prompt for action again
|
||||
|
||||
List<string> temporaryFiles = new();
|
||||
string inspectedFile = globalManagerFile;
|
||||
|
||||
AssetsFileInstance assetFileInstance = null;
|
||||
|
||||
string tempFile = Utility.CloneFile(inspectedFile, $"{inspectedFile}.temp");
|
||||
temporaryFiles.Add(tempFile);
|
||||
temporaryFiles.Add($"{tempFile}.unpacked");
|
||||
|
||||
assetFileInstance = LoadAssetFileInstance(tempFile, assetsManager);
|
||||
|
||||
if (assetFileInstance != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
UnityEngine.Debug.Log("( INFO ) Loading asset class types database...");
|
||||
assetsManager.LoadClassDatabaseFromPackage(
|
||||
assetFileInstance.file.Metadata.UnityVersion
|
||||
);
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Unity Version: {assetFileInstance.file.Metadata.UnityVersion}"
|
||||
);
|
||||
|
||||
assetFileInstance.file = RemoveSplashScreenAndWatermark(
|
||||
assetsManager,
|
||||
assetFileInstance
|
||||
);
|
||||
|
||||
if (assetFileInstance.file != null)
|
||||
{
|
||||
WriteChanges(
|
||||
inspectedFile,
|
||||
assetType,
|
||||
assetFileInstance,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"( ERR! ) Error when loading asset class types database! {ex.Message}"
|
||||
);
|
||||
return; // Prompt for action again
|
||||
}
|
||||
}
|
||||
assetsManager?.UnloadAll(true);
|
||||
Utility.CleanUp(temporaryFiles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load Class Types package (.tpk) file.
|
||||
/// </summary>
|
||||
@ -98,7 +156,7 @@ namespace USSR.Core
|
||||
try
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Loading class types package: [green]{tpkFile}[/]..."
|
||||
$"( INFO ) Loading class types package: {tpkFile}..."
|
||||
);
|
||||
assetsManager.LoadClassPackage(path: tpkFile);
|
||||
return true;
|
||||
@ -106,18 +164,57 @@ namespace USSR.Core
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Error when loading class types package! {ex.Message}"
|
||||
$"( ERR! ) Error when loading class types package! {ex.Message}"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] TPK file not found: [red]{tpkFile}[/]..."
|
||||
$"( ERR! ) TPK file not found: {tpkFile}..."
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for LoadAssetsFile.
|
||||
/// </summary>
|
||||
/// <param name="assetFile"></param>
|
||||
/// <param name="assetsManager"></param>
|
||||
/// <returns></returns>
|
||||
static AssetsFileInstance LoadAssetFileInstance(
|
||||
string assetFile,
|
||||
AssetsManager assetsManager
|
||||
)
|
||||
{
|
||||
AssetsFileInstance assetFileInstance = null;
|
||||
|
||||
if (File.Exists(assetFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Loading asset file: {assetFile}..."
|
||||
);
|
||||
assetFileInstance = assetsManager.LoadAssetsFile(assetFile, true);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"( ERR! ) Error when loading asset file! {ex.Message}"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"( ERR! ) Asset file not found: {assetFile}"
|
||||
);
|
||||
}
|
||||
|
||||
return assetFileInstance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for LoadAssetsFileFromBundle.
|
||||
/// </summary>
|
||||
@ -138,7 +235,7 @@ namespace USSR.Core
|
||||
try
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Loading asset file: [green]{assetFile}[/]..."
|
||||
$"( INFO ) Loading asset file: {assetFile}..."
|
||||
);
|
||||
assetFileInstance = assetsManager.LoadAssetsFileFromBundle(
|
||||
bundleFileInstance,
|
||||
@ -149,14 +246,14 @@ namespace USSR.Core
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Error when loading asset file! {ex.Message}"
|
||||
$"( ERR! ) Error when loading asset file! {ex.Message}"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Asset file not found: [red]{assetFile}[/]"
|
||||
$"( ERR! ) Asset file not found: {assetFile}"
|
||||
);
|
||||
}
|
||||
|
||||
@ -183,7 +280,7 @@ namespace USSR.Core
|
||||
try
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Loading bundle file: [green]{bundleFile}[/]..."
|
||||
$"( INFO ) Loading bundle file: {bundleFile}..."
|
||||
);
|
||||
bundleFileInstance = assetsManager.LoadBundleFile(bundleFile, false);
|
||||
//! Don't auto dispose the stream
|
||||
@ -196,14 +293,14 @@ namespace USSR.Core
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Error when loading bundle file! {ex.Message}"
|
||||
$"( ERR! ) Error when loading bundle file! {ex.Message}"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Bundle file not found: [red]{bundleFile}[/]"
|
||||
$"( ERR! ) Bundle file not found: {bundleFile}"
|
||||
);
|
||||
}
|
||||
|
||||
@ -249,10 +346,10 @@ namespace USSR.Core
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Can\'t get Player Settings fields! {ex.Message} It\'s possible that the current Unity version isn\'t supported yet."
|
||||
$"( ERR! ) Can\'t get Player Settings fields! {ex.Message} It\'s possible that the current Unity version isn\'t supported yet."
|
||||
);
|
||||
UnityEngine.Debug.Log(
|
||||
"( INFO ) Try updating the [bold green]classdata.tpk[/] manually from there: [link green]https://nightly.link/AssetRipper/Tpk/workflows/type_tree_tpk/master/uncompressed_file.zip[/] and try again. If the issue still persist, try use another Unity version."
|
||||
"( INFO ) Try updating the classdata.tpk manually from there: https://nightly.link/AssetRipper/Tpk/workflows/type_tree_tpk/master/uncompressed_file.zip and try again. If the issue still persist, try use another Unity version."
|
||||
);
|
||||
return assetFile;
|
||||
}
|
||||
@ -262,7 +359,7 @@ namespace USSR.Core
|
||||
playerSettingsBase["m_ShowUnitySplashScreen"].AsBool = false;
|
||||
|
||||
UnityEngine.Debug.Log(
|
||||
$"[green]( INFO ) Splash screen removed.[/]"
|
||||
$"( INFO ) Splash screen removed."
|
||||
);
|
||||
|
||||
AssetTypeValueField splashScreenLogos = playerSettingsBase[
|
||||
@ -282,13 +379,13 @@ namespace USSR.Core
|
||||
playerSettingsInfo[0].SetNewData(playerSettingsBase);
|
||||
buildSettingsInfo[0].SetNewData(buildSettingsBase);
|
||||
|
||||
UnityEngine.Debug.Log("[green]( INFO ) Watermark successfully removed.[/]");
|
||||
UnityEngine.Debug.Log("( INFO ) Watermark successfully removed.");
|
||||
return assetFile;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Error when removing the splash screen & watermark! {ex.Message}"
|
||||
$"( ERR! ) Error when removing the splash screen & watermark! {ex.Message}"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
@ -313,7 +410,7 @@ namespace USSR.Core
|
||||
try
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Writing changes to [green]{modifiedFile}[/]..."
|
||||
$"( INFO ) Writing changes to {modifiedFile}..."
|
||||
);
|
||||
|
||||
switch (assetType)
|
||||
@ -334,7 +431,7 @@ namespace USSR.Core
|
||||
bundleFileInstance?.file.Write(writer);
|
||||
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Compressing [green]{modifiedFile}[/]..."
|
||||
$"( INFO ) Compressing {modifiedFile}..."
|
||||
);
|
||||
using FileStream uncompressedBundleStream = File.OpenRead(
|
||||
uncompressedBundleFile
|
||||
@ -351,7 +448,7 @@ namespace USSR.Core
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogError(
|
||||
$"[red]( ERR! )[/] Error when writing changes! {ex.Message}"
|
||||
$"( ERR! ) Error when writing changes! {ex.Message}"
|
||||
);
|
||||
}
|
||||
finally
|
||||
@ -367,9 +464,21 @@ namespace USSR.Core
|
||||
|
||||
var data_unity3d_path = Path.Combine(path, "src/main/assets/bin/Data/data.unity3d");
|
||||
|
||||
var global_manager_path = Path.Combine(path, "src/main/assets/bin/Data/globalgamemanagers");
|
||||
|
||||
var tpk_path = FileUtil.GetPhysicalPath("Packages/com.bywaystudios.unitysplashremover/Editor/USSR/classdata.tpk");
|
||||
|
||||
ProcessFile(data_unity3d_path, tpk_path);
|
||||
try
|
||||
{
|
||||
ProcessBundle(data_unity3d_path, tpk_path);
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
ProcessFile(global_manager_path, tpk_path);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ namespace USSR.Utilities
|
||||
{
|
||||
if (sourceFileSignature[i] != fileSignature[i])
|
||||
{
|
||||
// AnsiConsole.MarkupLine("[red]Unknown/Unsupported[/] file type!");
|
||||
// AnsiConsole.MarkupLine("Unknown/Unsupported file type!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -54,8 +54,8 @@ namespace USSR.Utilities
|
||||
{
|
||||
if (!File.Exists(sourceFile))
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"[red]( ERROR )[/] Source file to duplicate doesn\'t exist: [red]{sourceFile}[/]"
|
||||
UnityEngine.Debug.LogError(
|
||||
$"( ERROR ) Source file to duplicate doesn\'t exist: {sourceFile}"
|
||||
);
|
||||
return string.Empty;
|
||||
}
|
||||
@ -83,7 +83,7 @@ namespace USSR.Utilities
|
||||
if (!File.Exists(backupFile))
|
||||
{
|
||||
UnityEngine.Debug.Log(
|
||||
$"( INFO ) Backup [green]{Path.GetFileName(sourceFile)}[/] as [green]{backupFile}[/]..."
|
||||
$"( INFO ) Backup {Path.GetFileName(sourceFile)} as {backupFile}..."
|
||||
);
|
||||
CloneFile(sourceFile, backupFile);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.bywaystudios.unitysplashremover",
|
||||
"displayName": "Unity Splash Remover",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "Package to Remove Unity Splash Screen on Build Pipeline"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user