unity实验报告.docx

上传人:b****6 文档编号:15458590 上传时间:2023-07-04 格式:DOCX 页数:15 大小:3.12MB
下载 相关 举报
unity实验报告.docx_第1页
第1页 / 共15页
unity实验报告.docx_第2页
第2页 / 共15页
unity实验报告.docx_第3页
第3页 / 共15页
unity实验报告.docx_第4页
第4页 / 共15页
unity实验报告.docx_第5页
第5页 / 共15页
unity实验报告.docx_第6页
第6页 / 共15页
unity实验报告.docx_第7页
第7页 / 共15页
unity实验报告.docx_第8页
第8页 / 共15页
unity实验报告.docx_第9页
第9页 / 共15页
unity实验报告.docx_第10页
第10页 / 共15页
unity实验报告.docx_第11页
第11页 / 共15页
unity实验报告.docx_第12页
第12页 / 共15页
unity实验报告.docx_第13页
第13页 / 共15页
unity实验报告.docx_第14页
第14页 / 共15页
unity实验报告.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

unity实验报告.docx

《unity实验报告.docx》由会员分享,可在线阅读,更多相关《unity实验报告.docx(15页珍藏版)》请在冰点文库上搜索。

unity实验报告.docx

unity实验报告

成绩

安徽科技学院

unity课程实习报告

所在专业地理信息系统

组长姓名杨明明(2206110124)

组内成员刘德旺(2206110114)

孟令康(2206110116)

任宏伟(2206110117)

赵文(2206110130)

所在院系城建与环境学院

指导教师邱银国

日期2014年11月5日

 

一、实验目的及要求

本次实验的总的目的是通过具体的程序的编写与unity3d软件相结合,将所学的知识内化,即将在课堂上学到的知识集成在一起,并实现相关功能,从而锻炼自己的程序编写、程序调试能力以及对unity3d的掌握能力。

本次实验的具体要求是使用Unity3d软件完成一个综合的应用系统。

二、实验方法

本次实验是以windows操作系统为平台,通过unity3d软件进行本次实验的项目实现,unity3d是一个十分优秀的全面整合的专业游戏引擎。

通过unity3d软件和编程工具的结合可以轻松创建各种3D模型,模拟模型动态以及插入互动内容。

三、实验内容、步骤及结果

1.实验内容

本次实验是通过unity3d软件完成一个综合的应用系统。

并且本次实验所设计的系统要实现的功能如下:

(1)漫游浏览(三维);

(2)连接数据库(SQLServer2008);

(3)音视频播放;

(4)绘制简单图形;

(5)基本GUI元素显示;

2.实验步骤及结果

步骤:

(1)场景设计以及构思;

(2)项目实施及代码编写;

(3)场景代码相结合;

(4)进行调试。

结果:

1)基本GUI元素显示:

代码如下:

#pragmastrict

varstr:

String;

varmm:

String;

functionStart(){

}

functionUpdate(){

}

functionOnGUI(){

GUI.BeginGroup(Rect(Screen.width/2-150,Screen.height/2-100,400,300));

GUI.Label(Rect(20,20,80,30),"菜单:

");

if(GUI.Button(Rect(100,40,60,20),"自动漫游")){

Application.LoadLevel("自动漫游");

}

if(GUI.Button(Rect(100,10,60,20),"音频播放")){

Application.LoadLevel("音频播放");

}

if(GUI.Button(Rect(100,70,60,20),"画线")){

Application.LoadLevel("画线");

}

if(GUI.Button(Rect(100,100,60,20),"视频播放")){

Application.LoadLevel("视频播放");

}

GUI.EndGroup();

}

2)绘制简单图形:

代码如下:

publicclassNewBehaviourScript:

MonoBehaviour{

ArrayListpX=newArrayList();

ArrayListpY=newArrayList();

publicMaterialmat;

//Point3dpts3d=newPoint3d();

Vector3mousePos=newVector3();

enumDrawMode

{

Null,Lines,Triangle,Rectangle

};

DrawModedm;

boolTriClose=false;

//Usethisforinitialization

voidStart()

{

dm=DrawMode.Null;

}

//Updateiscalledonceperframe

voidUpdate()

{

mousePos=Input.mousePosition;

if(Input.GetMouseButton(0))

{

pX.Add(Input.mousePosition.x);

pY.Add(Input.mousePosition.y);

}

}

voidOnGUI()

{

//此处略。

}

3)音视频播放:

音频:

代码如下:

usingUnityEngine;

usingSystem.Collections;

publicclassmusic:

MonoBehaviour{

//Usethisforinitialization

voidStart(){

}

//Updateiscalledonceperframe

voidUpdate(){

}

voidOnGUI(){

if(GUI.Button(newRect(Screen.width/2-100,Screen.height-30,50,20),"Start")){

gameObject.audio.Play();

}

if(GUI.Button(newRect(Screen.width/2-40,Screen.height-30,50,20),"Pause")){

gameObject.audio.Pause();

}

if(GUI.Button(newRect(Screen.width/2+20,Screen.height-30,50,20),"Stop")){

gameObject.audio.Stop();

}

if(GUI.Button(newRect(Screen.width/2+80,Screen.height-30,50,20),"Return")){

Application.LoadLevel("loading");

}

}

}

视频:

代码如下:

usingUnityEngine;

usingSystem.Collections;

publicclassvidio:

MonoBehaviour{

publicMovieTexturemovietexture;

publicboolON=false;

//Usethisforinitialization

voidStart(){

renderer.material.mainTexture=null;

movietexture.loop=true;

gameObject.audio.Stop();

}

//Updateiscalledonceperframe

voidUpdate(){

}

voidOnGUI(){

if(GUI.Button(newRect(Screen.width/2-40,Screen.height-40,40,40),"开关")){

if(!

ON){

movietexture.Play();

renderer.material.mainTexture=movietexture;

gameObject.audio.Play();

ON=true;

}else{

movietexture.Stop();

gameObject.audio.Stop();

ON=false;

renderer.material.mainTexture=null;

}

}

if(GUI.Button(newRect(Screen.width/2,Screen.height-40,40,40),"停止")){

movietexture.Stop();

gameObject.audio.Stop();

}

if(GUI.Button(newRect(Screen.width/2+40,Screen.height-40,40,40),"暂停")){

movietexture.Pause();

gameObject.audio.Pause();

}

if(GUI.Button(newRect(Screen.width/2+80,Screen.height-40,40,40),"返回")){

Application.LoadLevel("loading");

}

}

}

4)漫游浏览(三维):

代码如下:

usingUnityEngine;

usingSystem.Collections;

publicclassworking:

MonoBehaviour

{

floathSliderValue=1f;

publicGameObject[]path;//定义一个数组用来存储路径方块

publicstaticinti=0;//定义一个整型变量用来存储当前路径点序号

//Usethisforinitialization

voidStart()

{

}

//Updateiscalledonceperframe

voidUpdate()

{

gameObject.transform.LookAt(path[i%path.Length].transform);

gameObject.transform.Translate(Vector3.forward*Time.deltaTime*hSliderValue);

if(Input.GetMouseButtonDown(0))

{

Rayray=Camera.main.ScreenPointToRay(Input.mousePosition);

RaycastHithit=newRaycastHit();

if(Physics.Raycast(ray,outhit))

{

print(hit.collider.gameObject.name);

}

}

}

voidOnGUI()

{

GUI.skin.label.fontSize=10;

GUI.color=Color.cyan;

//GUI.Button(newRect(10,10,80,30),"djfkj");

hSliderValue=GUI.HorizontalSlider(newRect(Screen.width-200,40,100,30),hSliderValue,0.0f,100.0f);

//GUI.contentColor=Color.black;

GUI.Label(newRect(Screen.width-200,15,200,30),"漫游速度:

"+hSliderValue.ToString()+"m/s");

//空间坐标

//GUI.Label(newRect(10,Screen.height-20,100,30),"X坐标:

"+transform.position.x+"m");

//GUI.Label(newRect(120,Screen.height-20,100,30),"Y坐标:

"+transform.position.y+"m");

//GUI.Label(newRect(230,Screen.height-20,100,30),"Z坐标:

"+transform.position.z+"m");

if(GUILayout.Button("返回")){

Application.LoadLevel("loading");

}

 

}

}

四、实验结果以及心得体会

从普通用户的角度来说,3D Unity功能齐全,容易使用,3D模型导入比较容易,做3D项目比较容易。

从开发人员的角度来说,使用3D Unity已有的功能,是很方便,但是一旦涉及到某些地方要定制化就很难做。

由于它不能直接调用操作系统底层功能,因此,定制化模块的性能会比较差。

3Dunity适合做房产演示、产品演示、小型网络游戏。

但是不适合做大型网络游戏,和用户定制化要求比较高的项目。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 法律文书 > 起诉状

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2