2023年unity实验报告

上传人:人*** 文档编号:575884910 上传时间:2024-08-18 格式:PDF 页数:16 大小:1.24MB
返回 下载 相关 举报
2023年unity实验报告_第1页
第1页 / 共16页
2023年unity实验报告_第2页
第2页 / 共16页
2023年unity实验报告_第3页
第3页 / 共16页
2023年unity实验报告_第4页
第4页 / 共16页
2023年unity实验报告_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《2023年unity实验报告》由会员分享,可在线阅读,更多相关《2023年unity实验报告(16页珍藏版)》请在金锄头文库上搜索。

1、成绩安徽科技学院unity课程实习报告所在专业 地理信息系统组 长 姓 名 杨明明( )组 内 成 员 刘德旺o孟令康( )任 宏 伟 ( )赵 文 。所在院系 城建与环境学院指导教师 邱 银 国日 期 2 0 23年 1 1月5 日一、实验目的及规定本次实验的总的目的是通过具体的程序的编写与u n ity 3 d 软件相结合, 将所学的知识内化, 即将在课堂上学到的知识集成在一起, 并实现相关功能, 从而锻炼自己的程序编写、 程序调试能力以及对unity 3d的掌握能力。 本次实验的具体规定是使用Unity3 d 软件完毕一个综合的应用系统。二、实验方法本次实验是以window s 操作系统

2、为平台, 通过u n i ty 3 d 软件进行本次实验的项目实现,unity 3d是一个十分优秀的全面整合的专业游戏引擎。通过unity 3 d 软件和编程工具的结合可以轻松创建各种3 D 模型,模拟模型动态以及插入互动内容。三、实验内容、环节及结果1 .实验内容本次实验是通过uni t y 3d软件完毕一个综合的应用系统。 并且本次实验所设计的系统要实现的功能如下:(1) 漫游浏览( 三维 ) ;( 2) 连接数据库( SQL S er v e r 2 0 23);(3) 音视频播放;( 4) 绘制简朴图形;(5) 基本GU I 元素显示;2 .实验环节及结果环节:( 1)场景设计以及构思

3、;(2 )项目实行及代码编写;场景代码相结合;(4 )进行调试。结果:1 ) 基本GUI元素显示:代码如下:#pragma st r i c tvar str: S tring;va r mm:St r ing;f u n ction S t a r t () f u n ction Upd a te () )f u n ctio n OnGUI()oG ULBeginGroup(Rect(Sc r een.width/2 150, Sere e n .he i g ht/2-100,4 0 0,300);GUL L a b e l ( Rec t ( 2 0, 2 0,80,30),“ 菜单

4、: “ );i f(GUI .Button (Rect(100, 4 0,60, 2 0),“自动漫游 ) ) ( Applicati o n. L o adLev e 1 ( 自动漫游 ) ; )oif (GUI.Button(Rect(100, 1 0 ,60, 2 0),“音频播放 ) ) , Ap p lica t i o n.LoadLe v el ( 音频播放 ) ;。 a i f(GUI.Butt o n(R ec t (1 0 0,70,6 0 ,2 0 ),画线 ) ) 8Ap p licat i on. L oa d Level(画 线 ) ; )if(G U I . B

5、u t t o n ( R e c t ( l 00,100,60, 2 0 ) , 视频播放 ) ) Appli c a t i o n .LoadLev e 1 ( 视频播放 ) ;0)G UI.En d G r o u p ( ) ;)2 )绘制简朴图形:Lines Rriangle 返回Rriangle代码如下:public c 1 ass New Be h avi o urS c ript : Mon o Behaviou r ArrayList pX = new ArrayLi s t ();ArrayL i st pY = new Arr a yList ();p u bl i

6、c Materi a 1 m a t;/ / Po i nt3d p t s 3 d = new P o i n t3d();Vect o r3 mousePos = n ew Ve c tor 3 ();en u m Draw Mo d e(N u 1 1, L i n e s, T r iangle, Rectangle) ;Dra w Mo d e d m;boo 1 T r i Close = f alse;。 / / Use this f o r initial i zat i onvoid Start ()(dm = DrawMo d e. Null;0“/ Update is c

7、 a 1 1 e d one e p er framevoid Upda t e ()mo u s e P o s = Inpu t .m o usePos i tion;i f (Input. G etM o useBut t on (0)p X.Add(Input.mous e Po s ition. x );p Y .Ad d ( I nput. mo u se P osit i on. y );)void OnGUI()“ 此处略。)3 )音视频播放:音频:代码如下:using Unity E ngi n e ;usin g System. Col 1 ections;p u b 1

8、ic c lass m u s ic : MonoBeh a v i our / / U s e t his f o r i n it i al i zationov o i d Start () “/ Upda t e is c a 1 led once per f r a mev o id Upd a te ( ) )void OnGUI ()( GU I . Button (new Rect(Scree n .wi d t h /2-100, S c r een.heig h t-30,5 0 ,2 0),“S t art M )“ gam eO bject.au d i o.Play(

9、);-f(GU I .Bu t t o n (ne w R e ct (Screen.wi d th / 240,Sere e n.height-3 0 ,50, 2 0 )JPa use)ogameO b ject.audi o .Paus e ();q f (G UI. Button (new Rect(Screen.wi d th / 2+20,S c reen. h e i ght-30, 50, 2 0 ),“Stop)wgame O b ject.a u dio. S top();00 if (GUI. Butto n (n ew R e c t ( S e r e en.widt

10、 h / 2+80,S c reen.height-3 0 ,50, 2 0 ),R e tur n )eApp 1 ic a t ion. L o a d Leve 1 (1 o ading1);0 )视频:开 关 停 止 暂 停 返 回代码如下:us i ng U n it y Engin e ;us i n g S y stem. Colle c ti o ns;publ i c cl a ss vidi o : MonoBehavio u r pub 1 ic Mo v ieTexture mo v i e t e x ture;。p ubli c boo 1 O N =fal s e

11、 ;0。 / / U s e t h is for i n itializ a t ionov o id S t art () renderer.ma t erial.mainT e x ture=nu 1 1 ;am o vi e texture.loo p =tru e ;gameO b j e c t.audi o . S t o p ();)/ U P dat e i s call e d o n c e per framevo i d Update () ovoid OnGUI() 3 if( G U I . B utton (new R e c t (Sc r een.wi d t

12、 h / 2-4 0 ,Scree n . h eight- 4 0, 40 ,4 0 ), “ 开关 ) ) 。 。o i f (!ON) g mo v ietexture. Play();。 o rendere r .m a teri a Lma i nTexture=movietext u re;。 。 g am e Ob j ect.audio.Pla y ();。 ON=true;。 e Is e 。 0movie t extu r e.Stop(); g am e Obje c t.aud i o.S t op ();oooON=f a 1 se;oooorendere r . m

13、aterial, m a i n Texture=n u 1 1 ;)e i f(GUL B u t t o n(ne w Rect( S c r een. w idt h / 2 , Sc r ee n ,hei g h t-40, 4 0,40), “ 停止 ) ) v i e te x tu r e. S top ();g am e O b j e c t .a udio.StopO;0 )“i f (GUI. But t on (new Rect( S e r e en.widt h /2+4 0 ,Scree n .h e ight-40, 4 0,4 0 ), ” 暂停” ) )

14、nioviet e xt u re. P a u s e ();ogg a m e Obj e c t ,aud i o.Pause();6 )if(G ULButton(n e w R e ct(S c r e e n.wi d th / 2+80, S c re e n.h e i g h t 40,40,40) J返回” ) ) A p pl i ca t io n .LoadLe v e 1 (loadin g );)004) 漫游浏览( 三维):代码如下:us i n g Unity E n gi n e ;u s ing Sy s t em.Collect i o n s ;pub

15、 1 ic c lass w o rkin g : MonoB e h a viou r(float hS 1 ider Value = 1 f ;P u blic GameObjectJ pat h ; 定义一个数组用来存储途径方块p u b lic stati c in t i = 0; 定义一个整型变量用来存储当前程径点序号/ Use this f o r init i a 1 i z a t i o nvoi d St a r t()/ Upd a t e i s c a 1 1 ed o n ce pe r f r amevo i d Update ()(gameOb j ect.

16、t r a n s f orm. L o okA t(p a th i% p a t h.Lengt h . transfbrm);g a meObj e c t . t ransform.Trans 1 at e (Vector3.fo r ward * Time.delt a Time * hSl i de r V a lue);if (Input.GetMouseBut to n Dow n (0)(Ra y ray = Camer a .m a i n.Screen P o intToRay( I npu t . mous e P osit i o n ) ;Ra y c a s t

17、Hit hit = new RaycastHit ();i f (Ph y sics. Raycast(ray, out h i t)(p r i n t( h i t .c o llider. g ameObje c t. n ame);)vo i d OnGU I ()GUI.skin. la b el. fo n t S i z e = 10;GUI.co 1 or = C o lo r .cy a n ;/GULB utton (new Re c t(10,10,80, 3 0 ),“djfkj);h Sli d erVal u e = GUI. HorizontalS 1 id e

18、r(new Re c t( Scree n .wi d th - 2 00, 40,1 00, 3 0 ) , h S 1 iderValue, 0. 0 f, 1 00.0 f ) ;/G U I.contentCol o r = C o 1 or.black;GU I .L ab e 1( n ew Rec t(S cree n .wid t h - 200, 1 5,20 0 , 30), 漫游速度: + hSl i derVa 1 ue.T o S t r in g() + m /s);/ / 空间坐标/GULLab e l(new Rect ( 1 0 , Sc r e e n.he

19、ight - 2 0, 100, 30), X 坐标: + tra n s f orm. p osi t ion.x + mn);/GULLabe 1 (new R e c t ( 1 20, Screen.hei g ht - 2 0 , 1 0 0, 3 0 ), MY 坐标: + t r a n sf o r m.posit i on. y + mu);/ / GUI. Lab e (n e w R e c t (230, S c reen.height 20, 1 0 0, 3 0 ), “Z坐标: + transform.po s ition. z + m) ;。if (G U I Layo u t.Bu t ton( “ 返回” ) ) p pl i c a t i o n.LoadLeve 1 (n 1 o ad i ng”);)四、实验结果以及心得体会从普通用户的角度来说,3 D U n ity功能齐全,容易使用,3 D模型导入比较容易, 做3D项目比较容易。从开发人员的角度来说, 使 用3 D Unit y已有的功能,是很方便, 但是一旦涉及到某些地方要定制化就很难做。由于它不能直接调用操作系统底层功能,因此, 定制化模块的性能会比较差。3Dunity适合做房产演示、产品演示、小型网络游戏。但是不适合做大型网络游戏,和用户定制化规定比较高的项目。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号