public void Initialize(bool overwrite) { if ((this.skeletonAnimations.Count == 0) || overwrite) { this.Clear(); MeshGenerator.Settings meshGeneratorSettings = this.meshGeneratorSettings; Transform parent = base.transform; foreach (SkeletonDataAsset asset in this.skeletonDataAssets) { SkeletonAnimation item = SkeletonAnimation.NewSkeletonAnimationGameObject(asset); item.transform.SetParent(parent, false); item.SetMeshSettings(meshGeneratorSettings); item.initialFlipX = this.initialFlipX; item.initialFlipY = this.initialFlipY; Skeleton skeleton = item.skeleton; skeleton.FlipX = this.initialFlipX; skeleton.FlipY = this.initialFlipY; item.Initialize(false); this.skeletonAnimations.Add(item); } Dictionary <string, Spine.Animation> animationNameTable = this.animationNameTable; Dictionary <Spine.Animation, SkeletonAnimation> animationSkeletonTable = this.animationSkeletonTable; foreach (SkeletonAnimation animation2 in this.skeletonAnimations) { foreach (Spine.Animation animation3 in animation2.Skeleton.Data.Animations) { animationNameTable[animation3.Name] = animation3; animationSkeletonTable[animation3] = animation2; } } this.SetActiveSkeleton(this.skeletonAnimations[0]); this.SetAnimation(this.initialAnimation, this.initialLoop); } }
public void SetMeshSettings(MeshGenerator.Settings settings) { this.calculateTangents = settings.calculateTangents; this.immutableTriangles = settings.immutableTriangles; this.pmaVertexColors = settings.pmaVertexColors; this.tintBlack = settings.tintBlack; this.useClipping = settings.useClipping; this.zSpacing = settings.zSpacing; this.meshGenerator.settings = settings; }
static int SetMeshSettings(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Spine.Unity.SkeletonRenderer obj = (Spine.Unity.SkeletonRenderer)ToLua.CheckObject <Spine.Unity.SkeletonRenderer>(L, 1); Spine.Unity.MeshGenerator.Settings arg0 = StackTraits <Spine.Unity.MeshGenerator.Settings> .Check(L, 2); obj.SetMeshSettings(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
void HandleRender(SkeletonRendererInstruction instruction) { int rendererCount = partsRenderers.Count; if (rendererCount <= 0) { return; } if (copyPropertyBlock) { mainMeshRenderer.GetPropertyBlock(copiedBlock); } var settings = new MeshGenerator.Settings { addNormals = skeletonRenderer.addNormals, calculateTangents = skeletonRenderer.calculateTangents, immutableTriangles = false, // parts cannot do immutable triangles. pmaVertexColors = skeletonRenderer.pmaVertexColors, tintBlack = skeletonRenderer.tintBlack, useClipping = true, zSpacing = skeletonRenderer.zSpacing }; var submeshInstructions = instruction.submeshInstructions; var submeshInstructionsItems = submeshInstructions.Items; int lastSubmeshInstruction = submeshInstructions.Count - 1; int rendererIndex = 0; var currentRenderer = partsRenderers[rendererIndex]; for (int si = 0, start = 0; si <= lastSubmeshInstruction; si++) { if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction) { // Apply properties var meshGenerator = currentRenderer.MeshGenerator; meshGenerator.settings = settings; if (copyPropertyBlock) { currentRenderer.SetPropertyBlock(copiedBlock); } // Render currentRenderer.RenderParts(instruction.submeshInstructions, start, si + 1); start = si + 1; rendererIndex++; if (rendererIndex < rendererCount) { currentRenderer = partsRenderers[rendererIndex]; } else { // Not enough renderers. Skip the rest of the instructions. break; } } } // Clear extra renderers if they exist. for (; rendererIndex < rendererCount; rendererIndex++) { partsRenderers[rendererIndex].ClearMesh(); } }
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); } } }