SplashScreen textures from edito
2016-06-13 本文已影响171人
2b75747cf703
开屏图想放在框架中自动打包,而不用每个项目都要去拖动一次。
http://forum.unity3d.com/threads/splashscreen-textures-from-editor-script.187930/
到处搜索没搜到解决方案。。。
反编译了一下UnityEditor.dll,然后看到了。。。
Paste_Image.png结合ProjectSettings.asset
Paste_Image.pngusing System.IO;
using UnityEditor;
using UnityEngine;
using Babybus.Framework.ExtensionMethods;
namespace Babybus.Builder
{
public class BuildPlayerBase
{
protected static void SetSplashScreens()
{
#if UNITY_ANDROID
SetSplashScreen("androidSplashScreen", "800x480");
#endif
#if UNITY_IOS
if (!SetSplashScreen("iPhoneSplashScreen", "320x480"))
SetSplashScreen("iPhoneSplashScreen", "480x320");
if (!SetSplashScreen("iPhoneHighResSplashScreen", "640x960"))
SetSplashScreen("iPhoneHighResSplashScreen", "960x640");
if (!SetSplashScreen("iPhoneTallHighResSplashScreen", "640x1136"))
SetSplashScreen("iPhoneTallHighResSplashScreen", "1136x640");
if (!SetSplashScreen("iPhone47inSplashScreen", "750x1334"))
SetSplashScreen("iPhone47inSplashScreen", "1334x750");
SetSplashScreen("iPhone55inPortraitSplashScreen", "1242x2208");
SetSplashScreen("iPhone55inLandscapeSplashScreen", "2208x1242");
SetSplashScreen("iPadPortraitSplashScreen", "768x1024");
SetSplashScreen("iPadHighResPortraitSplashScreen", "1536x2048");
SetSplashScreen("iPadLandscapeSplashScreen", "1024x768");
SetSplashScreen("iPadHighResLandscapeSplashScreen", "2048x1536");
#endif
}
private static bool SetSplashScreen(string name, string size)
{
var property = typeof(PlayerSettings).Invoke("FindProperty", name) as SerializedProperty;
property.serializedObject.Update();
var assetPath = "Assets/BabyFrameWork/SplashScreens/SplashScreen-" + size + ".jpg";
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(assetPath);
property.objectReferenceValue = texture;
property.serializedObject.ApplyModifiedProperties();
return texture != null;
}
}
}