Exemplo n.º 1
0
        public static bool GenerateAtlas(Vector2[] sizes, int padding, int atlasSize, List <Rect> results)
        {
            if (sizes == null)
            {
                throw new ArgumentException("sizes array can not be null");
            }
            if (results == null)
            {
                throw new ArgumentException("results list cannot be null");
            }
            if (padding < 0)
            {
                throw new ArgumentException("padding can not be negative");
            }
            if (atlasSize <= 0)
            {
                throw new ArgumentException("atlas size must be positive");
            }

            results.Clear();
            if (sizes.Length == 0)
            {
                return(true);
            }

            NoAllocHelpers.EnsureListElemCount(results, sizes.Length);
            GenerateAtlasImpl(sizes, padding, atlasSize, NoAllocHelpers.ExtractArrayFromListT(results));
            return(results.Count != 0);
        }
Exemplo n.º 2
0
 public void GetBoneWeights(List <BoneWeight> boneWeights)
 {
     if (boneWeights == null)
     {
         throw new ArgumentNullException("The result boneWeights list cannot be null.", "boneWeights");
     }
     NoAllocHelpers.EnsureListElemCount <BoneWeight>(boneWeights, this.GetBoneWeightCount());
     this.GetBoneWeightsNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT <BoneWeight>(boneWeights));
 }
Exemplo n.º 3
0
 public void GetBindposes(List <Matrix4x4> bindposes)
 {
     if (bindposes == null)
     {
         throw new ArgumentNullException("The result bindposes list cannot be null.", "bindposes");
     }
     NoAllocHelpers.EnsureListElemCount <Matrix4x4>(bindposes, this.GetBindposeCount());
     this.GetBindposesNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT <Matrix4x4>(bindposes));
 }
Exemplo n.º 4
0
        public void GetSharedMaterials(List <Material> m)
        {
            bool flag = m == null;

            if (flag)
            {
                throw new ArgumentNullException("The result material list cannot be null.", "m");
            }
            NoAllocHelpers.EnsureListElemCount <Material>(m, this.GetMaterialCount());
            this.CopySharedMaterialArray(NoAllocHelpers.ExtractArrayFromListT <Material>(m));
        }
Exemplo n.º 5
0
 public void GetIndices(List <int> indices, int submesh, [UnityEngine.Internal.DefaultValue("true")] bool applyBaseVertex)
 {
     if (indices == null)
     {
         throw new ArgumentNullException("The result indices list cannot be null.", "indices");
     }
     if (submesh < 0 || submesh >= this.subMeshCount)
     {
         throw new IndexOutOfRangeException("Specified sub mesh is out of range. Must be greater or equal to 0 and less than subMeshCount.");
     }
     NoAllocHelpers.EnsureListElemCount <int>(indices, (int)this.GetIndexCount(submesh));
     this.GetIndicesNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT <int>(indices), submesh, applyBaseVertex);
 }
Exemplo n.º 6
0
 private void GetListForChannel <T>(List <T> buffer, int capacity, Mesh.InternalShaderChannel channel, int dim, Mesh.InternalVertexChannelType channelType)
 {
     buffer.Clear();
     if (!this.canAccess)
     {
         this.PrintErrorCantAccessChannel(channel);
     }
     else if (this.HasChannel(channel))
     {
         NoAllocHelpers.EnsureListElemCount <T>(buffer, capacity);
         this.GetArrayFromChannelImpl(channel, channelType, dim, NoAllocHelpers.ExtractArrayFromList(buffer));
     }
 }
Exemplo n.º 7
0
        public void GetBoneWeights(List <BoneWeight> boneWeights)
        {
            if (boneWeights == null)
            {
                throw new ArgumentNullException("The result boneWeights list cannot be null.", "boneWeights");
            }

            if (HasBoneWeights())
            {
                NoAllocHelpers.EnsureListElemCount(boneWeights, vertexCount);
            }
            GetBoneWeightsNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT(boneWeights));
        }
Exemplo n.º 8
0
        public void GetTriangles(List <int> triangles, int submesh, [DefaultValue("true")] bool applyBaseVertex)
        {
            if (triangles == null)
            {
                throw new ArgumentNullException("The result triangles list cannot be null.", "triangles");
            }

            if (submesh < 0 || submesh >= subMeshCount)
            {
                throw new IndexOutOfRangeException("Specified sub mesh is out of range. Must be greater or equal to 0 and less than subMeshCount.");
            }

            NoAllocHelpers.EnsureListElemCount(triangles, 3 * (int)GetTrianglesCountImpl(submesh));
            GetTrianglesNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT(triangles), submesh, applyBaseVertex);
        }
Exemplo n.º 9
0
        private void ExtractMatrixArray(int name, List <Matrix4x4> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            values.Clear();
            int matrixArrayCountImpl = this.GetMatrixArrayCountImpl(name);

            if (matrixArrayCountImpl > 0)
            {
                NoAllocHelpers.EnsureListElemCount <Matrix4x4>(values, matrixArrayCountImpl);
                this.ExtractMatrixArrayImpl(name, (Matrix4x4[])NoAllocHelpers.ExtractArrayFromList(values));
            }
        }
Exemplo n.º 10
0
        private void ExtractFloatArray(int name, List <float> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            values.Clear();
            int floatArrayCountImpl = this.GetFloatArrayCountImpl(name);

            if (floatArrayCountImpl > 0)
            {
                NoAllocHelpers.EnsureListElemCount <float>(values, floatArrayCountImpl);
                this.ExtractFloatArrayImpl(name, (float[])NoAllocHelpers.ExtractArrayFromList(values));
            }
        }
Exemplo n.º 11
0
        private static void ExtractGlobalMatrixArray(int name, List <Matrix4x4> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            values.Clear();
            int globalMatrixArrayCountImpl = Shader.GetGlobalMatrixArrayCountImpl(name);

            if (globalMatrixArrayCountImpl > 0)
            {
                NoAllocHelpers.EnsureListElemCount <Matrix4x4>(values, globalMatrixArrayCountImpl);
                Shader.ExtractGlobalMatrixArrayImpl(name, (Matrix4x4[])NoAllocHelpers.ExtractArrayFromList(values));
            }
        }
Exemplo n.º 12
0
        public void GetIndices(List <ushort> indices, int submesh, bool applyBaseVertex = true)
        {
            if (indices == null)
            {
                throw new ArgumentNullException("The result indices list cannot be null.", nameof(indices));
            }

            if (submesh < 0 || submesh >= subMeshCount)
            {
                throw new IndexOutOfRangeException("Specified sub mesh is out of range. Must be greater or equal to 0 and less than subMeshCount.");
            }

            NoAllocHelpers.EnsureListElemCount(indices, (int)GetIndexCount(submesh));
            GetIndicesNonAllocImpl16(NoAllocHelpers.ExtractArrayFromListT(indices), submesh, applyBaseVertex);
        }
Exemplo n.º 13
0
        private static void ExtractGlobalVectorArray(int name, List <Vector4> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            values.Clear();

            int count = GetGlobalVectorArrayCountImpl(name);

            if (count > 0)
            {
                NoAllocHelpers.EnsureListElemCount(values, count);
                ExtractGlobalVectorArrayImpl(name, (Vector4[])NoAllocHelpers.ExtractArrayFromList(values));
            }
        }
Exemplo n.º 14
0
        public void GetMaterials(List <Material> m)
        {
            bool flag = m == null;

            if (flag)
            {
                throw new ArgumentNullException("The result material list cannot be null.", "m");
            }
            bool flag2 = this.IsPersistent();

            if (flag2)
            {
                throw new InvalidOperationException("Not allowed to access Renderer.materials on prefab object. Use Renderer.sharedMaterials instead");
            }
            NoAllocHelpers.EnsureListElemCount <Material>(m, this.GetMaterialCount());
            this.CopyMaterialArray(NoAllocHelpers.ExtractArrayFromListT <Material>(m));
        }
Exemplo n.º 15
0
        private void ExtractVectorArray(int name, List <Vector4> values)
        {
            bool flag = values == null;

            if (flag)
            {
                throw new ArgumentNullException("values");
            }
            values.Clear();
            int  vectorArrayCountImpl = this.GetVectorArrayCountImpl(name);
            bool flag2 = vectorArrayCountImpl > 0;

            if (flag2)
            {
                NoAllocHelpers.EnsureListElemCount <Vector4>(values, vectorArrayCountImpl);
                this.ExtractVectorArrayImpl(name, (Vector4[])NoAllocHelpers.ExtractArrayFromList(values));
            }
        }
Exemplo n.º 16
0
        private static void ExtractGlobalVectorArray(int name, List <Vector4> values)
        {
            bool flag = values == null;

            if (flag)
            {
                throw new ArgumentNullException("values");
            }
            values.Clear();
            int  globalVectorArrayCountImpl = Shader.GetGlobalVectorArrayCountImpl(name);
            bool flag2 = globalVectorArrayCountImpl > 0;

            if (flag2)
            {
                NoAllocHelpers.EnsureListElemCount <Vector4>(values, globalVectorArrayCountImpl);
                Shader.ExtractGlobalVectorArrayImpl(name, (Vector4[])NoAllocHelpers.ExtractArrayFromList(values));
            }
        }
Exemplo n.º 17
0
        private void GetListForChannel <T>(List <T> buffer, int capacity, VertexAttribute channel, int dim, InternalVertexChannelType channelType)
        {
            buffer.Clear();

            if (!canAccess)
            {
                PrintErrorCantAccessChannel(channel);
                return;
            }

            if (!HasChannel(channel))
            {
                return;
            }

            NoAllocHelpers.EnsureListElemCount(buffer, capacity);
            GetArrayFromChannelImpl(channel, channelType, dim, NoAllocHelpers.ExtractArrayFromList(buffer));
        }
Exemplo n.º 18
0
        public static bool GenerateAtlas(Vector2[] sizes, int padding, int atlasSize, List <Rect> results)
        {
            bool flag = sizes == null;

            if (flag)
            {
                throw new ArgumentException("sizes array can not be null");
            }
            bool flag2 = results == null;

            if (flag2)
            {
                throw new ArgumentException("results list cannot be null");
            }
            bool flag3 = padding < 0;

            if (flag3)
            {
                throw new ArgumentException("padding can not be negative");
            }
            bool flag4 = atlasSize <= 0;

            if (flag4)
            {
                throw new ArgumentException("atlas size must be positive");
            }
            results.Clear();
            bool flag5 = sizes.Length == 0;
            bool result;

            if (flag5)
            {
                result = true;
            }
            else
            {
                NoAllocHelpers.EnsureListElemCount <Rect>(results, sizes.Length);
                Texture2D.GenerateAtlasImpl(sizes, padding, atlasSize, NoAllocHelpers.ExtractArrayFromListT <Rect>(results));
                result = (results.Count != 0);
            }
            return(result);
        }