void UpdatePivot(SpriteFrame sprite, int selectPivot) { m_pivotIndex = selectPivot; sprite.CreateQuad(); switch (selectPivot) { case 1: sprite.pivot = new Vector2(0.5f, 0.5f); break; case 2: sprite.pivot = new Vector2(0.5f, 1f); break; case 3: sprite.pivot = new Vector2(0f, 1f); break; case 4: sprite.pivot = new Vector2(1f, 1f); break; case 5: sprite.pivot = new Vector2(0f, 0.5f); break; case 6: sprite.pivot = new Vector2(1f, 0.5f); break; case 7: sprite.pivot = new Vector2(0.5f, 0f); break; case 8: sprite.pivot = new Vector2(0f, 0f); break; case 9: sprite.pivot = new Vector2(1f, 0f); break; } }
/// <summary> /// Changes the sprite frame. /// </summary> /// <param name="sf">Will replace SpriteFrame</param> /// <param name="texture">new Texture.</param> /// <param name="mat">Mat.</param> public void ChangeSpriteFrame(SpriteFrame sf, Texture texture, Material mat = null, bool useMaterialBlock = true) { if (!sf || !texture) { return; } //new textureframe TextureFrame frame = new TextureFrame(); frame.atlasTextureSize = new Vector2(texture.width, texture.height); frame.material = mat == null ? sf.material : mat; frame.rect.x = 0f; frame.rect.y = 0f; frame.rect.width = texture.width; frame.rect.height = texture.height; frame.frameSize = new Rect(0, 0, texture.width, texture.height); frame.isRotated = false; if (!sf.isCreatedMesh) { sf.CreateQuad(); } sf.frame = frame; if (mat) { sf.material = mat; } //change texture if (useMaterialBlock) { sf.meshRenderer.GetPropertyBlock(materialPropertyBlock); m_MatBlock.SetTexture("_MainTex", texture); sf.meshRenderer.SetPropertyBlock(materialPropertyBlock); } else { sf.material.mainTexture = texture; } }
static void CreateSpriteFrame() { if (Selection.activeObject is TextureFrames) { TextureFrames tfs = AssetDatabase.LoadAssetAtPath <TextureFrames>(AssetDatabase.GetAssetPath(Selection.activeObject)); if (tfs && tfs.frames != null && tfs.frames.Length > 0) { GameObject go = new GameObject(); SpriteFrame sf = go.AddComponent <SpriteFrame>(); sf.CreateQuad(); sf.textureFrames = tfs; foreach (Material mat in tfs.materials) { if (mat.name.LastIndexOf("_UI_Mat") == -1) { sf.material = tfs.materials[0]; break; } } } } }
protected internal void UpdateCurrentDisplay() { m_SpriteFrame = null; m_SpriteMesh = null; m_SpriteRenderer = null; m_Armature = null; m_Image = null; m_UIFrame = null; m_UIMesh = null; m_CurrentDisplay = null; if (armature == null) { return; } if (__displayIndex > -1 && transform.childCount > 0) { Transform skin = (armature.skins == null || armature.skins.Length <= 1) ?transform :transform.Find(armature.skinName); if (skin && skin.childCount > 0) { Transform child = skin.GetChild(__displayIndex); m_CurrentDisplay = child.gameObject; if (armature.isUGUI) { m_UIFrame = child.GetComponent <UIFrame>(); if (!m_UIFrame) { m_UIMesh = child.GetComponent <UIMesh>(); if (!m_UIMesh) { m_Image = child.GetComponent <Image>(); if (!m_Image) { m_Armature = child.GetComponent <Armature>(); } } } } else { m_SpriteFrame = child.GetComponent <SpriteFrame>(); if (!m_SpriteFrame) { m_SpriteMesh = child.GetComponent <SpriteMesh>(); if (!m_SpriteMesh) { m_SpriteRenderer = child.GetComponent <SpriteRenderer>(); if (!m_SpriteRenderer) { m_Armature = child.GetComponent <Armature>(); } } } UpdateZOrder(); } } } else if (armature.skins != null && armature.skins.Length > 1) { for (int i = 0; i < transform.childCount; ++i) { transform.GetChild(i).gameObject.SetActive(false); } } }
public override void OnInspectorGUI() { SpriteFrame sprite = target as SpriteFrame; serializedObject.Update(); EditorGUILayout.BeginVertical(); EditorGUILayout.PropertyField(serializedObject.FindProperty("textureFrames"), true); if (sprite.textureFrames != null && sprite.textureFrames.frames.Length > 0) { //显示frameName列表 string[] list = new string[sprite.textureFrames.frames.Length]; for (int i = 0; i < sprite.textureFrames.frames.Length; ++i) { list[i] = sprite.textureFrames.frames[i].name; } int selectIndex = EditorGUILayout.Popup("Frame", m_frameIndex, list); if (selectIndex != m_frameIndex) { m_frameIndex = selectIndex; sprite.CreateQuad(); sprite.frameName = sprite.textureFrames.frames[m_frameIndex].name; UpdatePivot(sprite, m_pivotIndex); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_skew"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_uvOffset"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_pivot"), true); if (sprite.textureFrames != null && !string.IsNullOrEmpty(sprite.frameName)) { // "None","CENTER","TOP","TOP_LEFT","TOP_RIGHT", // "LEFT","RIGHT","BOTTOM","BOTTOM_LEFT","BOTTOM_RIGHT" int selectPivot = EditorGUILayout.Popup("Auto Pivot", m_pivotIndex, posList); if (selectPivot != m_pivotIndex) { UpdatePivot(sprite, selectPivot); sprite.frameName = sprite.frameName; } } EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Color"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_brightness"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PreMultiplyAlpha"), true); selectedOption = EditorGUILayout.Popup("Sorting Layer", selectedOption, sortingLayerNames); if (sortingLayerNames[selectedOption] != sprite.sortingLayerName) { Undo.RecordObject(sprite, "Sorting Layer"); sprite.sortingLayerName = sortingLayerNames[selectedOption]; EditorUtility.SetDirty(sprite); if (!Application.isPlaying && !string.IsNullOrEmpty(sprite.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } int newSortingLayerOrder = EditorGUILayout.IntField("Order in Layer", sprite.sortingOrder); if (newSortingLayerOrder != sprite.sortingOrder) { Undo.RecordObject(sprite, "Edit Sorting Order"); sprite.sortingOrder = newSortingLayerOrder; EditorUtility.SetDirty(sprite); if (!Application.isPlaying && !string.IsNullOrEmpty(sprite.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } serializedObject.ApplyModifiedProperties(); }
private static void ShowSpriteFrame(TextureFrame frame, SpineData.SkinAttachment attachmentData, Transform slot, Transform skinParent, SpineArmatureEditor armatureEditor) { GameObject go = new GameObject(); SpriteFrame newFrame = go.AddComponent <SpriteFrame>(); newFrame.CreateQuad(); newFrame.textureFrames = armatureEditor.m_TextureFrames; newFrame.frame = frame; newFrame.name = attachmentData.name; newFrame.pivot = Vector2.one * 0.5f; newFrame.transform.parent = skinParent; Vector3 localPos = Vector3.zero; localPos.x = attachmentData.x; localPos.y = attachmentData.y; newFrame.transform.localPosition = localPos; Vector3 localSc = Vector3.one; localSc.x = attachmentData.scaleX; localSc.y = attachmentData.scaleY; if (newFrame.frame.isRotated) { if (attachmentData.width > 0 && frame.rect.height > 0) { localSc.x *= attachmentData.width / frame.rect.height; } if (attachmentData.height > 0 && frame.rect.width > 0) { localSc.y *= attachmentData.height / frame.rect.width; } } else { if (attachmentData.width > 0 && frame.rect.width > 0) { localSc.x *= attachmentData.width / frame.rect.width; } if (attachmentData.height > 0 && frame.rect.height > 0) { localSc.y *= attachmentData.height / frame.rect.height; } } newFrame.transform.localScale = localSc; newFrame.color = attachmentData.color; newFrame.transform.localRotation = Quaternion.Euler(0, 0, attachmentData.rotation); if (armatureEditor.genImgCollider) { BoxCollider2D collider = newFrame.gameObject.AddComponent <BoxCollider2D>(); if (newFrame.frame.isRotated) { collider.size = new Vector2(newFrame.frame.rect.size.y, newFrame.frame.rect.size.x) * armatureEditor.unit; Vector2 center = new Vector2( -newFrame.frame.frameSize.width / 2 - newFrame.frame.frameSize.x + newFrame.frame.rect.width / 2, newFrame.frame.frameSize.height / 2 + newFrame.frame.frameSize.y - newFrame.frame.rect.height / 2); collider.offset = center * armatureEditor.unit; } else { collider.size = newFrame.frame.rect.size * armatureEditor.unit; Vector2 center = new Vector2( -newFrame.frame.frameSize.width / 2 - newFrame.frame.frameSize.x + newFrame.frame.rect.width / 2, newFrame.frame.frameSize.height / 2 + newFrame.frame.frameSize.y - newFrame.frame.rect.height / 2); collider.offset = center * armatureEditor.unit; } } newFrame.UpdateVertexColor(); }
//init public void InitShow() { DragonBoneShowArmature.AddBones(this); DragonBoneShowArmature.AddSlot(this); DragonBoneShowArmature.ShowBones(this); DragonBoneShowArmature.ShowSlots(this); DragonBoneShowArmature.ShowSkins(this); DragonBoneShowArmature.SetIKs(this); DragonBoneAnimFile.CreateAnimFile(this); Armature armature = _armature.GetComponent <Armature>(); m_prefabs.Add(_armature.gameObject); armature.textureFrames = m_TextureFrames; //update slot display for (int s = 0; s < m_slots.Count; ++s) { m_slots[s].displayIndex = m_slots[s].displayIndex; } if (armature.isUGUI) { UnityEngine.UI.MaskableGraphic[] renders = _armature.GetComponentsInChildren <UnityEngine.UI.MaskableGraphic>(true); armature.uiAttachments = renders; armature.attachments = new Renderer[0]; } else { Renderer[] renders = _armature.GetComponentsInChildren <Renderer>(true); armature.attachments = renders; armature.uiAttachments = new UnityEngine.UI.MaskableGraphic[0]; } armature.slots = m_slots.ToArray(); armature.bones = m_bones.ToArray(); armature.zSpace = zoffset; armature.sonArmatures = m_sonArmature.ToArray(); if (armatureAnimList.ContainsKey(armature.name)) { armature.anims = armatureAnimList[armature.name].ToArray(); } armature.ResetSlotZOrder(); string path = AssetDatabase.GetAssetPath(animTextAsset); path = path.Substring(0, path.LastIndexOf('/')) + "/" + _armature.name; //create pose data PoseData poseData = AssetDatabase.LoadAssetAtPath <PoseData>(path + "_Pose.asset"); if (poseData == null) { poseData = ScriptableObject.CreateInstance <PoseData>(); AssetDatabase.CreateAsset(poseData, path + "_Pose.asset"); } poseData.slotDatas = new PoseData.SlotData[armature.slots.Length]; for (int i = 0; i < armature.slots.Length; ++i) { poseData.slotDatas[i] = new PoseData.SlotData(); poseData.slotDatas[i].color = armature.slots[i].color; poseData.slotDatas[i].displayIndex = armature.slots[i].displayIndex; poseData.slotDatas[i].zorder = armature.slots[i].z; armature.slots[i].SendMessage("UpdateSlotByInheritSlot", SendMessageOptions.DontRequireReceiver); } poseData.boneDatas = new PoseData.TransformData[armature.bones.Length]; for (int i = 0; i < armature.bones.Length; ++i) { poseData.boneDatas[i] = new PoseData.TransformData(); poseData.boneDatas[i].x = armature.bones[i].localPosition.x; poseData.boneDatas[i].y = armature.bones[i].localPosition.y; poseData.boneDatas[i].sx = armature.bones[i].localScale.x; poseData.boneDatas[i].sy = armature.bones[i].localScale.y; poseData.boneDatas[i].rotation = armature.bones[i].localEulerAngles.z; } if (isUGUI) { poseData.displayDatas = new PoseData.DisplayData[armature.uiAttachments.Length]; for (int i = 0; i < armature.uiAttachments.Length; ++i) { poseData.displayDatas[i] = new PoseData.DisplayData(); UnityEngine.UI.MaskableGraphic render = armature.uiAttachments[i]; UIFrame sf = render.GetComponent <UIFrame>(); if (sf) { poseData.displayDatas[i].type = PoseData.AttachmentType.IMG; poseData.displayDatas[i].color = sf.color; } else { UIMesh sm = render.GetComponent <UIMesh>(); if (sm) { poseData.displayDatas[i].type = PoseData.AttachmentType.MESH; poseData.displayDatas[i].color = sm.color; poseData.displayDatas[i].vertex = (Vector3[])sm.vertices.Clone(); if (sm.weights == null || sm.weights.Length == 0) { for (int k = 0; k < poseData.displayDatas[i].vertex.Length; ++k) { poseData.displayDatas[i].vertex[k] /= 100f; } } } else { UnityEngine.UI.Image sr = render.GetComponent <UnityEngine.UI.Image>(); if (sr) { poseData.displayDatas[i].type = PoseData.AttachmentType.IMG; poseData.displayDatas[i].color = sr.color; } else { poseData.displayDatas[i].type = PoseData.AttachmentType.BOX; } } } poseData.displayDatas[i].transform = new PoseData.TransformData(); poseData.displayDatas[i].transform.x = render.transform.localPosition.x; poseData.displayDatas[i].transform.y = render.transform.localPosition.y; poseData.displayDatas[i].transform.sx = render.transform.localScale.x; poseData.displayDatas[i].transform.sy = render.transform.localScale.y; poseData.displayDatas[i].transform.rotation = render.transform.localEulerAngles.z; render.transform.localScale *= unit; } } else { poseData.displayDatas = new PoseData.DisplayData[armature.attachments.Length]; for (int i = 0; i < armature.attachments.Length; ++i) { poseData.displayDatas[i] = new PoseData.DisplayData(); Renderer render = armature.attachments[i]; SpriteFrame sf = render.GetComponent <SpriteFrame>(); if (sf) { poseData.displayDatas[i].type = PoseData.AttachmentType.IMG; poseData.displayDatas[i].color = sf.color; } else { SpriteMesh sm = render.GetComponent <SpriteMesh>(); if (sm) { poseData.displayDatas[i].type = PoseData.AttachmentType.MESH; poseData.displayDatas[i].color = sm.color; poseData.displayDatas[i].vertex = (Vector3[])sm.vertices.Clone(); } else { SpriteRenderer sr = render.GetComponent <SpriteRenderer>(); if (sr) { poseData.displayDatas[i].type = PoseData.AttachmentType.IMG; poseData.displayDatas[i].color = sr.color; } else { poseData.displayDatas[i].type = PoseData.AttachmentType.BOX; } } } poseData.displayDatas[i].transform = new PoseData.TransformData(); poseData.displayDatas[i].transform.x = render.transform.localPosition.x; poseData.displayDatas[i].transform.y = render.transform.localPosition.y; poseData.displayDatas[i].transform.sx = render.transform.localScale.x; poseData.displayDatas[i].transform.sy = render.transform.localScale.y; poseData.displayDatas[i].transform.rotation = render.transform.localEulerAngles.z; } } armature.poseData = poseData; AssetDatabase.Refresh(); EditorUtility.SetDirty(poseData); AssetDatabase.SaveAssets(); if (armature.textureFrames && armature.textureFrames.materials != null && armature.textureFrames.materials.Length > 0) { armature.preMultiplyAlpha = armature.textureFrames.materials[0].GetFloat("_BlendSrc") == (int)UnityEngine.Rendering.BlendMode.One; } else { armature.preMultiplyAlpha = true; } if (armature.isUGUI) { GameObject canvas = GameObject.Find("/Canvas"); if (canvas) { _armature.SetParent(canvas.transform); _armature.localScale = Vector3.one / unit; _armature.localPosition = Vector3.zero; } } if (genPrefab) { string prefabPath = path + ".prefab"; GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath); if (!prefab) { PrefabUtility.CreatePrefab(prefabPath, _armature.gameObject, ReplacePrefabOptions.ConnectToPrefab); } else { PrefabUtility.ReplacePrefab(_armature.gameObject, prefab, ReplacePrefabOptions.ConnectToPrefab); } } }
public override void OnInspectorGUI() { Armature armature = target as Armature; if (armature == null) { return; } bool haveGroup = false; #if UNITY_5_6_OR_NEWER haveGroup = armature.sortingGroup != null; #endif if (!armature.isUGUI && !haveGroup) { selectedOption = EditorGUILayout.Popup("Sorting Layer", selectedOption, sortingLayerNames); if (sortingLayerNames[selectedOption] != armature.sortingLayerName) { Undo.RecordObject(armature, "Sorting Layer"); armature.sortingLayerName = sortingLayerNames[selectedOption]; EditorUtility.SetDirty(armature); } int newSortingLayerOrder = EditorGUILayout.IntField("Order in Layer", armature.sortingOrder); if (newSortingLayerOrder != armature.sortingOrder) { Undo.RecordObject(armature, "Edit Sorting Order"); armature.sortingOrder = newSortingLayerOrder; EditorUtility.SetDirty(armature); } if (GUILayout.Button("Update All Sorting", GUILayout.Height(20))) { armature.sortingLayerName = armature.sortingLayerName; armature.sortingOrder = armature.sortingOrder; EditorUtility.SetDirty(armature); foreach (Renderer render in armature.GetComponentsInChildren <Renderer>(true)) { render.sortingLayerName = armature.sortingLayerName; render.sortingOrder = armature.sortingOrder; EditorUtility.SetDirty(render); SpriteFrame sf = render.GetComponent <SpriteFrame>(); if (sf) { sf.sortingLayerName = armature.sortingLayerName; sf.sortingOrder = armature.sortingOrder; UnityEditor.EditorUtility.SetDirty(sf); } else { SpriteMesh sm = render.GetComponent <SpriteMesh>(); if (sm) { sm.sortingLayerName = armature.sortingLayerName; sm.sortingOrder = armature.sortingOrder; UnityEditor.EditorUtility.SetDirty(sm); } } } foreach (Armature sonArmature in armature.GetComponentsInChildren <Armature>(true)) { sonArmature.sortingLayerName = sonArmature.sortingLayerName; sonArmature.sortingOrder = sonArmature.sortingOrder; EditorUtility.SetDirty(sonArmature); } if (!string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } EditorGUILayout.Space(); } serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("color"), true); if (!Application.isPlaying) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_FlipX"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_FlipY"), true); } EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PreMultiplyAlpha"), true); if (!Application.isPlaying) { if (!armature.isUGUI) { #if UNITY_5_6_OR_NEWER EditorGUILayout.PropertyField(serializedObject.FindProperty("sortType"), true); #else armature.sortType = Armature.SortType.ZSpace; #endif EditorGUILayout.PropertyField(serializedObject.FindProperty("zSpace"), true); if (sortType != armature.sortType) { sortType = armature.sortType; armature.sortingOrder = armature.sortingOrder; } } } if (armature.anims != null && armature.anims.Length > 0) { int temp = (int)armature.animIndex; System.Collections.Generic.List <string> animsList = new System.Collections.Generic.List <string>(armature.anims); animsList.Insert(0, "<None>"); armature.animIndex = EditorGUILayout.Popup("Current Animation", temp + 1, animsList.ToArray()) - 1; if (armature.animIndex != temp && !Application.isPlaying) { UnityEditor.EditorUtility.SetDirty(armature); if (!Application.isPlaying && !string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } } EditorGUILayout.PropertyField(serializedObject.FindProperty("anims"), true); if (armature.skins != null && armature.skins.Length > 1) { int temp = armature.skinIndex; armature.skinIndex = EditorGUILayout.Popup("Skins", armature.skinIndex, armature.skins); if (temp != armature.skinIndex && !Application.isPlaying) { UnityEditor.EditorUtility.SetDirty(armature); if (!string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } } EditorGUILayout.PropertyField(serializedObject.FindProperty("slots"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("bones"), true); if (armature.isUGUI) { EditorGUILayout.PropertyField(serializedObject.FindProperty("uiAttachments"), true); } else { EditorGUILayout.PropertyField(serializedObject.FindProperty("attachments"), true); } EditorGUILayout.PropertyField(serializedObject.FindProperty("sonArmatures"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("parentArmature"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("textureFrames"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("poseData"), true); serializedObject.ApplyModifiedProperties(); if (!Application.isPlaying && armature.flipX != flipX) { armature.flipX = armature.flipX; flipX = armature.flipX; if (!string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } if (!Application.isPlaying && armature.flipY != flipY) { armature.flipY = armature.flipY; flipY = armature.flipY; if (!string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } if (!Application.isPlaying && armature.zSpace != zspace) { zspace = armature.zSpace; armature.ResetSlotZOrder(); if (!string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } if (armature.preMultiplyAlpha != preMultiplyAlpha) { preMultiplyAlpha = armature.preMultiplyAlpha; armature.preMultiplyAlpha = preMultiplyAlpha; if (!Application.isPlaying && !string.IsNullOrEmpty(armature.gameObject.scene.name)) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } if (!Application.isPlaying && !armature.isUGUI && armature.parentArmature == null) { ArmatureMesh am = armature.gameObject.GetComponent <ArmatureMesh>(); if (!am) { if (GUILayout.Button("Add Armature Mesh", GUILayout.Height(20))) { am = armature.gameObject.AddComponent <ArmatureMesh>(); } } } GUILayout.Space(5); if (GUILayout.Button("Set To Pose", GUILayout.Height(20))) { armature.SetToPose(); } }
/// <summary> /// Sets to pose. /// </summary> public void SetToPose() { if (poseData) { for (int i = 0; i < poseData.boneDatas.Length && i < bones.Length; ++i) { Transform bone = bones[i]; if (bone) { PoseData.TransformData transData = poseData.boneDatas[i]; bone.localPosition = new Vector3(transData.x, transData.y, bone.localPosition.z); bone.localScale = new Vector3(transData.sx, transData.sy, bone.localScale.z); bone.localEulerAngles = new Vector3(bone.localEulerAngles.x, bone.localEulerAngles.y, transData.rotation); } } for (int i = 0; i < poseData.slotDatas.Length && i < slots.Length; ++i) { Slot slot = slots[i]; if (slot) { slot.color = poseData.slotDatas[i].color; slot.displayIndex = poseData.slotDatas[i].displayIndex; slot.z = poseData.slotDatas[i].zorder; } m_SortedSlots = null; } if (isUGUI) { for (int i = 0; i < poseData.displayDatas.Length && i < uiAttachments.Length; ++i) { MaskableGraphic mg = uiAttachments[i]; if (mg) { PoseData.DisplayData displayData = poseData.displayDatas[i]; switch (displayData.type) { case PoseData.AttachmentType.IMG: UIFrame uf = mg.GetComponent <UIFrame>(); if (uf) { uf.color = displayData.color; } else { Image img = mg.GetComponent <Image>(); if (img) { img.color = displayData.color; } } break; case PoseData.AttachmentType.MESH: UIMesh um = mg.GetComponent <UIMesh> (); um.vertices = (Vector3[])displayData.vertex.Clone(); if (um.vertControlTrans != null && um.vertControlTrans.Length > 0) { for (int j = 0; j < um.vertControlTrans.Length && j < um.vertices.Length; ++j) { Transform vctr = um.vertControlTrans [j]; if (vctr) { vctr.localPosition = um.vertices [j]; } } } break; } } } } else { for (int i = 0; i < poseData.displayDatas.Length && i < attachments.Length; ++i) { Renderer r = attachments[i]; if (r) { PoseData.DisplayData displayData = poseData.displayDatas[i]; switch (displayData.type) { case PoseData.AttachmentType.IMG: SpriteFrame sf = r.GetComponent <SpriteFrame>(); if (sf) { sf.color = displayData.color; } else { SpriteRenderer sr = r.GetComponent <SpriteRenderer>(); if (sr) { sr.color = displayData.color; } } break; case PoseData.AttachmentType.MESH: SpriteMesh sm = r.GetComponent <SpriteMesh>(); sm.vertices = (Vector3[])displayData.vertex.Clone(); if (sm.vertControlTrans != null) { for (int j = 0; j < sm.vertControlTrans.Length && j < sm.vertices.Length; ++j) { Transform vctr = sm.vertControlTrans[j]; if (vctr) { vctr.localPosition = sm.vertices[j]; } } } break; } } } } } ResetSlotZOrder(); }