コード例 #1
0
 public void UpdateMesh()
 {
     if (this.IsValid)
     {
         this.skeleton.SetColor(this.get_color());
         MeshRendererBuffers.SmartMesh next = this.meshBuffers.GetNext();
         SkeletonRendererInstruction   currentInstructions = this.currentInstructions;
         Spine.Unity.MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, this.skeleton, this.get_material());
         bool updateTriangles = SkeletonRendererInstruction.GeometryNotEqual(currentInstructions, next.instructionUsed);
         this.meshGenerator.Begin();
         if (currentInstructions.hasActiveClipping)
         {
             this.meshGenerator.AddSubmesh(currentInstructions.submeshInstructions.Items[0], updateTriangles);
         }
         else
         {
             this.meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles);
         }
         if (base.get_canvas() != null)
         {
             this.meshGenerator.ScaleVertexData(base.get_canvas().referencePixelsPerUnit);
         }
         if (this.OnPostProcessVertices != null)
         {
             this.OnPostProcessVertices(this.meshGenerator.Buffers);
         }
         Mesh mesh = next.mesh;
         this.meshGenerator.FillVertexData(mesh);
         if (updateTriangles)
         {
             this.meshGenerator.FillTrianglesSingle(mesh);
         }
         this.meshGenerator.FillLateVertexData(mesh);
         base.get_canvasRenderer().SetMesh(mesh);
         next.instructionUsed.Set(currentInstructions);
     }
 }
コード例 #2
0
 public void UpdateMesh()
 {
     if (IsValid)
     {
         skeleton.SetColor(color);
         MeshRendererBuffers.SmartMesh next = meshBuffers.GetNext();
         SkeletonRendererInstruction   skeletonRendererInstruction = currentInstructions;
         MeshGenerator.GenerateSingleSubmeshInstruction(skeletonRendererInstruction, skeleton, material);
         bool flag = SkeletonRendererInstruction.GeometryNotEqual(skeletonRendererInstruction, next.instructionUsed);
         meshGenerator.Begin();
         if (skeletonRendererInstruction.hasActiveClipping)
         {
             meshGenerator.AddSubmesh(skeletonRendererInstruction.submeshInstructions.Items[0], flag);
         }
         else
         {
             meshGenerator.BuildMeshWithArrays(skeletonRendererInstruction, flag);
         }
         if (base.canvas != null)
         {
             meshGenerator.ScaleVertexData(base.canvas.referencePixelsPerUnit);
         }
         if (this.OnPostProcessVertices != null)
         {
             this.OnPostProcessVertices(meshGenerator.Buffers);
         }
         Mesh mesh = next.mesh;
         meshGenerator.FillVertexData(mesh);
         if (flag)
         {
             meshGenerator.FillTrianglesSingle(mesh);
         }
         base.canvasRenderer.SetMesh(mesh);
         next.instructionUsed.Set(skeletonRendererInstruction);
     }
 }
コード例 #3
0
 public virtual void LateUpdate()
 {
     if (this.valid)
     {
         bool generateMeshOverride = this.generateMeshOverride != null;
         if (this.meshRenderer.enabled || generateMeshOverride)
         {
             bool flag2;
             SkeletonRendererInstruction      currentInstructions = this.currentInstructions;
             ExposedList <SubmeshInstruction> submeshInstructions = currentInstructions.submeshInstructions;
             MeshRendererBuffers.SmartMesh    nextMesh            = this.rendererBuffers.GetNextMesh();
             if (this.singleSubmesh)
             {
                 MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, this.skeleton, this.skeletonDataAsset.atlasAssets[0].materials[0]);
                 if (this.customMaterialOverride.Count > 0)
                 {
                     MeshGenerator.TryReplaceMaterials(submeshInstructions, this.customMaterialOverride);
                 }
                 MeshGenerator.Settings settings = new MeshGenerator.Settings {
                     pmaVertexColors   = this.pmaVertexColors,
                     zSpacing          = this.zSpacing,
                     useClipping       = this.useClipping,
                     tintBlack         = this.tintBlack,
                     calculateTangents = this.calculateTangents,
                     addNormals        = this.addNormals
                 };
                 this.meshGenerator.settings = settings;
                 this.meshGenerator.Begin();
                 flag2 = SkeletonRendererInstruction.GeometryNotEqual(currentInstructions, nextMesh.instructionUsed);
                 if (currentInstructions.hasActiveClipping)
                 {
                     this.meshGenerator.AddSubmesh(submeshInstructions.Items[0], flag2);
                 }
                 else
                 {
                     this.meshGenerator.BuildMeshWithArrays(currentInstructions, flag2);
                 }
             }
             else
             {
                 MeshGenerator.GenerateSkeletonRendererInstruction(currentInstructions, this.skeleton, this.customSlotMaterials, this.separatorSlots, generateMeshOverride, this.immutableTriangles);
                 if (this.customMaterialOverride.Count > 0)
                 {
                     MeshGenerator.TryReplaceMaterials(submeshInstructions, this.customMaterialOverride);
                 }
                 if (generateMeshOverride)
                 {
                     this.generateMeshOverride(currentInstructions);
                     if (this.disableRenderingOnOverride)
                     {
                         return;
                     }
                 }
                 flag2 = SkeletonRendererInstruction.GeometryNotEqual(currentInstructions, nextMesh.instructionUsed);
                 MeshGenerator.Settings settings2 = new MeshGenerator.Settings {
                     pmaVertexColors   = this.pmaVertexColors,
                     zSpacing          = this.zSpacing,
                     useClipping       = this.useClipping,
                     tintBlack         = this.tintBlack,
                     calculateTangents = this.calculateTangents,
                     addNormals        = this.addNormals
                 };
                 this.meshGenerator.settings = settings2;
                 this.meshGenerator.Begin();
                 if (currentInstructions.hasActiveClipping)
                 {
                     this.meshGenerator.BuildMesh(currentInstructions, flag2);
                 }
                 else
                 {
                     this.meshGenerator.BuildMeshWithArrays(currentInstructions, flag2);
                 }
             }
             if (this.OnPostProcessVertices != null)
             {
                 this.OnPostProcessVertices(this.meshGenerator.Buffers);
             }
             Mesh mesh = nextMesh.mesh;
             this.meshGenerator.FillVertexData(mesh);
             this.rendererBuffers.UpdateSharedMaterials(submeshInstructions);
             if (flag2)
             {
                 this.meshGenerator.FillTriangles(mesh);
                 this.meshRenderer.sharedMaterials = this.rendererBuffers.GetUpdatedSharedMaterialsArray();
             }
             else if (this.rendererBuffers.MaterialsChangedInLastUpdate())
             {
                 this.meshRenderer.sharedMaterials = this.rendererBuffers.GetUpdatedSharedMaterialsArray();
             }
             this.meshGenerator.FillLateVertexData(mesh);
             this.meshFilter.sharedMesh = mesh;
             nextMesh.instructionUsed.Set(currentInstructions);
         }
     }
 }
コード例 #4
0
        public virtual void LateUpdate()
        {
            if (!valid)
            {
                return;
            }
            bool flag = this.generateMeshOverride != null;

            if (!meshRenderer.enabled && !flag)
            {
                return;
            }
            SkeletonRendererInstruction      skeletonRendererInstruction = currentInstructions;
            ExposedList <SubmeshInstruction> submeshInstructions         = skeletonRendererInstruction.submeshInstructions;

            MeshRendererBuffers.SmartMesh nextMesh = rendererBuffers.GetNextMesh();
            bool flag2;

            if (singleSubmesh)
            {
                MeshGenerator.GenerateSingleSubmeshInstruction(skeletonRendererInstruction, skeleton, skeletonDataAsset.atlasAssets[0].materials[0]);
                if (customMaterialOverride.Count > 0)
                {
                    MeshGenerator.TryReplaceMaterials(submeshInstructions, customMaterialOverride);
                }
                meshGenerator.settings = new MeshGenerator.Settings
                {
                    pmaVertexColors   = pmaVertexColors,
                    zSpacing          = zSpacing,
                    useClipping       = useClipping,
                    tintBlack         = tintBlack,
                    calculateTangents = calculateTangents,
                    addNormals        = addNormals
                };
                meshGenerator.Begin();
                flag2 = SkeletonRendererInstruction.GeometryNotEqual(skeletonRendererInstruction, nextMesh.instructionUsed);
                if (skeletonRendererInstruction.hasActiveClipping)
                {
                    meshGenerator.AddSubmesh(submeshInstructions.Items[0], flag2);
                }
                else
                {
                    meshGenerator.BuildMeshWithArrays(skeletonRendererInstruction, flag2);
                }
            }
            else
            {
                MeshGenerator.GenerateSkeletonRendererInstruction(skeletonRendererInstruction, skeleton, customSlotMaterials, separatorSlots, flag, immutableTriangles);
                if (customMaterialOverride.Count > 0)
                {
                    MeshGenerator.TryReplaceMaterials(submeshInstructions, customMaterialOverride);
                }
                if (flag)
                {
                    this.generateMeshOverride(skeletonRendererInstruction);
                    if (disableRenderingOnOverride)
                    {
                        return;
                    }
                }
                flag2 = SkeletonRendererInstruction.GeometryNotEqual(skeletonRendererInstruction, nextMesh.instructionUsed);
                meshGenerator.settings = new MeshGenerator.Settings
                {
                    pmaVertexColors   = pmaVertexColors,
                    zSpacing          = zSpacing,
                    useClipping       = useClipping,
                    tintBlack         = tintBlack,
                    calculateTangents = calculateTangents,
                    addNormals        = addNormals
                };
                meshGenerator.Begin();
                if (skeletonRendererInstruction.hasActiveClipping)
                {
                    meshGenerator.BuildMesh(skeletonRendererInstruction, flag2);
                }
                else
                {
                    meshGenerator.BuildMeshWithArrays(skeletonRendererInstruction, flag2);
                }
            }
            if (this.OnPostProcessVertices != null)
            {
                this.OnPostProcessVertices(meshGenerator.Buffers);
            }
            Mesh mesh = nextMesh.mesh;

            meshGenerator.FillVertexData(mesh);
            rendererBuffers.UpdateSharedMaterials(submeshInstructions);
            if (flag2)
            {
                meshGenerator.FillTriangles(mesh);
                meshRenderer.sharedMaterials = rendererBuffers.GetUpdatedShaderdMaterialsArray();
            }
            else if (rendererBuffers.MaterialsChangedInLastUpdate())
            {
                meshRenderer.sharedMaterials = rendererBuffers.GetUpdatedShaderdMaterialsArray();
            }
            meshFilter.sharedMesh = mesh;
            nextMesh.instructionUsed.Set(skeletonRendererInstruction);
        }