Unity,如何在背景图片前面设置精灵? [英] Unity, How to set the sprite in front the background Image?

查看:407
本文介绍了Unity,如何在背景图片前面设置精灵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了背景图片,并制作了动画.问题在于动画层位于背景图像的后面.

I had make a background image, and running an animation. The problem is the animation layer is behind the background image.

如何排序?

信息(请参见屏幕截图):

Information (see the screenshot):

背景图片:z = 0(图片上为绿色),GUITexture

Background Image : z = 0 (Green Color on the picture), GUITexture

爆炸:z = -5(图片上的黄色),精灵渲染器

explosion : z = -5 (Yellow color on the picture), sprite Renderer

相机:z = -10

camera : z = -10

我尝试过反转数字,但是仍然相同.我也尝试在背景图片上添加Sprite组件,但是排序层看起来仍然不起作用(可能使用了错误的方法).

I had try Reverse the number, but it still same. I also try to add sprite component on the background image, but the sort layer look like still not working(maybe using wrong method).

下面是屏幕截图.

推荐答案

仅供参考

好吧,您可能要做的第一件事就是更改Z轴.如果您使用的是2D正交相机,则不会在子图形的大小上产生差异.如果距离很小,您将尝试所谓的Z格斗.

Well, the first thing you could an is common to do is to change the Z axis. If you are using a 2D orthogonal camera, that doesn't generate difference in the size of the sprites. If the distances are small you are going to experiment the so called Z fighting.

但是在这种情况下,正确的方法是使用排序图层和图层排序"属性.您也可以检查.

But the correct way to do it in this case would be to use the sorting layers and the Order in layer property. You can check this our too.

对于这种情况

我假设您指的是静态背景,但始终存在. 两个摄像头的方法很酷.

I assume that your are referring to an static background, that is always there, still. This two cameras approach is cool.

我不知道您在玩哪种游戏,但是在大多数情况下,静止的背景往往很无聊,而且如果您利用摄影机的视角,也可以通过将背景放在一个不同的Z :)

I don't know what kind of game are you doing, but an still background in most cases tend to be boring, and if you take advantage of the camera perspective you can get also a nice parallax effect by positioning the background on a different Z :)

用于Z战的骇客

我使用此脚本解决纹理之间的Z争斗.它会覆盖渲染队列. hacky,但高效.您只需更改值,然后首先呈现较高的值!

I use this script for solving the Z fighting between textures. It overrides the render queue. Is hacky, but efficient. You just change the value and the higher values are rendered first!

using UnityEngine;
using System.Collections;

public class OverrideRenderQueue : MonoBehaviour {
    public int queueOrder = 3000;

    void Start ()
    {
        renderer.material.renderQueue = queueOrder;
    }
}

这篇关于Unity,如何在背景图片前面设置精灵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆