Unity3D 动态显示场景跳转提示框
2013-05-09 16:03
309 查看
#pragma strict
//Author:Andy Sun
//Time:2013/4/16
//Function:Load a new scene
var newScene:String;//The Scene that will be Loaded
var sceneView:Texture2D;//The view image the loaded scene
private var firstPersonPlayer:GameObject;
private var label_width_Max:float;//The max width of the Label
private var label_height_Max:float;//The max height of the Label
private var label_width:float=0.0f;//The width of the Label
private var label_height:float=0.0f;//The height of the Label
private var showPrompt:boolean=false;
private var script:Follow_Load;//Get the Script Object
private var enter:boolean=false;//If the Player Enter the Trigger
function Start () {
if(GameObject.FindWithTag("Manager")){
firstPersonPlayer = GameObject.FindWithTag("Manager");
script = firstPersonPlayer.GetComponent(Follow_Load);
}
}
function Update () {
label_width_Max = Screen.width/3;
label_height_Max = Screen.height/3;
if(label_width<label_width_Max && showPrompt){
label_width += label_width_Max*0.05;
}
if(label_height<label_height_Max && showPrompt){
label_height += label_height_Max*0.05;
}
if(!showPrompt && (label_width>0.0f)){
label_width-=label_width_Max*0.05;
}
if(!showPrompt && (label_height>0.0f)){
label_height-=label_height_Max*0.05;
}
}
function OnGUI()
{
//if the distance is less than 1.0f,show the prompt
if(enter){
showPrompt = true;
GUI.DrawTexture(new Rect(Screen.width/2-label_width/2,Screen.height/2-label_height/2,label_width,label_height),sceneView,ScaleMode.StretchToFill,true,10.0f);
if(GUI.Button(new Rect(Screen.width/2-label_width/6,Screen.height/2+label_height/2-label_height/5,label_width/3,label_height/10),"进入/"+""+newScene))
{
script.Load_Level(newScene);//Load a new Scene
}
}else{//if the distance is more than 5.0f,clear away the prompt
showPrompt = false;
GUI.DrawTexture(new Rect(Screen.width/2-label_width/2,Screen.height/2-label_height/2,label_width,label_height),sceneView,ScaleMode.StretchToFill,true,10.0f);
}
}
function OnTriggerEnter (other : Collider) {
enter=true;
}
function OnTriggerExit (other : Collider) {
enter=false;
}
//Author:Andy Sun
//Time:2013/4/16
//Function:Load a new scene
var newScene:String;//The Scene that will be Loaded
var sceneView:Texture2D;//The view image the loaded scene
private var firstPersonPlayer:GameObject;
private var label_width_Max:float;//The max width of the Label
private var label_height_Max:float;//The max height of the Label
private var label_width:float=0.0f;//The width of the Label
private var label_height:float=0.0f;//The height of the Label
private var showPrompt:boolean=false;
private var script:Follow_Load;//Get the Script Object
private var enter:boolean=false;//If the Player Enter the Trigger
function Start () {
if(GameObject.FindWithTag("Manager")){
firstPersonPlayer = GameObject.FindWithTag("Manager");
script = firstPersonPlayer.GetComponent(Follow_Load);
}
}
function Update () {
label_width_Max = Screen.width/3;
label_height_Max = Screen.height/3;
if(label_width<label_width_Max && showPrompt){
label_width += label_width_Max*0.05;
}
if(label_height<label_height_Max && showPrompt){
label_height += label_height_Max*0.05;
}
if(!showPrompt && (label_width>0.0f)){
label_width-=label_width_Max*0.05;
}
if(!showPrompt && (label_height>0.0f)){
label_height-=label_height_Max*0.05;
}
}
function OnGUI()
{
//if the distance is less than 1.0f,show the prompt
if(enter){
showPrompt = true;
GUI.DrawTexture(new Rect(Screen.width/2-label_width/2,Screen.height/2-label_height/2,label_width,label_height),sceneView,ScaleMode.StretchToFill,true,10.0f);
if(GUI.Button(new Rect(Screen.width/2-label_width/6,Screen.height/2+label_height/2-label_height/5,label_width/3,label_height/10),"进入/"+""+newScene))
{
script.Load_Level(newScene);//Load a new Scene
}
}else{//if the distance is more than 5.0f,clear away the prompt
showPrompt = false;
GUI.DrawTexture(new Rect(Screen.width/2-label_width/2,Screen.height/2-label_height/2,label_width,label_height),sceneView,ScaleMode.StretchToFill,true,10.0f);
}
}
function OnTriggerEnter (other : Collider) {
enter=true;
}
function OnTriggerExit (other : Collider) {
enter=false;
}
相关文章推荐
- Unity3D【脚本】 异步切换场景,显示进度到滚动条
- Unity3d动态显示/隐藏GUI
- Unity3d NGUI的使用(十二)(UIGrid动态列表显示)
- unity3d 动态添加模型到场景中
- Unity3D淡入淡出场景跳转
- [unity3d]从服务器端获取资源动态加载到场景
- Unity3D之动态修改烘培贴图的大小&脚本烘培场景
- 页面操作完成时,显示提示信息并倒计N秒后跳转(草)
- 跟随鼠标的移动,动态显示提示信息
- 当跳转到一个需要访问数据的Activity时,显示进度条,给客户友好提示画面
- html动态显示提示
- 搜索框输入内容,动态显示提示(ajax)
- [unity3d]从服务器端获取资源动态加载到场景
- unity3d实现动态显示伤害值
- js实现 页面显示系统时间(中文显示星期)、动态倒计时页面跳转
- html动态显示提示
- Unity3D:按钮实现场景的跳转
- jsp3s倒计时页面跳转(页面动态显示3.2.1.0)
- Unity3D 游戏开发构架篇 —— 动态大场景生成 = 区域加载+对象池管理
- SpringMVC配置prefix <property name="prefix" value="/WEB-INF/jsp/" />页面跳转时不显示提示信息