Explanation.
NGUI를 사용하여 게임제작시
자동으로 Depth를 조정해주는 스크립트
depth의 범위를 지정안하고 그냥
포지션의 y값을 가지고와서 depth로 적용.
Todo.
정해진 depth 범위내에서 적용되도록 변경.
![]() |
| 기본 |
![]() |
| Auto Depth 적용전 |
![]() |
| Auto Depth 적용후 |
using UnityEngine;
using System.Collections;
public class AutoDepth : MonoBehaviour {
private UISprite mSprite;
private Transform mTransform;
private int waitFrameCount = 15;
void Start () {
mSprite = GetComponent();
mTransform = transform;
StartCoroutine("depthCoroutine");
}
IEnumerator depthCoroutine()
{
for (int i = 0; i < waitFrameCount ; ++i)
yield return null;
mSprite.depth = -(int)mTransform.localPosition.y;
StartCoroutine("depthCoroutine");
}
}



0 개의 댓글:
댓글 쓰기