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


C# VectorLine.Resize方法代码示例

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


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

示例1: SetupOutLine

 void SetupOutLine(VectorLine outline, List<Vector2> list)
 {
     int startIndex = outline.points3.Count;
     outline.Resize(startIndex + (list.Count-1)*2);
     for(int i = 0, j=startIndex; i < list.Count-1; i++, j=j+2){
         outline.points3[j] = DrawHelper.Vector2To3(list[i]);
         outline.points3[j+1] = DrawHelper.Vector2To3(list[i+1]);
     }
 }
开发者ID:duanpeijian,项目名称:unity-drawline,代码行数:9,代码来源:WallFill.cs

示例2: MakeTextInLine

	public static void MakeTextInLine (VectorLine line, string text, Vector2 startPos, float size, float charSpacing, float lineSpacing, bool uppercaseOnly) {
		if (line.continuousLine) {
			LogError ("Vector: MakeTextInLine can only be used with a discrete line");
			return;
		}
		Vector2 scaleVector = new Vector2(size, size);
		int idx = 0;
		int pointsLength = 0;
		
		while (true) {
			pointsLength = GetPointsLength (line);
			idx = 0;
			float charPos = 0.0f;
			float linePos = 0.0f;
			int charNum = 0;
			bool addChar = false;
			Vector2[] useArray = VectorChar.data[0];

			for (int i = 0; i < text.Length; i++) {
				charNum = System.Convert.ToInt32(text[i]);
				addChar = false;
				if (charNum < 0 || charNum > VectorChar.numberOfCharacters) {
					LogError ("Vector.MakeTextInLine: Character " + charNum + " out of range");
					return;
				}
				// Newline
				else if (charNum == 10) {
					linePos -= lineSpacing;
					charPos = 0.0f;
				}
				// Space
				else if (charNum == 32) {
					charPos += charSpacing;
				}
				// Character
				else {
					if (uppercaseOnly && charNum >= 97 && charNum <= 122) {
						charNum -= 32;
					}
					useArray = VectorChar.data[charNum];
					addChar = useArray != null;
				}
				if (addChar) {
					// See if it would exceed array length...if so, keep going so we can add up the total needed
					if (idx + useArray.Length > pointsLength) {
						idx += useArray.Length;
					}
					else {
						if (line.points2 != null) {
							for (int j = 0; j < useArray.Length; j++) {
								line.points2[idx] = useArray[j] + new Vector2(charPos, linePos);
								line.points2[idx] = Vector2.Scale(line.points2[idx], scaleVector);
								line.points2[idx++] += startPos;
							}
						}
						else {
							for (int j = 0; j < useArray.Length; j++) {
								line.points3[idx] = (Vector3)useArray[j] + new Vector3(charPos, linePos, 0.0f);
								line.points3[idx] = Vector2.Scale(line.points3[idx], scaleVector);
								line.points3[idx++] += (Vector3)startPos;
							}
						}
					}
					charPos += charSpacing;
				}
			}
			if (idx > pointsLength) {
				System.Array.Resize(ref line.points3, idx);
				line.Resize(idx);
			}
			else {
				break;
			}
		}
		// Zero out any unused space in the array, in case there was any previous data
		if (idx < pointsLength) {
			ZeroPointsInLine (line, idx);
		}
	}
开发者ID:AlexanderUrbano,项目名称:shapewars,代码行数:79,代码来源:Vector.cs

示例3: MakeTextInLine

    public static void MakeTextInLine(VectorLine line, string text, Vector3 startPos, float size, float charSpacing, float lineSpacing, bool uppercaseOnly)
    {
        if (line.continuousLine) {
            LogError ("Vector: MakeTextInLine can only be used with a discrete line");
            return;
        }
        int pointsLength = GetPointsLength (line);
        int charPointsLength = 0;

        // Get total number of points needed for all characters in the string
        for (int i = 0; i < text.Length; i++) {
            int charNum = System.Convert.ToInt32(text[i]);
            if (charNum == 32 || charNum == 10) continue;
            if (VectorChar.data[charNum] == null) {
                LogError ("Vector.MakeTextInLine: no data found for character '" + text[i] + "'");
                return;
            }
            if (charNum < 0 || charNum > VectorChar.numberOfCharacters) {
                LogError ("Vector.MakeTextInLine: Character '" + text[i] + "' is not valid");
                return;
            }
            if (uppercaseOnly && charNum >= 97 && charNum <= 122) {
                charNum -= 32;
            }
            charPointsLength += VectorChar.data[charNum].Length;
        }
        if (charPointsLength > pointsLength) {
            line.Resize (charPointsLength);
        }
        else if (charPointsLength < pointsLength) {
            ZeroPointsInLine (line, charPointsLength);
        }

        float charPos = 0.0f;
        float linePos = 0.0f;
        int idx = 0;
        var scaleVector = new Vector2(size, size);
        var useVector2 = line.points3 == null;

        for (int i = 0; i < text.Length; i++) {
            int charNum = System.Convert.ToInt32(text[i]);
            // Newline
            if (charNum == 10) {
                linePos -= lineSpacing;
                charPos = 0.0f;
            }
            // Space
            else if (charNum == 32) {
                charPos += charSpacing;
            }
            // Character
            else {
                if (uppercaseOnly && charNum >= 97 && charNum <= 122) {
                    charNum -= 32;
                }
                int end = VectorChar.data[charNum].Length;
                if (useVector2) {
                    for (int j = 0; j < end; j++) {
                        line.points2[idx++] = Vector2.Scale(VectorChar.data[charNum][j] + new Vector2(charPos, linePos), scaleVector) + (Vector2)startPos;
                    }
                }
                else {
                    for (int j = 0; j < end; j++) {
                        line.points3[idx++] = Vector3.Scale((Vector3)VectorChar.data[charNum][j] + new Vector3(charPos, linePos, 0.0f), scaleVector) + startPos;
                    }
                }
                charPos += charSpacing;
            }
        }
    }
开发者ID:ericjxl2013,项目名称:MDIEdit,代码行数:70,代码来源:Vector.cs

示例4: MakeWireframeInLine

    public static void MakeWireframeInLine(VectorLine line, Mesh mesh)
    {
        if (line.continuous) {
            LogError ("Vector: MakeWireframeInLine only works with a discrete line");
            return;
        }
        if (line.points2 != null) {
            LogError ("Vector: MakeWireframeInLine only works with Vector3 points");
            return;
        }
        if (mesh == null) {
            LogError ("Vector: MakeWireframeInLine can't use a null mesh");
            return;
        }
        var meshTris = mesh.triangles;
        var meshVertices = mesh.vertices;
        var pairs = new Dictionary<Vector3Pair, bool>();
        var linePoints = new List<Vector3>();

        for (int i = 0; i < meshTris.Length; i += 3) {
            CheckPairPoints (pairs, meshVertices[meshTris[i]],   meshVertices[meshTris[i+1]], linePoints);
            CheckPairPoints (pairs, meshVertices[meshTris[i+1]], meshVertices[meshTris[i+2]], linePoints);
            CheckPairPoints (pairs, meshVertices[meshTris[i+2]], meshVertices[meshTris[i]],   linePoints);
        }

        if (linePoints.Count > line.points3.Length) {
            System.Array.Resize (ref line.points3, linePoints.Count);
            line.Resize (linePoints.Count);
        }
        else if (linePoints.Count < line.points3.Length) {
            ZeroPointsInLine (line, linePoints.Count);
        }
        System.Array.Copy (linePoints.ToArray(), line.points3, linePoints.Count);
    }
开发者ID:dayglo,项目名称:StormTest,代码行数:34,代码来源:Vector.cs


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