本文整理汇总了C#中BetterList.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# BetterList.ToArray方法的具体用法?C# BetterList.ToArray怎么用?C# BetterList.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BetterList
的用法示例。
在下文中一共展示了BetterList.ToArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set
/// <summary>
/// Set the draw call's geometry.
/// </summary>
public void Set(BetterList<Vector3> verts, BetterList<Vector3> norms, BetterList<Vector4> tans, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
int count = verts.size;
// Safety check to ensure we get valid values
if (count > 0 && (count == uvs.size && count == cols.size) && (count % 4) == 0)
{
// Cache all components
if (mFilter == null) mFilter = gameObject.GetComponent<MeshFilter>();
if (mFilter == null) mFilter = gameObject.AddComponent<MeshFilter>();
if (mRen == null) mRen = gameObject.GetComponent<MeshRenderer>();
if (mRen == null)
{
mRen = gameObject.AddComponent<MeshRenderer>();
#if UNITY_EDITOR
mRen.enabled = isActive;
#endif
UpdateMaterials();
}
else if (mMat != null && mMat.mainTexture != mSharedMat.mainTexture)
{
UpdateMaterials();
}
if (verts.size < 65000)
{
int indexCount = (count >> 1) * 3;
bool rebuildIndices = (mIndices == null || mIndices.Length != indexCount);
// Populate the index buffer
if (rebuildIndices)
{
// It takes 6 indices to draw a quad of 4 vertices
mIndices = new int[indexCount];
int index = 0;
for (int i = 0; i < count; i += 4)
{
mIndices[index++] = i;
mIndices[index++] = i + 1;
mIndices[index++] = i + 2;
mIndices[index++] = i + 2;
mIndices[index++] = i + 3;
mIndices[index++] = i;
}
}
// Set the mesh values
Mesh mesh = GetMesh(ref rebuildIndices, verts.size);
mesh.vertices = verts.ToArray();
if (norms != null) mesh.normals = norms.ToArray();
if (tans != null) mesh.tangents = tans.ToArray();
mesh.uv = uvs.ToArray();
mesh.colors32 = cols.ToArray();
if (rebuildIndices) mesh.triangles = mIndices;
mesh.RecalculateBounds();
mFilter.mesh = mesh;
}
else
{
if (mFilter.mesh != null) mFilter.mesh.Clear();
Debug.LogError("Too many vertices on one panel: " + verts.size);
}
}
else
{
if (mFilter.mesh != null) mFilter.mesh.Clear();
Debug.LogError("UIWidgets must fill the buffer with 4 vertices per quad. Found " + count);
}
}
示例2: Set
/// <summary>
/// Set the draw call's geometry.
/// </summary>
public void Set(BetterList<Vector3> verts, BetterList<Vector3> norms, BetterList<Vector4> tans, BetterList<Vector2> uvs, BetterList<Color> cols)
{
int count = verts.size;
// Safety check to ensure we get valid values
if (count > 0 && (count == uvs.size && count == cols.size) && (count % 4) == 0)
{
int index = 0;
// It takes 6 indices to draw a quad of 4 vertices
int indexCount = (count >> 1) * 3;
// Populate the index buffer
if (mIndices == null || mIndices.Length != indexCount)
{
mIndices = new int[indexCount];
for (int i = 0; i < count; i += 4)
{
mIndices[index++] = i;
mIndices[index++] = i + 1;
mIndices[index++] = i + 2;
mIndices[index++] = i + 2;
mIndices[index++] = i + 3;
mIndices[index++] = i;
}
}
// Cache all components
if (mFilter == null) mFilter = gameObject.GetComponent<MeshFilter>();
if (mFilter == null) mFilter = gameObject.AddComponent<MeshFilter>();
if (mRen == null) mRen = gameObject.GetComponent<MeshRenderer>();
if (mRen == null)
{
mRen = gameObject.AddComponent<MeshRenderer>();
UpdateMaterials();
}
if (verts.size < 65000)
{
if (mMesh == null)
{
mMesh = new Mesh();
mMesh.name = "UIDrawCall for " + mSharedMat.name;
}
else
{
mMesh.Clear();
}
// Set the mesh values
mMesh.vertices = verts.ToArray();
if (norms != null) mMesh.normals = norms.ToArray();
if (tans != null) mMesh.tangents = tans.ToArray();
mMesh.uv = uvs.ToArray();
mMesh.colors = cols.ToArray();
mMesh.triangles = mIndices;
mMesh.RecalculateBounds();
mFilter.mesh = mMesh;
}
else
{
if (mMesh != null) mMesh.Clear();
Debug.LogError("Too many vertices on one panel: " + verts.size);
}
}
else
{
if (mMesh != null) mMesh.Clear();
Debug.LogError("UIWidgets must fill the buffer with 4 vertices per quad. Found " + count);
}
}
示例3: CreateFont
//.........这里部分代码省略.........
for (int i = 0, y = 0; y < glyph.bitmap.rows; ++y)
{
for (int x = 0; x < glyph.bitmap.width; ++x)
{
white.a = buffer[i++];
colors[x + glyph.bitmap.width * (glyph.bitmap.rows - y - 1)] = white;
}
}
// Save the texture
texture.SetPixels32(colors);
texture.Apply();
textures.Add(texture);
entries.Add(ch);
// Record the metrics
BMGlyph bmg = font.GetGlyph(ch, true);
bmg.offsetX = (glyph.metrics.horiBearingX >> 6);
bmg.offsetY = -(glyph.metrics.horiBearingY >> 6);
bmg.advance = (glyph.metrics.horiAdvance >> 6);
bmg.channel = 15;
// Save kerning information
for (int b = 0; b < characters.Length; ++b)
{
uint ch2 = characters[b];
if (ch2 == ch) continue;
FT_Vector vec;
if (FT_Get_Kerning(face, ch2, ch, 0, out vec) != 0) continue;
int offset = (vec.x / 64);
if (offset != 0) bmg.SetKerning((int)ch2, offset);
}
}
}
// Create a packed texture with all the characters
tex = new Texture2D(32, 32, TextureFormat.ARGB32, false);
Rect[] rects = tex.PackTextures(textures.ToArray(), 1);
// Make the RGB channel pure white
Color32[] cols = tex.GetPixels32();
for (int i = 0, imax = cols.Length; i < imax; ++i)
{
Color32 c = cols[i];
c.r = 255;
c.g = 255;
c.b = 255;
cols[i] = c;
}
tex.SetPixels32(cols);
tex.Apply();
font.texWidth = tex.width;
font.texHeight = tex.height;
int min = int.MaxValue;
int max = int.MinValue;
// Other glyphs are visible and need to be added
for (int i = 0; i < entries.size; ++i)
{
// Destroy the texture now that it's a part of an atlas
UnityEngine.Object.DestroyImmediate(textures[i]);
textures[i] = null;
Rect rect = rects[i];
// Set the texture coordinates
BMGlyph glyph = font.GetGlyph(entries[i], true);
glyph.x = Mathf.RoundToInt(rect.x * font.texWidth);
glyph.y = Mathf.RoundToInt(rect.y * font.texHeight);
glyph.width = Mathf.RoundToInt(rect.width * font.texWidth);
glyph.height = Mathf.RoundToInt(rect.height * font.texHeight);
// Flip the Y since the UV coordinate system is different
glyph.y = font.texHeight - glyph.y - glyph.height;
max = Mathf.Max(max, -glyph.offsetY);
min = Mathf.Min(min, -glyph.offsetY - glyph.height);
}
int baseline = size + min;
baseline += ((max - min - size) >> 1);
// Offset all glyphs so that they are not using the baseline
for (int i = 0; i < entries.size; ++i)
{
BMGlyph glyph = font.GetGlyph(entries[i], true);
glyph.offsetY += baseline;
}
}
if (face != IntPtr.Zero) FT_Done_Face(face);
#if !UNITY_3_5
if (lib != IntPtr.Zero) FT_Done_FreeType(lib);
#endif
return (tex != null);
}
示例4: Set
/// <summary>
/// Set the draw call's geometry.
/// </summary>
public void Set (BetterList<Vector3> verts, BetterList<Vector3> norms, BetterList<Vector4> tans, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
int count = verts.size;
// Safety check to ensure we get valid values
if (count > 0 && (count == uvs.size && count == cols.size) && (count % 4) == 0)
{
// Cache all components
if (mFilter == null) mFilter = gameObject.GetComponent<MeshFilter>();
if (mFilter == null) mFilter = gameObject.AddComponent<MeshFilter>();
if (verts.size < 65000)
{
// Populate the index buffer
int indexCount = (count >> 1) * 3;
bool setIndices = (mIndices == null || mIndices.Length != indexCount);
// Create the mesh
if (mMesh == null)
{
mMesh = new Mesh();
mMesh.hideFlags = HideFlags.DontSave;
mMesh.name = (mMaterial != null) ? mMaterial.name : "Mesh";
#if !UNITY_3_5
mMesh.MarkDynamic();
#endif
setIndices = true;
}
// If the buffer length doesn't match, we need to trim all buffers
bool trim = (uvs.buffer.Length != verts.buffer.Length) ||
(cols.buffer.Length != verts.buffer.Length) ||
(norms != null && norms.buffer.Length != verts.buffer.Length) ||
(tans != null && tans.buffer.Length != verts.buffer.Length);
if (trim || verts.buffer.Length > 65000)
{
if (trim || mMesh.vertexCount != verts.size)
{
mMesh.Clear();
setIndices = true;
}
mMesh.vertices = verts.ToArray();
mMesh.uv = uvs.ToArray();
mMesh.colors32 = cols.ToArray();
if (norms != null) mMesh.normals = norms.ToArray();
if (tans != null) mMesh.tangents = tans.ToArray();
}
else
{
if (mMesh.vertexCount != verts.buffer.Length)
{
mMesh.Clear();
setIndices = true;
}
mMesh.vertices = verts.buffer;
mMesh.uv = uvs.buffer;
mMesh.colors32 = cols.buffer;
if (norms != null) mMesh.normals = norms.buffer;
if (tans != null) mMesh.tangents = tans.buffer;
}
if (setIndices)
{
mIndices = GenerateCachedIndexBuffer(count, indexCount);
mMesh.triangles = mIndices;
}
if (!alwaysOnScreen) mMesh.RecalculateBounds();
mFilter.mesh = mMesh;
}
else
{
if (mFilter.mesh != null) mFilter.mesh.Clear();
Debug.LogError("Too many vertices on one panel: " + verts.size);
}
if (mRenderer == null) mRenderer = gameObject.GetComponent<MeshRenderer>();
if (mRenderer == null)
{
mRenderer = gameObject.AddComponent<MeshRenderer>();
#if UNITY_EDITOR
mRenderer.enabled = isActive;
#endif
}
UpdateMaterials();
}
else
{
if (mFilter.mesh != null) mFilter.mesh.Clear();
Debug.LogError("UIWidgets must fill the buffer with 4 vertices per quad. Found " + count);
}
//.........这里部分代码省略.........
示例5: Set
public void Set(BetterList<Vector3> verts, BetterList<Vector3> norms, BetterList<Vector4> tans, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
int size = verts.size;
if (((size > 0) && (size == uvs.size)) && ((size == cols.size) && ((size % 4) == 0)))
{
if (this.mFilter == null)
{
this.mFilter = base.gameObject.GetComponent<MeshFilter>();
}
if (this.mFilter == null)
{
this.mFilter = base.gameObject.AddComponent<MeshFilter>();
}
if (verts.size < 0xfde8)
{
int indexCount = (size >> 1) * 3;
bool flag = (this.mIndices == null) || (this.mIndices.Length != indexCount);
if (this.mMesh == null)
{
this.mMesh = new Mesh();
this.mMesh.hideFlags = HideFlags.DontSave;
this.mMesh.name = (this.mMaterial == null) ? "Mesh" : this.mMaterial.name;
this.mMesh.MarkDynamic();
flag = true;
}
bool flag2 = (((uvs.buffer.Length != verts.buffer.Length) || (cols.buffer.Length != verts.buffer.Length)) || ((norms != null) && (norms.buffer.Length != verts.buffer.Length))) || ((tans != null) && (tans.buffer.Length != verts.buffer.Length));
if (flag2 || (verts.buffer.Length > 0xfde8))
{
if (flag2 || (this.mMesh.vertexCount != verts.size))
{
this.mMesh.Clear();
flag = true;
}
this.mMesh.vertices = verts.ToArray();
this.mMesh.uv = uvs.ToArray();
this.mMesh.colors32 = cols.ToArray();
if (norms != null)
{
this.mMesh.normals = norms.ToArray();
}
if (tans != null)
{
this.mMesh.tangents = tans.ToArray();
}
}
else
{
if (this.mMesh.vertexCount != verts.buffer.Length)
{
this.mMesh.Clear();
flag = true;
}
this.mMesh.vertices = verts.buffer;
this.mMesh.uv = uvs.buffer;
this.mMesh.colors32 = cols.buffer;
if (norms != null)
{
this.mMesh.normals = norms.buffer;
}
if (tans != null)
{
this.mMesh.tangents = tans.buffer;
}
}
if (flag)
{
this.mIndices = this.GenerateCachedIndexBuffer(size, indexCount);
this.mMesh.triangles = this.mIndices;
}
if (this.mClipping != Clipping.None)
{
this.mMesh.RecalculateBounds();
}
this.mFilter.mesh = this.mMesh;
}
else
{
if (this.mFilter.mesh != null)
{
this.mFilter.mesh.Clear();
}
Debug.LogError("Too many vertices on one panel: " + verts.size);
}
if (this.mRenderer == null)
{
this.mRenderer = base.gameObject.GetComponent<MeshRenderer>();
}
if (this.mRenderer == null)
{
this.mRenderer = base.gameObject.AddComponent<MeshRenderer>();
}
this.UpdateMaterials();
}
else
{
if (this.mFilter.mesh != null)
{
this.mFilter.mesh.Clear();
}
Debug.LogError("UIWidgets must fill the buffer with 4 vertices per quad. Found " + size);
//.........这里部分代码省略.........