2016-09-27 101 views
0

我正在製作遊戲。我也做了一個保存遊戲並加載遊戲。 我想要的是當我加載遊戲(這意味着代碼加載)我會顯示加載進度,直到代碼加載執行完成。創建加載等待執行特定代碼直到完成Unity

例如(LoadGame.cs):

using UnityEngine; 
using System.Collections; 

public class Load_Timer_Merchant : MonoBehaviour { 
    CloudSaver CloudSave; 

    // Use this for initialization 
    void Start() { 
     CloudSave = GameObject.FindGameObjectWithTag("CloudSave").GetComponent<CloudSaver>(); 

     CloudSave.Load_Timer_Merchant(); 
    } 

    // Update is called once per frame 
    void Update() { 

    } 
} 

我要作出這樣的文件腳本LoadGame.cs

的進展裝載這是可能做到這一點?

感謝

Dennnis

回答

0

你需要Co-routine做這個任務 例如,你想從一個url像這樣

IEnumerator DoImageLoad() 
{ 
    WWW txTexture = new WWW(m_szTexturePath); 
    yield return txTexture; 
    renderer.material.mainTexture = txTexture.texture; 
    Debug.Log("Image Loaded. This message will show as image loaded"); 
} 
    Start(){ 
    StartCoroutine("DoImageLoad"); 
    } 
+0

嗨Faizan記錄成功的文字圖片的加載,我的意思是像Application.LoadLevelAsync。如果我們使用這個,我們可以使加載的百分比。但那只是爲了改變關卡的場景。那麼加載遊戲怎麼樣,等到所有遊戲加載完畢? –

+0

這意味着我們如何知道執行上面的腳本需要多少時間。所以我可以讓進度加載等待.. –

+0

我仍然與這個問題混淆。腳本加載是什麼意思? –