2016-09-27 100 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

我仍然与这个问题混淆。脚本加载是什么意思? –