• 动态加载网上或者本地场景


    中秋节在外,一个人无聊+无奈,幸而在朋友家里蹭了顿饭,顺便打发时间,在此感谢我的朋友。放假两天,睡了两天,今天开始上班,顺便写点东西。
    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;
    功能及使用说明:
    1、建立一个Cube,然后将这段代码加到Cube上。
    2、建立一个GUITexture,并命名为guiTexture,选择Texture。这个GUITexture主要是用作进度条的。
    功能:动态加载网上或者本地场景
    点击Cube,加载场景,等进度条不再变化时进入你想进入的场景,点击时Cube没有变化,希望大家可以完善它。

    // 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)
  • 相关阅读:
    【二分图】HEOI2012 朋友圈
    【转载】动态规划—各种 DP 优化
    【默哀】京阿尼纵火案一周年
    【暑假集训】HZOI2019 Luogu P1006 传纸条 二三四维解法
    【暑假集训】HZOI2019 水站 多种解法
    最小二乘法求线性回归方程
    51Nod 最大M子段和系列 V1 V2 V3
    【博弈论】51Nod 1534 棋子游戏
    【最短路】CF 938D Buy a Ticket
    51nod1524 最大子段和V2
  • 原文地址:https://www.cnblogs.com/Mygirl/p/2003121.html
Copyright © 2020-2023  润新知