유 니 티 필드 전환 진도 표시 실현
UI슬라이더 를 만 들 고 적당 한 변경 을 하면 됩 니 다.


2.loadScene 스 크 립 트 를 추가 하여 장면 전환 을 하고 임의의 물체 에 연결 합 니 다.블 로 거들 은 메 인 카 메 라 를 놓 는 것 을 예 로 들 었 다.매개 변 수 는 각각 진도 바(value 값 설정)로 진도 텍스트 text 를 표시 합 니 다.

설정 에 두 필드 추가:

3.대본;
/// <summary>
///
/// unity progress , 0.9. 1
/// progress 0.9, 1, 100%
/// progress , ,
/// , ++。
/// </summary>
public class loadScene : MonoBehaviour
{
AsyncOperation async;
public Slider slider;
public Text text;//
void Start()
{
//
StartCoroutine("loginMy");
}
void Update()
{
}
IEnumerator loginMy()
{
int displayProgress = 0;
int toProgress = 0;
AsyncOperation op = SceneManager.LoadSceneAsync(1);
op.allowSceneActivation = false;
while (op.progress < 0.9f) // <= 0.9f 0.9
{
toProgress = (int)op.progress * 100;
while (displayProgress < toProgress)
{
++displayProgress;
SetLoadingPercentage(displayProgress);
yield return new WaitForEndOfFrame();//ui
}
}
toProgress = 100;
while (displayProgress < toProgress)
{
++displayProgress;
SetLoadingPercentage(displayProgress);
yield return new WaitForEndOfFrame();
}
op.allowSceneActivation = true;
}
private void SetLoadingPercentage(int displayProgress)
{
slider.value = displayProgress;
text.text = displayProgress.ToString() + "%";
}
}
4.실행:
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Unity 최적화1. 프레임마다 처리하는 것을 최대한 피한다. 예를 들면: 5프레임당 한 번 처리로 변경할 수 있습니다. 2. 정시 반복 처리는 InvokeRepeating 함수로 이루어집니다. 예를 들어 0.5초 동안 시작한 후 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.