如何修改java启动界面_unity启动界面splash的设置和研究(logo过大,背景模糊)...

本文介绍了如何在Unity中调整启动界面(splash screen),包括如何缩小logo、设置清晰背景以及实现logo动画。通过设置纯色背景并结合适当图片处理,可以避免logo过大和背景模糊的问题。此外,通过选择不同的scaling选项,可以实现背景清晰显示。若要同时展示logo动画,可以在静态启动画面后接带有logo的场景。
摘要由CSDN通过智能技术生成

unity自带的splash功能在player setting下设置:

530c5f8ea7085451d506f2b6b1f476b0.png

常用的配置选项一般都能看懂,使用中有两个问题

1.  怎样把logo缩小

logo配背景图的方式下,logo会非常大,比较难看,原因是logo图的大小是固定的,而且宽度占据屏幕宽度的一半以上。

比如logo设为这个:

79e435a566412253ec81d282f706c3f9.png

spalsh显示效果如图:

66e501fde9705b19efcc3e52a682035a.png

想要把logo缩小,怎么办?

解决办法是,设置纯色背景,将logo缩小,放在一张大图之中比如logo.png,logo.png的背景设为和splash background color同色。

比如背景如果是白的,logo.png的背景也设为白的

a38dd7e28fed3ea09076f2d6fa859a2a.png

这样,logo.png占据屏幕正中的时候,真正的logo只占了屏幕正中的一小部分,实现了logo的缩小。

72769acb3f0032a3408e0051b7edb8ef.png

8436061230bca2e7da2ed34950c0c7a7.png

注意,logo.png的logo之外的背景不能设为透明

019d34b2c0bc4a028a68b6b098c00b62.png

像上图这样设完,unity还是会自动放大logo。

227c61408e4e755868fbd82b532181fa.png

1b62a7c33acec146709beaa6f06fbd1f.png

那么,背景不想设为纯色,而是设为背景图片该怎么办?利用上面过程之中发现的特点,有个取巧的办法,我们在制作纯色png的logo时,在图片相对的两个角落里根据背景图片的相近颜色点上两个点。

比如我就在图中红圈的位置点了两个白点:

c88e43926812268f95fa78bbff470f61.png

然后使用一张白色比较多的背景图片:

700f177df234d35015038389c877f847.png

效果就是这样的了:

5c3e7a210d04da48243cf184a44d1d17.png

2.  背景清晰

但这种方式设置完的splash背景总是模糊的,该怎么办?

可以关掉show spalsh screen,然后在static spalsh image里设一张带有logo和背景的大图,scaling选scale to fill(cropped)比如下面:

25ffbe217165a87765f51bb80e10e03e.png

效果就是这样了,非常清晰:

230a3d579d144222bb52338a21734faf.png

scalling一共有三种方式:

Center (only scale down) will try to draw your image "pixel correct", with no scaling unless needed to fit it on screen.

居中(只是缩小),以正确的像素显示图片,不会缩放图片除非需要。

Scale to fit (letter-boxed) will try to draw your image full screen, but without cropping it, an fill the empty space with black pixels.

自适应缩放大小(高宽比不变)尝试满屏显示,但不会裁剪,并用黑色填充空白的地方。

Scale to fill (cropped) will draw your image full screen, and cut the parts which extend outside the screen.

自适应填充(裁切不正的)满屏显示,屏幕外的部分将不显示。

一般我们选第三种。这三种方式的区别,如果图比较大,前两种是没什么区别的,但是当换成比较小的图时就可以看出三种方式的区别了:

Center (only scale down) ,只是缩小,不会放大:

dd2eccf3a95f26d85b4439b7cbc8ae53.png

(注意此种方式,当你图片非常大,但是比例和屏幕比例不一致时,会保持原图长宽比不变进行简单地缩小,直到屏幕能显示图片所有内容为止,所以也会出现黑边)

比如原图是这样的:

3eeeb95df8c01f16553fdc7e172408fb.png

显示效果是这样的:

9aa6f1caff0dd0604cd39a66d8cf139d.png

Scale to fit (letter-boxed),这种情况下只要比例不合,无论图片过小还是过大,都会尝试等比例缩小或扩大图片,以显示图片全部内容,并保持图片的长或宽充满屏幕。

b550be9635dd5126a80a25010c6b838d.png

Scale to fill (cropped),当图片过大,等比例缩小直到图片的长和宽之中有一个和屏幕正好相等。当图片过小,则等比例拉伸直到没有黑边。

ebb44f37f05ef2e65442875e1cfa4a50.png

3. 背景既要清晰,又要logo的动画,该怎么做?

这个更简单,先在static spalsh image里设一张没有logo的清晰背景大图。然后把你的第一个scene里写一段logo的动画,背景还是static spalsh image里那张背景大图。这样程序启动时,先显示背景,然后进入scene之中显示带背景的logo动画。

不过需要掌握好图片被裁切的比例和大小,以免被人看出scene之间的切换。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unity DOTS 1.0中,可以使用ECS(Entity Component System)来播放帧动画。以下是一个简单的例子: 1. 创建一个帧动画组件 ```csharp public struct FrameAnimationComponent : IComponentData { public int currentFrame; public int maxFrame; public float timePerFrame; public float elapsedTime; } ``` 这个组件包含了当前帧、最大帧数、每帧持续时间以及已经经过的时间。 2. 创建一个帧动画系统 ```csharp [UpdateInGroup(typeof(PresentationSystemGroup))] public class FrameAnimationSystem : SystemBase { protected override void OnUpdate() { float deltaTime = Time.DeltaTime; Entities.ForEach((ref FrameAnimationComponent animationComponent) => { animationComponent.elapsedTime += deltaTime; if (animationComponent.elapsedTime >= animationComponent.timePerFrame) { animationComponent.currentFrame++; animationComponent.elapsedTime = 0f; if (animationComponent.currentFrame >= animationComponent.maxFrame) { animationComponent.currentFrame = 0; } } }).ScheduleParallel(); } } ``` 这个系统会遍历所有包含了帧动画组件的实体,更新它们的当前帧,同时检查是否到达最大帧数,如果是则重置为0。 3. 创建一个帧动画渲染系统 ```csharp [UpdateInGroup(typeof(PresentationSystemGroup))] public class FrameAnimationRenderSystem : SystemBase { private EntityQuery frameAnimationQuery; private Material material; protected override void OnCreate() { frameAnimationQuery = GetEntityQuery(ComponentType.ReadOnly<FrameAnimationComponent>(), ComponentType.ReadOnly<SpriteRenderer>()); material = Resources.Load<Material>("FrameAnimationMaterial"); // 用于渲染帧动画的材质 } protected override void OnUpdate() { var sprites = GetComponentDataFromEntity<SpriteRenderer>(true); var frameAnimations = GetComponentDataFromEntity<FrameAnimationComponent>(true); Entities.WithoutBurst().ForEach((Entity entity, ref DynamicBuffer<SpriteBufferElement> spriteBuffer) => { if (!frameAnimations.HasComponent(entity)) { return; } var animation = frameAnimations[entity]; var sprite = sprites[entity]; int frameIndex = animation.currentFrame * sprite.numSubMeshes; for (int i = 0; i < sprite.numSubMeshes; i++) { spriteBuffer[i] = new SpriteBufferElement { sprite = sprite.subMeshes[i].sprites[frameIndex + i], material = material }; } }).WithStructuralChanges().Run(); } } ``` 这个系统会遍历所有包含了帧动画组件和SpriteRenderer组件的实体,根据当前帧数和SpriteRenderer的子网格数来更新DynamicBuffer中的SpriteBufferElement,这样就可以渲染出帧动画了。 需要注意的是,这个例子仅适用于单个SpriteRenderer组件中包含了整个帧动画的情况。如果需要对不同的子网格分别播放帧动画,则需要做一些修改
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值