이미지 준비
작은 동그라미가 원형으로 배열 되어서 투명도가 0~1~0 으로 변화하는 간단한 로딩 화면.
검은색 패널 1개와 작은 둥근원 이미지 8개를 준비
8개의 둥근원의 피벗은 0.5,-2
- 이렇게 하고 z축으로 회전시키면 둥근원의 아래쪽을 기준으로 회전하기 때문
패널에 붙일 코드
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CS_LoadingIndicator : MonoBehaviour
{
public Image[] image_Circle;
int int_CircleCount;
float elapsedTime = 1.0f;
float speed = 2.0f;
private void Start()
{
int_CircleCount = image_Circle.Length;
// 시작 시 둥근 원들을 둥글게 배열시킴
for(int i = 0; i< int_CircleCount; i++)
{
image_Circle[i].rectTransform.rotation = Quaternion.Euler(0.0f, 0.0f, i * (360f / int_CircleCount));
}
}
private void Update()
{
// 틱마다 투명도를 계산
for (int i = 0; i < int_CircleCount; i++)
{
float f_Transparent = (elapsedTime + i * (1f / int_CircleCount)) % 2.0f;
if(f_Transparent > 1)
{
f_Transparent = (2f - f_Transparent)%1f;
}
image_Circle[i].color = new Color(1.0f, 1.0f, 1.0f, f_Transparent);
if(i==0)
{
print(f_Transparent);
}
}
elapsedTime += Time.deltaTime * speed;
}
}
패널 인스펙터의 public Image[] image_Circle; 에 8개의 이미지를 넣어주면 됨
* 복수의 애셋을 인스펙터로 드래그 하려면 인스펙터의 자물쇠 버튼을 눌러 인스펙터를 잠궈야 함
'게임 개발 > 유니티' 카테고리의 다른 글
[ 유니티 iOS ] Sign in With Apple 관련 팁 (0) | 2023.06.24 |
---|---|
[ 유니티 iOS ] 결제 시스템 관련 팁 (0) | 2023.06.23 |
[유니티 iOS] 특정 핸드폰에서 앱이 비활성화된 후 활성화 되었을 때 배경음악이 끊기는 현상 (0) | 2023.06.21 |
[유니티 iOS 빌드] 유니티에서 Plist파일 관리하기 (0) | 2023.06.21 |
[유니티 iOS 멈춤] 앱 추적 허용 팝업에서 버튼을 누른 후 앱이 멈추는 현상 ( 개인적인 이유 ) (0) | 2023.06.20 |