Skip to content

Instantly share code, notes, and snippets.

@takashicompany
Last active December 27, 2015 11:19
Show Gist options
  • Save takashicompany/7317660 to your computer and use it in GitHub Desktop.
Save takashicompany/7317660 to your computer and use it in GitHub Desktop.
UnityのEditor ScriptでiPhone / Androidアプリのアイコンを変更するスクリプト。 プロジェクト内のフォルダからアイコン画像を取得して設定する。
// Editor Scriptで書くこと。
Texture2D[] currentIcons; //現在設定されているアイコンのテクスチャー
Texture2D[] newIcon; //新しく設定するアイコンのテクスチャー
int[] iconSizes;
// 現在のアイコンを取得。
currentIcons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Android);
// プラットフォームのアイコンサイズを取得。
iconSizes = PlayerSettings.GetIconSizesForTargetGroup(BuildTargetGroup.Android);
// 新しいアイコンの配列を初期化。
newIcon = new Texture2D[iconSizes.Length];
// サイズの一覧を基に、Assets/Textures/Android フォルダ内のテクスチャーを取得。(フォルダは適当なところに置いてOK)
for(int i = 0; i < iconSizes.Length; i++){
int size = iconSizes[i];
// ex. icon_72x72.pngなど
newIcon[i] = AssetDatabase.LoadAssetAtPath("Assets/Textures/Android/icon_" + size + "x" + size + ".png", typeof(Texture2D)) as Texture2D;
}
// Assets/Textures/Androidフォルダから取得したアイコン画像をPlayerSettingsに反映。
PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android,newIcons);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment