當前位置:編程學習大全網 - 編程軟體 - unity ngui怎麽做視頻播放進度條怎麽賦值

unity ngui怎麽做視頻播放進度條怎麽賦值

腳本

public GameObject BtnGaoLu;

public UISlider MyUISlider;

private bool isLoad=false;

private AsyncOperation async;

float progress = 0;

void Awake()

{

UIEventListener.Get(BtnGaoLu).onClick = fnChangeSence;

MyUISlider.alpha = 0;

}

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

//繪制進度條,但是由於時間太短,效果不好

if (isLoad)

{

MyUISlider.alpha = 1;

progress = Convert.ToSingle((async.progress.ToString("f2")));

if (progress > 0)

{

MyUISlider.GetComponent<UISlider>().value = progress+0.8f;

//此處添加0.8f是因為我只加載到85%就跳轉了,為了達到進度條到達100*的效果,所以添加了0.8,是實際情況而定。

print(progress);

}

}

}

void fnChangeSence(GameObject obj)

{

StartCoroutine(fnLoadSence("Final_Scene"));

}

IEnumerator fnLoadSence(string strSenceName)

{

isLoad = true;

async = Application.LoadLevelAsync(strSenceName);

yield return async;

}

  • 上一篇:馮春250sr儀表盤的詳細說明是什麽?
  • 下一篇:如何編程,在屏幕上輸出2010年的年歷
  • copyright 2024編程學習大全網