38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
#if UNITY_EDITOR
|
|
using System;
|
|
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEditor.Build;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectQuint.Editor
|
|
{
|
|
internal static class ProjectQuintIconConfigurator
|
|
{
|
|
internal const string IconAssetPath =
|
|
"Assets/ProjectQuint/Art/AppIcon/ProjectQuintAppIcon.png";
|
|
|
|
[MenuItem("ProjectQuint/Apply macOS App Icon")]
|
|
public static void ApplyMacAppIcon()
|
|
{
|
|
AssetDatabase.ImportAsset(IconAssetPath, ImportAssetOptions.ForceUpdate);
|
|
var icon = AssetDatabase.LoadAssetAtPath<Texture2D>(IconAssetPath);
|
|
if (icon == null)
|
|
throw new InvalidOperationException($"ProjectQuint app icon is missing: {IconAssetPath}");
|
|
|
|
var target = NamedBuildTarget.Standalone;
|
|
var iconCount = PlayerSettings.GetIconSizes(target, IconKind.Application).Length;
|
|
if (iconCount <= 0)
|
|
throw new InvalidOperationException("Unity reported no Standalone application icon slots.");
|
|
|
|
PlayerSettings.SetIcons(
|
|
target,
|
|
Enumerable.Repeat(icon, iconCount).ToArray(),
|
|
IconKind.Application);
|
|
AssetDatabase.SaveAssets();
|
|
Debug.Log($"[ProjectQuint Icon] Applied {IconAssetPath} to {iconCount} Standalone icon slots.");
|
|
}
|
|
}
|
|
}
|
|
#endif
|