/// <summary> /// Clears the previously generated mesh and resets the skeleton's pose.</summary> public virtual void ClearState() { meshFilter.sharedMesh = null; currentInstructions.Clear(); if (skeleton != null) { skeleton.SetToSetupPose(); } }
/// <summary> /// Clears the previously generated mesh and resets the skeleton's pose.</summary> public virtual void ClearState() { var meshFilter = GetComponent <MeshFilter>(); if (meshFilter != null) { meshFilter.sharedMesh = null; } currentInstructions.Clear(); if (skeleton != null) { skeleton.SetToSetupPose(); } }
void LazyIntialize() { if (buffers == null) { buffers = new MeshRendererBuffers(); buffers.Initialize(); if (meshGenerator != null) { return; } meshGenerator = new MeshGenerator(); meshFilter = GetComponent <MeshFilter>(); meshRenderer = GetComponent <MeshRenderer>(); currentInstructions.Clear(); } }
public void Clear() { mesh.Clear(); instructionUsed.Clear(); }
public static void GenerateSkeletonRendererInstruction(SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Dictionary <Slot, Material> customSlotMaterials, List <Slot> separatorSlots, bool generateMeshOverride, bool immutableTriangles = false) { ExposedList <Slot> drawOrder = skeleton.drawOrder; int count = drawOrder.Count; instructionOutput.Clear(); ExposedList <SubmeshInstruction> submeshInstructions = instructionOutput.submeshInstructions; instructionOutput.attachments.Resize(count); Attachment[] items = instructionOutput.attachments.Items; int num = 0; bool hasActiveClipping = false; SubmeshInstruction submeshInstruction = default(SubmeshInstruction); submeshInstruction.skeleton = skeleton; submeshInstruction.preActiveClippingSlotSource = -1; SubmeshInstruction submeshInstruction2 = submeshInstruction; bool flag = customSlotMaterials != null && customSlotMaterials.Count > 0; int num2 = (separatorSlots != null) ? separatorSlots.Count : 0; bool flag2 = num2 > 0; int num3 = -1; int preActiveClippingSlotSource = -1; SlotData slotData = null; int num4 = 0; Slot[] items2 = drawOrder.Items; for (int i = 0; i < count; i++) { Slot slot = items2[i]; Attachment attachment = items[i] = slot.attachment; int num5 = 0; int num6 = 0; object obj = null; bool flag3 = false; RegionAttachment regionAttachment = attachment as RegionAttachment; if (regionAttachment != null) { obj = regionAttachment.RendererObject; num5 = 4; num6 = 6; } else { MeshAttachment meshAttachment = attachment as MeshAttachment; if (meshAttachment != null) { obj = meshAttachment.RendererObject; num5 = meshAttachment.worldVerticesLength >> 1; num6 = meshAttachment.triangles.Length; } else { ClippingAttachment clippingAttachment = attachment as ClippingAttachment; if (clippingAttachment != null) { slotData = clippingAttachment.endSlot; num3 = i; submeshInstruction2.hasClipping = true; hasActiveClipping = true; } flag3 = true; } } if (slotData != null && slot.data == slotData) { slotData = null; num3 = -1; } if (flag2) { submeshInstruction2.forceSeparate = false; for (int j = 0; j < num2; j++) { if (object.ReferenceEquals(slot, separatorSlots[j])) { submeshInstruction2.forceSeparate = true; break; } } } if (flag3) { if (submeshInstruction2.forceSeparate && generateMeshOverride) { submeshInstruction2.endSlot = i; submeshInstruction2.preActiveClippingSlotSource = preActiveClippingSlotSource; submeshInstructions.Resize(num4 + 1); submeshInstructions.Items[num4] = submeshInstruction2; num4++; submeshInstruction2.startSlot = i; preActiveClippingSlotSource = num3; submeshInstruction2.rawTriangleCount = 0; submeshInstruction2.rawVertexCount = 0; submeshInstruction2.rawFirstVertexIndex = num; submeshInstruction2.hasClipping = (num3 >= 0); } continue; } Material value; if (flag) { if (!customSlotMaterials.TryGetValue(slot, out value)) { value = (Material)((AtlasRegion)obj).page.rendererObject; } } else { value = (Material)((AtlasRegion)obj).page.rendererObject; } if (submeshInstruction2.forceSeparate || (submeshInstruction2.rawVertexCount > 0 && !object.ReferenceEquals(submeshInstruction2.material, value))) { submeshInstruction2.endSlot = i; submeshInstruction2.preActiveClippingSlotSource = preActiveClippingSlotSource; submeshInstructions.Resize(num4 + 1); submeshInstructions.Items[num4] = submeshInstruction2; num4++; submeshInstruction2.startSlot = i; preActiveClippingSlotSource = num3; submeshInstruction2.rawTriangleCount = 0; submeshInstruction2.rawVertexCount = 0; submeshInstruction2.rawFirstVertexIndex = num; submeshInstruction2.hasClipping = (num3 >= 0); } submeshInstruction2.material = value; submeshInstruction2.rawTriangleCount += num6; submeshInstruction2.rawVertexCount += num5; submeshInstruction2.rawFirstVertexIndex = num; num += num5; } if (submeshInstruction2.rawVertexCount > 0) { submeshInstruction2.endSlot = count; submeshInstruction2.preActiveClippingSlotSource = preActiveClippingSlotSource; submeshInstruction2.forceSeparate = false; submeshInstructions.Resize(num4 + 1); submeshInstructions.Items[num4] = submeshInstruction2; } instructionOutput.hasActiveClipping = hasActiveClipping; instructionOutput.rawVertexCount = num; instructionOutput.immutableTriangles = immutableTriangles; }
public static void GenerateSingleSubmeshInstruction(SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Material material) { ExposedList <Slot> drawOrder = skeleton.drawOrder; int count = drawOrder.Count; instructionOutput.Clear(); ExposedList <SubmeshInstruction> submeshInstructions = instructionOutput.submeshInstructions; submeshInstructions.Resize(1); instructionOutput.attachments.Resize(count); Attachment[] items = instructionOutput.attachments.Items; int num = 0; SubmeshInstruction submeshInstruction = default(SubmeshInstruction); submeshInstruction.skeleton = skeleton; submeshInstruction.preActiveClippingSlotSource = -1; submeshInstruction.startSlot = 0; submeshInstruction.rawFirstVertexIndex = 0; submeshInstruction.material = material; submeshInstruction.forceSeparate = false; submeshInstruction.endSlot = count; SubmeshInstruction submeshInstruction2 = submeshInstruction; bool hasActiveClipping = false; Slot[] items2 = drawOrder.Items; for (int i = 0; i < count; i++) { Slot slot = items2[i]; Attachment attachment = items[i] = slot.attachment; RegionAttachment regionAttachment = attachment as RegionAttachment; int num2; int num3; if (regionAttachment != null) { num2 = 4; num3 = 6; } else { MeshAttachment meshAttachment = attachment as MeshAttachment; if (meshAttachment != null) { num2 = meshAttachment.worldVerticesLength >> 1; num3 = meshAttachment.triangles.Length; } else { ClippingAttachment clippingAttachment = attachment as ClippingAttachment; if (clippingAttachment != null) { submeshInstruction2.hasClipping = true; hasActiveClipping = true; } num2 = 0; num3 = 0; } } submeshInstruction2.rawTriangleCount += num3; submeshInstruction2.rawVertexCount += num2; num += num2; } instructionOutput.hasActiveClipping = hasActiveClipping; instructionOutput.rawVertexCount = num; submeshInstructions.Items[0] = submeshInstruction2; }