随笔分类 - Unity3D学习笔记
Unity3D
摘要:1 using UnityEngine; 2 using UnityEditor; 3 using System.Collections; 4 5 public class ExportOgv 6 { 7 [MenuItem("Assets/ExportOgg")] 8 ...
阅读全文
摘要:在Unity3D中,有什么好的方法去创建一个单例游戏管理类,可以像一个全局类的静态变量一样到处访问?在Unity中有什么接口吗?我是否要把这个脚本添加到一个物体上呢?这个类可以仅仅放在文件夹里不用添加到场景里吗?通常来说视情况而定,常用的两种单例类。(1)组件式的添加在物体上。(2)不从MonoBe...
阅读全文
摘要:public Vector3[] poss = new Vector3[] { new Vector3(1f, 2f, 3f), new Vector3(12f, 2f, 1f) };如上,在unity3D使用的时候有时候需要使用到数组,如上所示的数组定义和实例化在C#中都没有问题,但是在unity...
阅读全文
摘要:IOS:Application.dataPath :Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/DataApplication.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/RawApplication.persistentDataPath :Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/DocumentsApplication.temporaryCac
阅读全文
摘要:GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(Screen.width / 1024.0f, Screen.height / 768.0f, 1.0f)); /////自适应分辨率,已1024*768为标准
阅读全文
摘要:bool IsAnimationPlaying(GameObject objWithAnimation,string animationName) { return objWithAnimation.animation.IsPlaying(animationName)&&objWithAnimation.animation[animationName].normalizedTime<1.0f; }判断某个动画是否播放完毕。 IEnumerator WaitForAnimationPlayOver(GameObject objWithAnimation,...
阅读全文
摘要:首先新建一个场景,场景中有两台相机。其中camera负责渲染三维物体,Main Camera负责渲染GUI。因为camera只是负责渲染,所以移除camera上的其它组件,只保留Camera组件。场景中的三维物体cube,给它添加一个自己的Layer,并且设置为该Layer。OK!现在开始设置camera,要让camera只渲染cube这一个物体。所以需要设置Camera上的Culling Mask,将它设置为我们刚才为cube添加的层,这样相机camera就只渲染我们设定的这一层。然后将Main Camera的Culling Mask设置为Nothing,因为它只需要做为GUI的显示,不需要
阅读全文
摘要:有的时候我们希望相机可以慢慢的转动去看向一个目标物体,官方的API里有个方法是LookAt,但是LookAt是直接看过去,少了一个旋转的过程。 void CameraRotateToLookAt(Transform target,float rotateSpeed) { //取得目标物体相对于相机的法向量 Vector3 normalize = Vector3.Cross(myCamera.transform.forward,target.transform.position-myCamera.transform.position); fl...
阅读全文
浙公网安备 33010602011771号