去掉unity打包的apk左上角转圈圈(splash替换黑屏)

本文介绍了如何在Unity打包的APK中去除左上角的启动转圈,改用自定义的启动画面。通过创建UnityPlayerActivity,并在其中添加原生代码,实现显示自定义的 splash 屏幕,同时提供了隐藏 splash 屏幕的方法。
摘要由CSDN通过智能技术生成
勾选显示splash,然后用原生添加显示splash
public class UnityPlayerActivity extends Activity
{
    protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code

    // Setup activity layout
    @Override protected void onCreate(Bundle savedInstanceState)
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);

        getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy

        mUnityPlayer = new UnityPlayer(this);
        setContentView(mUnityPlayer);
        mUnityPlayer.requestFocus();
        UnitySplashSDK.getInstance().onCreate(this,savedInstanceState);
   
    }


    public void HideSplash()
    {
        Log.d("UnityPlayer","Android_HideSplash");
        UnitySplashSDK.getInstance().onHideSplash();
    }
package com.aiiage.steam.evolve;

impor
Unity中,打包APK并读取StreamingAssets文件夹中的图片文件,然后将其转换成Sprite实例的过程可以分为以下步骤: 1. 准备图片资源:首先确保你的图片资源已经放置在项目的Assets/StreamingAssets文件夹内。StreamingAssets文件夹中的资源在打包后会被包含在APK文件中。 2. 打包APK:在Unity编辑器中选择File -> Build Settings,然后选择Android平台,点击"Player Settings"进行APK打包设置。之后点击"Build"或"Build and Run"来打包APK文件。 3. 读取StreamingAssets中的图片:打包后的APK会在设备上安装一个包含StreamingAssets文件夹的文件系统,你可以通过以下代码读取其中的图片资源,并将其转换为Sprite: ```csharp using System.IO; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class ImageLoader : MonoBehaviour { public string imagePath; // StreamingAssets中的图片文件路径 void Start() { // 获取StreamingAssets文件夹中的图片完整路径 string fullPath = Path.Combine(Application.streamingAssetsPath, imagePath); // 使用WWW类加载图片 WWW www = new WWW(fullPath); yield return www; // 检查图片是否成功加载 if (string.IsNullOrEmpty(www.error)) { // 从加载的图片中获取Texture2D对象 Texture2D texture = new Texture2D(2, 2); texture.LoadImage(www.bytes); // 将Texture2D对象转换为Sprite对象 Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); // 在这里你可以将生成的Sprite对象赋给UI的Image组件或使用其他方式展示 } else { Debug.LogError("Error loading image from StreamingAssets: " + www.error); } } } ``` 以上代码中,你需要将`imagePath`变量设置为StreamingAssets文件夹内图片的相对路径。然后在Start方法中使用WWW类来异步加载图片。当图片加载完成后,从WWW对象中获取图片数据并创建一个Texture2D对象,接着使用Texture2D对象来创建一个Sprite对象。 请确保使用WWW类加载网络资源时要注意网络权限,对于从StreamingAssets加载资源则无需额外权限。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值