当前位置: 首页>>代码示例>>C#>>正文


C# Vector2.Set方法代码示例

本文整理汇总了C#中UnityEngine.Vector2.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Set方法的具体用法?C# Vector2.Set怎么用?C# Vector2.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Vector2的用法示例。


在下文中一共展示了Vector2.Set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEdgePosition

 public static Vector2 GetEdgePosition(Socket socket, Vector2 position)
 {
     float width = 0;
     if (socket.Direction == SocketDirection.Output)
     {
         width = BonConfig.SocketSize;
     }
     position.Set(
         socket.X + width,
         socket.Y + (BonConfig.SocketSize/2f));
     return position;
 }
开发者ID:RudraNilBasu,项目名称:BrotherhoodOfNode,代码行数:12,代码来源:Edge.cs

示例2: Draw

        public void Draw()
        {
            if (Input != null && Output != null)
            {
                _tmpStartPos = GetEdgePosition(Output, _tmpStartPos);
                _tmpEndPos = GetEdgePosition(Input, _tmpEndPos);
                _tmpTangent01 = GetTangentPosition(Output, _tmpStartPos);
                _tmpTangent02 = GetTangentPosition(Input, _tmpEndPos);
                DrawEdge(_tmpStartPos, _tmpTangent01, _tmpEndPos, _tmpTangent02, Output.Type);

                Handles.color = Color.black;
                _tmpStartPos.Set(_tmpEndPos.x - 5, _tmpEndPos.y - 5);
                Handles.DrawLine(_tmpEndPos, _tmpStartPos);
                _tmpStartPos.Set(_tmpEndPos.x - 5, _tmpEndPos.y + 5);
                Handles.DrawLine(_tmpEndPos, _tmpStartPos);
            }
        }
开发者ID:RudraNilBasu,项目名称:BrotherhoodOfNode,代码行数:17,代码来源:Edge.cs

示例3: GetRecoilVec

 /// <summary>
 /// Calculates the amount of recoil at a given point in a burst
 /// </summary>
 private Vector2 GetRecoilVec()
 {
     Vector2 recoilVec = new Vector2(0, 0);
     if (this.cpCustomGet != null)
     {
         Vector2 recoilOffsetX = this.cpCustomGet.recoilOffsetX;
         Vector2 recoilOffsetY = this.cpCustomGet.recoilOffsetY;
         if (!(recoilOffsetX.Equals(Vector2.zero) && recoilOffsetY.Equals(Vector2.zero)))
         {
             int currentBurst = Math.Min(this.verbProps.burstShotCount - this.burstShotsLeft, 20);
             recoilVec.Set(UnityEngine.Random.Range(recoilOffsetX.x, recoilOffsetX.y), UnityEngine.Random.Range(recoilOffsetY.x, recoilOffsetY.y));
             recoilVec *= (float)Math.Sqrt((1 - shootingAccuracy) * currentBurst);
         }
     }
     return recoilVec;
 }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:19,代码来源:Verb_ShootCR.cs

示例4: ProjectToNode

 /// <summary>Projects the assigned position to a node relative position.</summary>
 /// <param name="canvasPosition">The position in canvas coordinates.</param>
 /// <returns>The position in node coordinates</returns>
 public Vector2 ProjectToNode(Vector2 canvasPosition)
 {
     canvasPosition.Set(canvasPosition.x - WindowRect.x, canvasPosition.y - WindowRect.y);
     return canvasPosition;
 }
开发者ID:RudraNilBasu,项目名称:BrotherhoodOfNode,代码行数:8,代码来源:Node.cs

示例5: IsTransparentByTextureAlphaWithUv

		/// <summary>
		/// UV値を考慮した、テクスチャのアルファ値に依る透過確認
		/// </summary>
		/// <returns>透過か(true:透過, false:不透明)</returns>
		/// <param name="texture">テクスチャ</param>
		/// <param name="uv1">三角形頂点のUV値</param>
		/// <param name="uv2">三角形頂点のUV値</param>
		/// <param name="uv3">三角形頂点のUV値</param>
		/// <remarks>
		/// 理想ならば全テクセルを確認しなければならないが、
		/// 現在の実装では三角形を構成する各頂点のUV・重心・各辺の中心点の7点のテクセルしか確認していない
		/// </remarks>
		static bool IsTransparentByTextureAlphaWithUv(Texture2D texture, Vector2 uv1, Vector2 uv2, Vector2 uv3)
		{
			bool result = true; //透過
			do {
				//座標系が相違しているので補正
				uv1.Set(uv1.x, 1.0f - uv1.y - (1.0f / texture.height));
				uv2.Set(uv2.x, 1.0f - uv2.y - (1.0f / texture.height));
				uv3.Set(uv3.x, 1.0f - uv3.y - (1.0f / texture.height));
				
				const float c_threshold = 253.0f / 255.0f; //253程度迄は不透明として見逃す

				//頂点直下
				if (texture.GetPixelBilinear(uv1.x, uv1.y).a < c_threshold) {
					break;
				}
				if (texture.GetPixelBilinear(uv2.x, uv2.y).a < c_threshold) {
					break;
				}
				if (texture.GetPixelBilinear(uv3.x, uv3.y).a < c_threshold) {
					break;
				}

				//重心
				Vector2 center = new Vector2((uv1.x + uv2.x + uv3.x) / 3.0f, (uv1.y + uv2.y + uv3.y) / 3.0f);
				if (texture.GetPixelBilinear(center.x, center.y).a < c_threshold) {
					break;
				}

				//辺中央
				Vector2 uv12 = new Vector2((uv1.x + uv2.x) / 2.0f, (uv1.y + uv2.y) / 2.0f);
				if (texture.GetPixelBilinear(uv12.x, uv12.y).a < c_threshold) {
					break;
				}
				Vector2 uv23 = new Vector2((uv2.x + uv3.x) / 2.0f, (uv2.y + uv3.y) / 2.0f);
				if (texture.GetPixelBilinear(uv23.x, uv23.y).a < c_threshold) {
					break;
				}
				Vector2 uv31 = new Vector2((uv3.x + uv1.x) / 2.0f, (uv3.y + uv1.y) / 2.0f);
				if (texture.GetPixelBilinear(uv31.x, uv31.y).a < c_threshold) {
					break;
				}

				//此処迄来たら不透明
				result = false;
			} while(false);
			return result;
		}
开发者ID:leonpardlee,项目名称:mmd-for-unity,代码行数:59,代码来源:PMXConverter.cs

示例6: GetCursorPos

        //-----------------------------------------------------
        public override Vector2 GetCursorPos()
        {
            if(m_cPosTime != Time.time)
            {
            m_cPosTime = Time.time;
            m_cPos.Set(0f, 0f);

            if(Input.touchCount > 0)
            {
                foreach(Touch t in Input.touches)
                {
                    m_cPos.x += t.position.x;
                    m_cPos.y += t.position.y;
                }

                m_cPos /= Input.touches.Length;
                m_cPos.Set( m_cPos.x < 0.0f ? Mathf.Ceil(m_cPos.x-0.5f) : Mathf.Floor(m_cPos.x+0.5f),
                            m_cPos.y < 0.0f ? Mathf.Ceil(m_cPos.y-0.5f) : Mathf.Floor(m_cPos.y+0.5f));

                m_oldCpos.Set(m_cPos.x, m_cPos.y);
                // Note : on n'utilise pas Mathf.Round car en cas de *.5, il retourne le l'entier pair le plus proche
                // au lieu de l'entier supérieur.
            }
            else
                m_cPos.Set(m_oldCpos.x, m_oldCpos.y);
            }
            return m_cPos;
        }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:29,代码来源:TouchInput.cs


注:本文中的UnityEngine.Vector2.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。