zoukankan      html  css  js  c++  java
  • 动态加载网上或者本地场景(转)

    var gui : GUITexture;
    var find : GameObject;
    var GameObjectName;
    function Awake(){
    //找到guiTexture,当初始加载时让其不可用
       find=GameObject.Find("guiTexture");
       find.active=false;
       GameObjectName=GameObject.Find("Cube").tag;//通过tag来传递参数给www()函数
    }
     
    function OnMouseDown(){
       find.active=true;
       //Debug.Log(GameObjectName);
       var SenceName=GameObjectName;
       www(SenceName);
    }
     
    function www(Cubename){
    // Store the original pixel inset
    // and modify it from there.
    var originalPixelRect = gui.pixelInset;
    //功能及使用说明:<br>1、建立一个Cube,然后将这段代码加到Cube上。<br>2、建立一个GUITexture,并命名为guiTexture,选择Texture。这个GUITexture主要是用作进度条的。<br>功能:动态加载网上或者本地场景<br>点击Cube,加载场景,等进度条不再变化时进入你想进入的场景,点击时Cube没有变化,希望大家可以完善它。<br><br>
     
    // Update the progress bar by scaling the gui texture
    // until we reach the end
    // var stream=new WWW("http://unity3d.com/gallery/hosted-demos/dressingroom.unity3d");本地连接官网上的例子
    var stream=new WWW(""+Cubename+".unity3d");//CubeName为你将要下载的场景名字
    while (!stream.isDone)
    {
    gui.pixelInset.xMax = originalPixelRect.xMin+ stream.progress * originalPixelRect.width;
    yield;
    }
    // Update it one last time before loading
    gui.pixelInset.xMax = originalPixelRect.xMax;
    stream.LoadUnityWeb();
    }
    @script RequireComponent (GUITexture)
    
    aliyun活动 https://www.aliyun.com/acts/limit-buy?userCode=re2o7acl
  • 相关阅读:
    【转载】C/C++预处理器
    【转载】C/C++内存管理详解
    Spring知识点整理
    Hibernate知识点整理
    MyBatis知识点整理
    数据可视化(三)- Seaborn简易入门
    数据可视化(二)
    数据可视化(一)-Matplotlib简易入门
    Pandas之容易让人混淆的行选择和列选择
    Pandas简易入门(四)
  • 原文地址:https://www.cnblogs.com/wangbin/p/2335850.html
Copyright © 2011-2022 走看看