【Unity】【iOS】ステータスバーの背景色を設定する
Unity、iOSでステータスバーを表示した時に、背景が透明なので黒くしたい。
https://www.facebook.com/groups/unityuserj/permalink/1152148234845115
色々調査しました・・・
やった方法
Assets/Plugins/iOS
に
StatusBarBackgroundColor.mmを作成
extern UIViewController* UnityGetGLViewController(); extern "C" { void _Set(); } void _Set() { // ステータスバーの背景色を設定(viewを追加) UIViewController* parent = UnityGetGLViewController(); UIView *statusBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, parent.view.window.frame.size.width, 20)]; statusBar.backgroundColor = [UIColor blackColor]; [parent.view addSubview:statusBar]; }
Assets/Plugins
に
StatusBarBackgroundColor.csを作成
using UnityEngine; using System.Runtime.InteropServices; public class StatusBarBackgroundColor { [DllImport("__Internal")] private static extern void _Set(); public static void Set() { _Set(); } }
最初のシーンのどっかのAwakeで
StatusBarBackgroundColor.Set();
を呼ぶ。