60 lines
No EOL
1.7 KiB
C#
60 lines
No EOL
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
using UnityEngine.Analytics;
|
|
|
|
namespace GBSU.Addons;
|
|
public class Helper
|
|
{
|
|
public static string RotationFolderPath = Application.dataPath + "/Config/Rotation/";
|
|
public static string GameConfigPath = RotationFolderPath + "config.json";
|
|
public static void DisableAnalytics()
|
|
{
|
|
// Try disabling analytics https://docs.unity3d.com/ScriptReference/Analytics.Analytics-deviceStatsEnabled.html
|
|
try
|
|
{
|
|
Analytics.enabled = false;
|
|
Analytics.deviceStatsEnabled = false;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Plugin.Log.LogWarning("Failed to disable analytics: " + e.Message);
|
|
}
|
|
}
|
|
public static void CreateRotationFolder()
|
|
{
|
|
try
|
|
{
|
|
Plugin.Log.LogInfo("Creating rotation folder at " + RotationFolderPath);
|
|
Directory.CreateDirectory(RotationFolderPath);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Plugin.Log.LogError("Could not create rotation folder path: " + e.Message);
|
|
}
|
|
}
|
|
public static string FilesInRotationDir()
|
|
{
|
|
// https://stackoverflow.com/a/14877330
|
|
DirectoryInfo d = new(RotationFolderPath);
|
|
FileInfo[] files = d.GetFiles();
|
|
int number = files.Length;
|
|
|
|
// no files?
|
|
if (number == 0)
|
|
{
|
|
return @"No files were found in the directory.";
|
|
}
|
|
else
|
|
{
|
|
string names = "";
|
|
|
|
foreach(FileInfo file in files)
|
|
{
|
|
names = file.Name + " " + names;
|
|
}
|
|
|
|
return $"There are {number} files: {names}";
|
|
}
|
|
}
|
|
} |