UNITY3D学习笔记5
来源:互联网 发布:大司马淘宝店 编辑:程序博客网 时间:2024/06/06 04:35
using UnityEngine;using System.Collections;public class TestD4 : MonoBehaviour {GameObject objCube;GameObject objShere;bool isCubeRoate,isShereRoate;// Use this for initializationvoid Start () {//objCube = GameObject.Find("Cube");objCube = GameObject.FindWithTag("MyTag");objShere = GameObject.Find("Object/Sphere");}// Update is called once per framevoid Update () {if(isCubeRoate){if(objCube){objCube.transform.Rotate(0.0f,Time.deltaTime*200,0.0f);}}if(isShereRoate){if(objShere){objShere.transform.Rotate(0.0f,Time.deltaTime*200,0.0f);}}}void OnGUI(){if(GUILayout.Button("cube rotate",GUILayout.Height(50))){if(!isCubeRoate){isCubeRoate = true;}else{isCubeRoate = false;}}if(GUILayout.Button("sphere rotate",GUILayout.Height(50))){if(!isShereRoate){isShereRoate = true;}else{isShereRoate = false;}}if(GUILayout.Button("destroy",GUILayout.Height(50))){Destroy(objCube);Destroy(objShere);}}}
using UnityEngine;using System.Collections;public class TestD5 : MonoBehaviour {GameObject obj;// Use this for initializationvoid Start () {obj = GameObject.Find("Sphere");}// Update is called once per framevoid Update () {}void OnGUI(){if(GUILayout.Button("start copy",GUILayout.Height(50))){GameObject clone = Instantiate(obj,obj.transform.position,obj.transform.rotation) as GameObject;Destroy(clone,5);}}}
using UnityEngine;using System.Collections;public class TestD6 : MonoBehaviour {GameObject objCube,objCylinder;int speed = 150;// Use this for initializationvoid Start () {objCube = GameObject.Find("Cube");objCylinder = GameObject.Find("Cylinder");}// Update is called once per framevoid Update () {objCube.transform.RotateAround(objCylinder.transform.position,Vector3.up,Time.deltaTime*speed);}void OnGUI(){GUILayout.Label("cube rotate dgree:"+objCube.transform.rotation);GUILayout.Label("cube position:"+objCube.transform.position);}}
using UnityEngine;using System.Collections;public class TestD7 : MonoBehaviour {GameObject obj;float scaleX = 1.0f;float scaleY = 1.0f;float scaleZ = 1.0f;// Use this for initializationvoid Start () {obj = GameObject.Find("Cube2");}// Update is called once per framevoid Update () {}void OnGUI(){GUILayout.Label("scale X");scaleX = GUILayout.HorizontalSlider(scaleX,1.0f,2.0f,GUILayout.Width(100));GUILayout.Label("scale Y");scaleY = GUILayout.HorizontalSlider(scaleY,1.0f,2.0f,GUILayout.Width(100));GUILayout.Label("scale Z");scaleZ = GUILayout.HorizontalSlider(scaleZ,1.0f,2.0f,GUILayout.Width(100));obj.transform.localScale = new Vector3(scaleX,scaleY,scaleZ);}}
using UnityEngine;using System.Collections;public class TestD8 : MonoBehaviour {// Use this for initialization//void Start () { }// Update is called once per framevoid Update () {}IEnumerator Start(){/*Debug.Log ("Time.time:"+Time.time);yield return new WaitForSeconds(2);Debug.Log ("Time.time:"+Time.time);*/return Test ();}IEnumerator Test(){Debug.Log ("Time.time:"+Time.time);yield return new WaitForSeconds(2);Debug.Log ("Time.time:"+Time.time);}void OnGUI(){GUILayout.Label("Now Game Time:Time.time:"+Time.time);GUILayout.Label("previous frame time:Time.deltaTime:"+Time.deltaTime);GUILayout.Label("fixed increment time:Time.fixedTime:"+Time.fixedTime);GUILayout.Label("previous time:Time.fixedDeltaTime:"+Time.fixedDeltaTime);}}
0 0
- UNITY3D学习笔记5
- 【Unity3d】学习笔记(5)
- unity3d基础学习笔记5:常用函数
- unity3d深入学习笔记5:内存释放
- Unity3d学习笔记
- 【学习笔记】插件,Unity3D
- unity3d学习笔记1
- unity3D学习笔记
- Unity3D学习笔记
- unity3D 学习笔记
- Unity3d学习笔记
- unity3D学习笔记1
- unity3D学习笔记2
- Unity3D学习笔记总结
- Unity3D学习笔记
- Unity3D学习笔记
- Unity3D学习笔记【01】
- Unity3D初探学习笔记
- SPOJ GONE G-One Numbers(数位dp)
- 自动寻路算法
- EF中Expression<Func<T,bool>>动态查询怎么写啊
- 【FFmpeg】Windows下FFmpeg调试
- 【3C认证】安防产品3C认证
- UNITY3D学习笔记5
- 最大连续子列和
- iOS 实现百度LBS定位
- [Android新手区] android里面EditTex多行输入及输入置顶问题
- 工作情况
- mysql的jdbc大量数据操作记录
- 武汉学员,我们和传智播客boss在一起
- Jump Game II
- gzip: stdin: not in gzip format tar: Child returned status 1