/// <summary> /// IOS Splash Image設定 /// </summary> public void UISplashIOSShow() { GUILayout.Label("IOS Splash 圖片", TitleFrontStyle()); for (int i = 0; i < mShowSetInfo.IOSSet.SplashImages.Length; i++) { eMobileSplashScreen aShowScreen = (eMobileSplashScreen)i; IconObjectSet(aShowScreen.ToString(), ref mUIUseImages.IOSSplashImages[i], ref mShowSetInfo.IOSSet.SplashImages[i]); } }
/// <summary> /// 取得Splash圖片路徑 /// </summary> public static string GetSplashScreenPath(eMobileSplashScreen iScrType, ref Texture2D iImage) { string aResult = string.Empty; iImage = GetSplashScreen(iScrType); if (iImage != null) { aResult = AssetDatabase.GetAssetPath(iImage); } return(aResult); }
/// <summary> /// 設置Splash圖片 /// </summary> public static void SetSplashScreen(eMobileSplashScreen iScrType, string iPath) { foreach (var player in Resources.FindObjectsOfTypeAll <PlayerSettings> ()) { var so = new SerializedObject(player); so.Update(); so.FindProperty(iScrType.ToString()).objectReferenceValue = AssetDatabase.LoadAssetAtPath(iPath, typeof(Texture2D)); so.ApplyModifiedProperties(); EditorUtility.SetDirty(player); } AssetDatabase.SaveAssets(); }
// 這邊用到的方法是直接提取PlayerSettings設定檔的內容 // 設定名稱可以從Edit/ProjectSetting/Editor中把AssetSerialization轉成文字模式 // 再用記事本檔案查看PlayerSetting是甚麼名字 // 當PlayerSettings沒有提供相關方法時所採用的最後手段 #region SerializedObject /// <summary> /// 取得PlayerSetting上的Splash圖片 /// </summary> public static Texture2D GetSplashScreen(eMobileSplashScreen iScrType) { Texture2D aResult = null; PlayerSettings[] aAllSet = Resources.FindObjectsOfTypeAll <PlayerSettings> (); for (int i = 0; i < aAllSet.Length; i++) { SerializedObject aSO = new SerializedObject(aAllSet[i]); aSO.Update(); aResult = aSO.FindProperty(iScrType.ToString()).objectReferenceValue as Texture2D; } return(aResult); }