unity 场景加载
来源:互联网 发布:mac os 英文字体 编辑:程序博客网 时间:2024/04/29 18:57
详解地址:http://www.xuanyusong.com/archives/1427
GUI.Draw Texture 绘制纹理
static function DrawTexture (position : Rect, image : Texture, scaleMode : ScaleMode =ScaleMode.StretchToFill, alphaBlend : bool = true, imageAspect : float = 0) : void
实例:
//背景图片
一:
GUI.DrawTexture(new Rect(0,0,Screen.height),backImg, ScaleMode.StretchToFill, true,0.0f);
//这个函数的原型可以省略,若只保留第一二个参数,alhpaBlend 图片的混合模式,是否通道混合图片显示,默认为混合通道,如果不,图片直接被绘制显示。
//scaleMode 将采用StretchToFill 的形式对GUI进行填充。
//scaleMode有三个参数,StretchToFill(伸缩图片填充满整个GUI),scaleAndGrop(保持原有图片形式,在GUI中显示),ScaleToFit(使图片适应GUI)
//imageAspect 如果是0,则使用原图的长宽比
二:Application.CanStreamedLevelBeLoaded 流关卡被加载
能流模式加载的关卡是否被加载?
e.ceeger.com/Script/Application/Application.CanStreamedLevelBeLoaded.html
static function CanStreamedLevelBeLoaded (levelIndex : int) : bool
update中检查能流模式能加载,则加载场景
void Update()
{
if (Application.CanStreamedLevelBeLoaded(LoadingSceneName))
{
if (count == 0)
{
count++;
StartCoroutine(LoadScene());
}
}
Application.LoadLevelAsync 异步加载关卡
http://game.ceeger.com/Script/Application/Application.LoadLevelAsync.html
private IEnumerator LoadScene()
{
Debug.Log("LoadingSceneName:" + LoadingSceneName);
//Debug.Log("开始加载场景...");
//异步读取场景
async = Application.LoadLevelAsync(LoadingSceneName);
//读取完毕自动返回,系统会自动进入下一个场景
yield return async;
}
//在这里计算读取的进度,
//progress 的取值范围在0.1 - 1之间, 但是它不会等于1
//也就是说progress可能是0.9的时候就直接进入新场景了
//所以在写进度条的时候需要注意一下。
//为了计算百分比 所以直接乘以100即可
progress = (
int
)(async.progress *100);
综上:loadScene分为以下几个大类
{
Debug.Log("LoadingSceneName:" + LoadingSceneName);
//Debug.Log("开始加载场景...");
//异步读取场景
async = Application.LoadLevelAsync(LoadingSceneName);
//读取完毕自动返回,系统会自动进入下一个场景
yield return async;
}
{
//背景图片
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backImg, ScaleMode.StretchToFill, true, 0.0f);
for (int i = 0; i < (Screen.width / roadImg.width) + 1; i++)
{
GUI.DrawTexture(new Rect(0 + roadImg.width * i, Screen.height * 0.85f, roadImg.width, roadImg.height), roadImg);
}
GUI.Label(new Rect(Screen.width * 0.25f, Screen.height * 0.2f, 600, 300), "场景加载中,请稍后……", textStyle);
if (count > 0)
GUI.DrawTexture(new Rect(Screen.width * async.progress, Screen.height * 0.85f, carImg.width, roadImg.height), carImg, ScaleMode.ScaleToFit, true, 0.0f);
//GUI.DrawTexture(new Rect(0, Screen.height * 0.6f, roadImg.width, roadImg.height), roadImg);
//显示计算后的进度
//GUI.Label(new Rect(100, 100, 100, 40), "Loading!!! " + progress + "%");
}
Update里面:
void Update()
{
if (Application.CanStreamedLevelBeLoaded(LoadingSceneName))
{
if (count == 0)
{
count++;
StartCoroutine(LoadScene());
}
}
//计算场景的读取进度,这里progress的取值是0到1之间,但是它不会等于1
//也就是说progress可能在0.9的时候就已经加载完新场景了
if (async != null)
progress = (int)(async.progress * 100);
}
- unity 场景加载
- Unity 异步加载场景
- unity加载场景
- Unity 场景异步加载
- Unity 异步加载场景
- unity学习笔记【场景加载】
- UNITY之进度条加载场景
- unity场景切换异步加载
- Unity场景加载与进度条
- Unity异步加载场景与加载进度条
- Unity 异步加载场景的代码
- <Unity3D专区>Unity实现加载场景进度条
- Unity加载火炬之光的场景
- Unity加载火炬之光的场景
- (转)Unity实现加载场景进度条
- Unity加载火炬之光的场景
- Unity异步加载场景loading条
- unity在加载场景时传递参数
- Greenplum 日常维护手册
- JavaScript中清空数组的三种方式
- iOS NSDateFormatter将一串字符串转换成时间格式
- 基于MFC的一个端游launcher---控件操作(二)
- Oracle 11gR2 RMAN Duplicate 触发PLS-00201: identifier 'DBMS_RCVCAT.GETDBID' must be declared 错误
- unity 场景加载
- Linux启动模式
- JS面向对象基础
- 东软总结03-显示数据库中的数据
- 7.5.2:容器中Bean的作用域
- 上周去ThoughtWorks的一次失败的面试经历(二)
- AIX 同步镜像VG中的新LV,手工镜像LV
- Oracle常见错误码及其所对应的的含义
- POJ 3125 (13.07.15)