Unity3d 2种重要方法的使用

Unity3d 2种重要方法的使用

GetStreamProgressForLevel()

  in the webplayer, returns the progress of the actual level (from theofficial documentation). With "progress" it's intended the loading progress...Since the game will be stored on a server (generally), a certain time period is required to send the data of a particular scene to the client. The documentation reports a clear example:

Code:

function Update() {
    if(Application.GetStreamProgressForLevel(1) == 1) {
        guiText.text = "Level at index 1 has been fully streamed!";
    } else {
        percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
        guiText.text = percentageLoaded.ToString();
    }
}

Easy, uh? With this, you can know what percentage of the scene has been "loaded". That is, what percentage of the level has been "streamed" from the server to the client. And you can fill you loading bar accordingly, for the sake of your question. Even with the free version of Unity.


LoadLevelAsync() 

(THAT REQUIRES UNITY PRO), instead, loads the level asynchronously in the background (always from the documentation). See this example:

Code:

function Start () {
    // Load the level named "MyBigLevel".
    var async : AsyncOperation = Application.LoadLevelAsync ("MyBigLevel");
    yield async;
    Debug.Log ("Loading complete");
}

A message will be printed on the console as soon as "MyBigLevel" has been loaded (or, as we said before, "streamed"). It is indicated for performance reasons, that's why it (wisely) requires Unity Pro.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值