Skip to content

Commit

Permalink
Added InfoYGChecker
Browse files Browse the repository at this point in the history
- Disable Archiving for YG Plugin
  • Loading branch information
RimuruDev committed Jul 2, 2024
1 parent ef54973 commit db76488
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CustomBuildUpdater/Checkers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions CustomBuildUpdater/Checkers/CheckAndDisableArchivingBuild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace RimuruDev.Unity_CustomBuildUpdater.CustomBuildUpdater.Checkers
{
// TODO: Add log level settings
public static class InfoYGChecker
{
private const string InfoYGPath = "Assets/YandexGame/WorkingData/InfoYG.asset";

[InitializeOnLoadMethod]
private static void CheckAndDisableArchivingBuild()
{
if (File.Exists(InfoYGPath))
{
var infoYGType = GetType("YG.InfoYG");
if (infoYGType != null)
{
var infoYG = AssetDatabase.LoadAssetAtPath(InfoYGPath, infoYGType) as ScriptableObject;
if (infoYG != null)
{
var archivingBuildField = infoYGType.GetField("archivingBuild");
if (archivingBuildField != null)
{
archivingBuildField.SetValue(infoYG, false);

EditorUtility.SetDirty(infoYG);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

Debug.Log("InfoYG archivingBuild set to false");
}
// else Debug.LogWarning("Field archivingBuild not found in InfoYG.");
}
// else Debug.LogWarning("InfoYG asset exists but could not be loaded.");
}
// else Debug.LogWarning("Class InfoYG not found in namespace YG.");
}
// else Debug.Log("InfoYG asset does not exist.");
}

private static Type GetType(string typeName)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
var type = assembly.GetType(typeName);

if (type != null)
return type;
}

return null;
}
}
}
11 changes: 11 additions & 0 deletions CustomBuildUpdater/Checkers/CheckAndDisableArchivingBuild.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit db76488

Please sign in to comment.