本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}