原因是因为插件或则是自定义的AndroidManifast.xml文件覆盖修改了了Unity原来配置主题选项。
在Unity5.5以上的版本中,只需要将AndroidManifast.xml的application标签加上Unity默认主题:
android:theme="@style/UnityThemeSelector"
今天想用四元数实现转很多圈,就是这样的:
transform.rotation = Quaternion.Lerp(transform.rotation,Quaternion.Euler (0, 0, 360*3+45),Time.deltaTime);
好吧,可能是四元数只能表示0-360度吧,并没有转很多圈,就连一圈也没转到,那应该就是:
Debug.Log (Quaternion.Euler (380, 560, 360).eulerAngles); //(20,200,0)
就是你新建一个脚本后,然后打开,VS完全不认识它,你以前写的类在这里都是不能用的。而它也不能被其他类所使用。
猜测:新建脚本后,Unity没有来得及做处理,没有编译到程序集中,所以它是一个独立的个体。
解决办法:打开项目文件,找到脚本文件,复制到外面,再在Unity中将该脚本文件删除,将复制的脚本拉(导入)进来。
在Unity中设置vs2017作为打开脚本的编辑器,打开脚本。
看到vs运行播放那里有没有附加到Unity,如果没有:
点击 "工具/获取工具和功能"
把 "使用Unity的游戏开发" 勾选 并修改
在vs运行处上出现附加到Unity,点击后在需要的地方设置断点,在Unity运行游戏,运行到这断点出就会跳转到vs这边来。
using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; [AddComponentMenu("UI/Effects/Gradient")] public class Gradient : BaseMeshEffect { public Color32 topColor = Color.white; public Color32 bottomColor = Color.black; public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) return; List<UIVertex> list = new List<UIVertex>(); vh.GetUIVertexStream(list); int listCount = list.Count; float bY = list[0].position.y; float tY = list[0].position.y; for (int i = 0; i < listCount; i++) { if (list[i].position.y > tY) { tY = list[i].position.y; } else if (list[i].position.y < bY) { bY = list[i].position.y; } } float h = tY - bY; UIVertex v = new UIVertex(); for (int j = 0;j < vh.currentVertCount; j++) { vh.PopulateUIVertex(ref v, j); v.color = Color32.Lerp(bottomColor, topColor, (v.position.y - bY) / h); vh.SetUIVertex(v,j); } } }
GetUIVertexStream()是获取到网格三角形中的所有顶点,因为三角形会有相交的,所以这里获取的顶点是有重复的。
using UnityEngine; using System.Collections; using UnityEngine.UI; public class CameraScale : MonoBehaviour { void Start() { int ManualWidth = 960; int ManualHeight = 640; int manualHeight; if (System.Convert.ToSingle(Screen.height) / Screen.width > System.Convert.ToSingle(ManualHeight) / ManualWidth) manualHeight = Mathf.RoundToInt(System.Convert.ToSingle(ManualWidth) / Screen.width * Screen.height); else manualHeight = ManualHeight; Camera camera = GetComponent<Camera>(); float scale = System.Convert.ToSingle(manualHeight / 640f); camera.fieldOfView *= scale; } }
这个是C#的新特性,在unity2017中,需要更改PlayerSeting的.Net框架版本
然后使用如下:
async void Start () { Debug.Log("Start"); await Task.Delay(5000); Debug.Log("Continue"); }
原来Debug自身就有控制全区是否输出的开关了。
Debug.logger.logEnabled = false;//弃用了 Debug.unityLogger.logEnabled = false;
unityLogger为获取到默认的输出日志工具
using UnityEngine; public class A : MonoBehaviour { }
using UnityEngine; public class FindA : MonoBehaviour { void Start () { A a = (A)GameObject.FindObjectOfType(typeof(A)); Debug.Log(a.gameObject.name); int num = GameObject.FindObjectsOfType<A>().Length; Debug.Log(num); } }
GameObject可以省略掉,这个FindObjectsOfType()可以通过组件的脚本类型,来查找到当前运行的所有此类型的实例,可以用这个方法来监控单例管理类在游戏中只有一个实例。