Unity日常积累

SetVerticesDirty

#unity/日常积累 Graphic.SetVerticesDirty public void SetVerticesDirty (); 描述 将顶点标记为“脏”。 SetVerticesDirty被调用的情况 我们回过头来看一看何处会修改SetVerticesDirty: 设置脏标记,当调用了SetVerticesDirty则会修改该值并且添加到Canvas的重建列表当中。 调用该函数的地方……

协奏

UIVertex

#unity/日常积累 UIVertex struct in UnityEngine 描述 Canvas 用于管理顶点的 Vertex 类。 静态变量 simpleVert 简单 UIVertex,具有适用于 UI 系统的合理设置。 变量 color 顶点颜色。 normal 法线。 position 顶点位置。 tangent 切线。 uv0 网格的第一个纹理坐标集。默认情况下由 UI 元素使用。 uv1 网格的第二个纹理坐标集(如果存在)。 uv2 网格的第三个纹理坐标集(如果存……

协奏

Unity——Mathf

#unity/日常积累 相同 Atan 和 Atan2 都是求反正切函数 如:有两个点 point(x1,y1), 和 point(x2,y2),那么这两个点形成的斜率的角度计算方法分别是: 1 2 float angle = Atan((y2-y1) / (x2-x1)); float angle = Atan2( y2-y1, x2-x1 ); 区别 1:参数的填写方式不同。 1 2 public static float Atan2 (float y, float x); public static float Atan (float f); 2:Atan2 的优点在于 如果 x2-x1等于0 依然可以计算……

协奏

WaitUntil

#unity/日常积累 对于WaitUnitl,用在 yield return new WaitUntil 表达式上,协程可以控制运行的时间,对于WaitUntil更是一个有效的挂起命令 用法如下: 1 2 3 4 5 6 7 int i,j; IEnumerator CloseDoor() { yield return new WaitUntil(() => i==j);//Lambda表达式 Debug.Log(1); } 这里必须 i 和 j 相等时,才能打印出 1 . 而WaitUnitl里面的……

协奏

worldPositionStays

#unity/日常积累 SetParent的第二个参数worldPositionStays,为true的时候,会保持child的世界坐标、旋转和缩放,但是localPosition、localRotation以及localScale会因此发生改变; 为false的时候,child的世……

协奏

Camera

#unity/日常积累 Camera.WorldToScreenPoint public Vector3 WorldToScreenPoint (Vector3 position); public Vector3 WorldToScreenPoint (Vector3 position, Camera.MonoOrStereoscopicEye eye); 参数 eye 可选参数,可用于指定要使用的眼睛变换。默认值为 Mono。 描述 将 position 从世界空间变换为屏幕空间。 屏幕空间以像素定义。屏幕的左下角为 (0,0),右上角 为 (pixelWidth,pixelHeight)。z 位置为与摄像机的距离,采用世界……

协奏

Mathf

#unity/日常积累 Mathf.FloorToInt public static int FloorToInt (float f); 描述 返回小于或等于 f 的最大整数。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Example() { Debug.Log(Mathf.FloorToInt(10.0F)); // Prints 10 Debug.Log(Mathf.FloorToInt(10.2F)); // Prints 10 Debug.Log(Mathf.FloorToInt(10.7F)); // Prints 10 Debug.Log(Mathf.FloorToInt(-10.0F)); // Prints -10 Debug.Log(Mathf.FloorToInt(-10.2F)); // Prints -11 Debug.Log(Mathf.FloorToInt(-10.7F)); // Prints -11 } }……

协奏

MathF

#unity/日常积累 C#中的MathF.Pow()方法用于计算增加到另一个数字的幂的数字。 语法 以下是语法- 1 public static float Pow (float val1, float val2); 上面的val1是升为幂的浮点数。val2参数是幂或指数。 示例 现在让我们看一个实现MathF.Pow()方法的示例- 1 2 3 4 5 6 7 8 using System; public class Demo { public static void Main(){ float val1……

协奏

MathF

#unity/日常积累 C#中的MathF.Sqrt()方法与示例 在C#编程语言中,MathF.Sqrt()方法是用来计算一个数的平方根的方法。在本篇文章中,我们将对这个方法进行介绍,并且给出一些使用示例。 MathF.Sqrt()方法的语法 MathF.Sqrt()方法是MathF类……

协奏

Renderer

#unity/日常积累 Renderer class in UnityEngine / 继承自:Component 描述 所有渲染器的常规功能。 渲染器是使对象显示在屏幕上的工具。使用该类可以访问任何对象、网格或粒子系统的渲染器。 可以禁用渲染器以使对象不可见(请参阅 enabled),也可以通过渲染器 访问和修改材质(请参阅 material)。……

协奏