Unity3D로 2D 게임을 제작하고 있습니다. 단색 배경을 그리기 위해 노력하고 있는데, 앞에 스프라이트가 몇 개 있습니다. unity3d로 2D 게임에서 단색 배경을 그리는 방법은 무엇입니까?
는이 코드 발견 :using UnityEngine;
using System.Collections;
public class GUIRect : MonoBehaviour {
public Color color;
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update() {
}
private static Texture2D _staticRectTexture;
private static GUIStyle _staticRectStyle;
// Note that this function is only meant to be called from OnGUI() functions.
public static void GUIDrawRect(Rect position, Color color)
{
if(_staticRectTexture == null)
{
_staticRectTexture = new Texture2D(1, 1);
}
if(_staticRectStyle == null)
{
_staticRectStyle = new GUIStyle();
}
_staticRectTexture.SetPixel(0, 0, color);
_staticRectTexture.Apply();
_staticRectStyle.normal.background = _staticRectTexture;
GUI.Box(position, GUIContent.none, _staticRectStyle);
}
void OnGUI() {
GUIDrawRect(Rect.MinMaxRect(0, 0, Screen.width, Screen.height), color);
}
}
나는 빈 게임 객체에 부착을하고, 좋은 일하고,하지만 난 그 장면에서 다른 스프라이트 사이의 z 순서를 결정할 수 없습니다.
올바른 방법입니까? 그렇다면, 어떻게 그 순서를 바꿔야합니까?
나는 유니티 프로를 사용하지 않습니다. D : 그러나 팁 주셔서 감사합니다. 단색 배경을 만들려면 텍스처를 사용해야합니까? 그리고 런타임에 색상을 변경 하시겠습니까? – ProGM
예, 배경은 텍스처 (jpg 등)처럼 단순 할 수 있습니다. 애셋에서 선택하고 2D 모드 인 경우 화면으로 드래그하면됩니다. 그렇다면 카메라가 직각 좌표에 있는지 확인하고 꺼져 있는지 확인하십시오! "계층화 된"배경을 원한다면 알파 레이어가있는 텍스처를 사용하여 볼 수 있습니다. –
마지막 질문이 보이지 않음 - "gameObject.renderer.material.color = Color (0.777, 08, 0.604);" –