特别说明:以下仅适用于Android平台。
实现原理
- 创建安卓端自定义的Activity
- 禁用UnityPlayerActivity的启动Logo
- 改用自定义Activity
示例效果
参考简单步骤或详细步骤都可实现。
自定义的启动动画,效果如下:

简单步骤
三步操作实现启动动画的自定义。
导入资源
这里,我预先做好了一个Unitypackage,下载后导入Unity即可。资源链接
这里默认的动画是示例效果中的启动动画。
替换动画
在Assets/Eqgis/Plugins/Android/目录下,找到unitydev...的安卓包。
使用解压工具打开unitydev-1.0.8.aar包,在res\raw\目录下,替换成你制作的"start.mp4"。
注意:你可以先解压aar,待覆盖"start.mp4"文件后,再打包(如,zip包修改aar后缀即可)

修改默认Activity
打开"Player Settings",启用自定义的AndroidManifest。

在Aseets/Plugins/Android目录下找到,AndroidManifest.xml,修改默认的Acitivity为"EqSplashActivity"。
示例如下:
            
            
              xml
              
              
            
          
          <?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    xmlns:tools="http://schemas.android.com/tools">
    <application>
        <activity android:name="com.eqgis.unity.EqSplashActivity"
                  android:screenOrientation="landscape"
                  android:theme="@style/UnityThemeSelector">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
        </activity>
    </application>
</manifest>详细步骤
涉及在Android原生开发。
创建Android Library
使用AndroidStudio,实现自定义的启动页面。
- 
在AndroidStudio中新建一个Android Library模块 
- 
在Android Library模块中导入"unity-classes.jar" 
"unity-classes.jar"可以通过任意Unity项目导出安卓工程的方式得到,也可去unity的git仓库获取。
定制启动页
- 
创建EqSplashActivity.java(这里以"EqSplashActivity"为例,名称可修改) 
- 
编写安卓layout布局 
启动页实现自由度很高,按你心意自定义即可。这里示例代码如下:
EqSplashActivity.java
            
            
              java
              
              
            
          
          public class EqSplashActivity extends Activity {
    private VideoView videoView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        videoView = findViewById(R.id.video_view);
        String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.start;
        Uri uri = Uri.parse(videoPath);
        // 设置视频源
        videoView.setVideoURI(uri);
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                toUnityActivity();
            }
        });
        // 开始播放视频
        videoView.start();
    }
    /**
     * 转至UnityPlayerActivity
     */
    private void toUnityActivity() {
        try {
            Class<?> classtype = Class.forName("com.unity3d.player.UnityPlayerActivity");
            startActivity(new Intent(this, classtype));
            finish();
        } catch (ClassNotFoundException e) {
            Log.e(EqSplashActivity.class.getSimpleName(), "toUnityActivity: ", e);
        }
    }
}activity_main.xml
            
            
              xml
              
              
            
          
          <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="#000"
    android:layout_height="match_parent">
    <VideoView
        android:layout_centerInParent="true"
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>导入AAR
- 在AndroidStudio中打包aar
- 将aar文件拷贝至Unity工程的Assets/...自定义路径.../Plugins/Android的目录下

禁用启动Logo
在Unity端需要修改默认启动的Activity,和禁用启动logo。
- 禁用启动Logo
具体操作是在工程中创建一个脚本"SkipSplash.cs",无需挂载到游戏对象上,只要这个脚本放到除了Editor以外的文件夹就会生效。
            
            
              c#
              
              
            
          
          #if !UNITY_EDITOR
using UnityEngine;
using UnityEngine.Rendering;
public class SkipSplash
{
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
    private static void BeforeSplashScreen()
    {
#if UNITY_WEBGL
        Application.focusChanged += Application_focusChanged;
#else
        System.Threading.Tasks.Task.Run(AsyncSkip);
#endif
    }
#if UNITY_WEBGL
    private static void Application_focusChanged(bool obj)
    {
        Application.focusChanged -= Application_focusChanged;
        SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
    }
#else
    private static void AsyncSkip()
    {
        SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
    }
#endif
}
#endif修改默认Activity
打开"Player Settings",启用自定义的AndroidManifest。

在Aseets/Plugins/Android目录下找到,AndroidManifest.xml,修改默认的Acitivity为"EqSplashActivity"。
示例如下:
            
            
              xml
              
              
            
          
          <?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    xmlns:tools="http://schemas.android.com/tools">
    <application>
        <activity android:name="com.eqgis.unity.EqSplashActivity"
                  android:screenOrientation="landscape"
                  android:theme="@style/UnityThemeSelector">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
        </activity>
    </application>
</manifest>