2023. 9. 21. 03:08
Unity
public GameObject playerIcon;
List<GameObject> playerIcons = new List<GameObject>();
void Start()
{
playerIcon.SetActive(false);
}
void LateUpdate()
{
var gameSystem = GetComponent<GameSystem>();
{
//아군 식별 마커
var characters = GameSystem.GetInGameCharacters(gameSystem.team);
for (int i = playerIcons.Count; i < characters.Length; i++)
{
var instant = Instantiate(playerIcon, playerIcon.transform.parent);
playerIcons.Add(instant);
}
for (int i = characters.Length; i < playerIcons.Count; i++)
{
playerIcons[i].SetActive(false);
}
var cam = Camera.main;
for (int i = 0; i < characters.Length; i++)
{
var markerPosition = characters[i].transform.position + Vector3.up * 1f;
if ((Vector3.Distance(markerPosition, cam.transform.position) > 10)
&& (Quaternion.Angle(cam.transform.rotation, Quaternion.LookRotation(markerPosition - cam.transform.position)) < 90))
{
var screenPoint = RectTransformUtility.WorldToScreenPoint(cam, markerPosition);
playerIcons[i].SetActive(true);
playerIcons[i].GetComponent<RectTransform>().position = screenPoint;
}
else
{
playerIcons[i].SetActive(false);
}
}
}
}
웨이포인트 같은거 표시할때도 씀
'Unity' 카테고리의 다른 글
유니티 애드몹 2023 (0) | 2023.09.24 |
---|---|
유니티 APK 용량 (0) | 2023.09.08 |
유니티 킬로그 (0) | 2023.08.28 |