ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:1.46MB ,
资源ID:5979822      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5979822.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Unity 3D 计算机游戏设计实验指导书七.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Unity 3D 计算机游戏设计实验指导书七.docx

1、Unity 3D 计算机游戏设计实验指导书七Unity 3D 计算机游戏设计实验指导书(七)三、实验内容及步骤1. 编写代码实现轻量级数据的存储和读取。public class cunchu : MonoBehaviour private string username=; private string passwd=; private string userage=; private string userheight=; private bool showInfo=false; / Use this for initialization void Start () / Update is

2、called once per frame void Update () void OnGUI() GUILayout.BeginHorizontal(box,GUILayout.Width(200); GUILayout.Label(请输入用户名); username=GUILayout.TextField(username,10); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(box); GUILayout.Label(请输入密码); passwd=GUILayout.TextField(passwd,10); GUILayou

3、t.EndHorizontal(); GUILayout.BeginHorizontal(box); GUILayout.Label(请输入年龄); userage=GUILayout.TextField(userage,10); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(box); GUILayout.Label(请输入身高); userheight=GUILayout.TextField(userheight,5); GUILayout.EndHorizontal(); if(GUILayout.Button(提交数据) sh

4、owInfo=true; PlayerPrefs.SetString(username,username); PlayerPrefs.SetString(passwd,passwd); PlayerPrefs.SetInt(userage,int.Parse(userage); PlayerPrefs.SetFloat(userheight,float.Parse(userheight); if(GUILayout.Button(取消查看) showInfo=false; PlayerPrefs.DeleteAll(); if(showInfo) GUILayout.Label(输入的姓名为:

5、+PlayerPrefs.GetString(username,姓名默认值); GUILayout.Label(输入的密码为:+PlayerPrefs.GetString(passwd,密码默认值); GUILayout.Label(输入的年龄为:+PlayerPrefs.GetInt(userage,0).ToString(); GUILayout.Label(输入的身高为:+PlayerPrefs.GetFloat(userheight,0.0f).ToString(); 2. 编写代码实现自定义文件的存储和读取。using UnityEngine;using System.Collect

6、ions;using System.IO;public class file : MonoBehaviour / string TestInfo=hello !; / Use this for initialization void Start () CreateFile(Application.dataPath,nnfile,TestInfo); / Update is called once per frame void Update () void CreateFile(string path,string name,string Info) StreamWriter sw; FileI

7、nfo t=new FileInfo(path+/+name); if(!t.Exists) sw=t.CreateText(); else sw=t.AppendText(); sw.WriteLine(Info); sw.Close(); sw.Dispose(); using UnityEngine;using System.Collections;using System.Collections.Generic;using System.IO;using System;public class file1 : MonoBehaviour / Use this for initializ

8、ation void Start () ArrayList info=LoadFile(Application.dataPath,nnfile); foreach(string str in info) Debug.Log (str); / Update is called once per frame void Update () ArrayList LoadFile(string path,string name) StreamReader str=null; try str=File.OpenText (path+/+name); catch(Exception e) return nu

9、ll; string line; ArrayList arr=new ArrayList(); while(line=str.ReadLine ()!=null) arr.Add (line); str.Close(); str.Dispose (); return arr; 3. 编写代码实现鼠标拖动模型。效果:鼠标拖着物体向右走,可以看到物体移动:源代码:using UnityEngine;using System.Collections;public class moxingyidong : MonoBehaviour void OnMouseDrag() Debug .Log (鼠标拖

10、动模型区域时); transform .position +=Vector3 .right*Time.deltaTime*Input .GetAxis (Mouse X); transform .position +=Vector3 .right*Time.deltaTime*Input .GetAxis (Mouse Y); / Use this for initialization void Start () / Update is called once per frame void Update () 实验7 游戏多媒体三、实验内容及步骤1. 编写代码实现音频的播放、暂停、停止,和音量

11、等控制方法。using UnityEngine;using System.Collections;public class yinpin : MonoBehaviour public AudioSource music; public float musicVolume; / Use this for initialization void Start () musicVolume =0.5F; void OnGUI() if (GUI.Button(new Rect(10,10,100,50),播放音乐) if (!music .isPlaying ) music.Play (); if (

12、GUI.Button (new Rect(10,60,100,50),暂停音乐) if(music.isPlaying ) music.Stop (); / Update is called once per frame void Update () 2. 编写代码实现视频的播放、暂停、停止等控制方法。源代码:using UnityEngine;using System.Collections;public class NewBehaviourScript : MonoBehaviour /电影纹理 public MovieTexture movTexture; / Use this for

13、initialization void Start () renderer.material.mainTexture = movTexture; movTexture.loop = true; / Update is called once per frame void Update () void OnGUI() if(GUILayout.Button (播放/继续) if(!movTexture.isPlaying) movTexture.Play (); if(GUILayout.Button (暂停播放) movTexture.Pause (); if(GUILayout.Button (停止播放) movTexture.Stop ();

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1