Exemplo n.º 1
0
        /// <summary>
        /// 用特定的显示对象数据替换特定插槽当前的显示对象数据。
        /// </summary>
        /// <param name="dragonBonesName">The DragonBonesData instance cache name</param>
        /// <param name="armatureName">The armature data name</param>
        /// <param name="slotName">The slot data name</param>
        /// <param name="displayName">The display data name</param>
        /// <param name="slot">The slot</param>
        /// <param name="texture">The new texture</param>
        /// <param name="material">The new material</param>
        /// <param name="isUGUI">is ugui。</param>
        /// <param name="displayIndex">The index of the display data that is replaced. (If it is not set, replaces the current display data)</param>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>

        /// <summary>
        /// 用特定的显示对象数据替换特定插槽当前的显示对象数据。
        /// </summary>
        /// <param name="dragonBonesName">指定的龙骨数据名称。</param>
        /// <param name="armatureName">指定的骨架名称。</param>
        /// <param name="slotName">指定的插槽名称。</param>
        /// <param name="displayName">指定的显示对象名称。</param>
        /// <param name="slot">指定的插槽实例。</param>
        /// <param name="texture">新的贴图。</param>
        /// <param name="material">新的材质。</param>
        /// <param name="isUGUI">是否为ugui。</param>
        /// <param name="displayIndex">被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据)。</param>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>
        public void ReplaceSlotDisplay(
            string dragonBonesName, string armatureName, string slotName, string displayName,
            Slot slot, Texture2D texture, Material material,
            bool isUGUI = false, int displayIndex = -1)
        {
            var armatureData = this.GetArmatureData(armatureName, dragonBonesName);

            if (armatureData == null || armatureData.defaultSkin == null)
            {
                return;
            }

            var displays = armatureData.defaultSkin.GetDisplays(slotName);

            if (displays == null)
            {
                return;
            }

            DisplayData prevDispalyData = null;

            foreach (var displayData in displays)
            {
                if (displayData.name == displayName)
                {
                    prevDispalyData = displayData;
                    break;
                }
            }

            if (prevDispalyData == null || !(prevDispalyData is ImageDisplayData))
            {
                return;
            }

            TextureData      prevTextureData = (prevDispalyData as ImageDisplayData).texture;
            UnityTextureData newTextureData  = new UnityTextureData();

            newTextureData.CopyFrom(prevTextureData);
            newTextureData.rotated       = false;
            newTextureData.region.x      = 0.0f;
            newTextureData.region.y      = 0.0f;
            newTextureData.region.width  = texture.width;
            newTextureData.region.height = texture.height;
            newTextureData.frame         = newTextureData.region;
            newTextureData.name          = prevTextureData.name;
            newTextureData.parent        = new UnityTextureAtlasData();
            newTextureData.parent.width  = (uint)texture.width;
            newTextureData.parent.height = (uint)texture.height;
            if (isUGUI)
            {
                (newTextureData.parent as UnityTextureAtlasData).uiTexture = material;
            }
            else
            {
                (newTextureData.parent as UnityTextureAtlasData).texture = material;
            }

            material.mainTexture = texture;

            ImageDisplayData newDisplayData = prevDispalyData is MeshDisplayData ? new MeshDisplayData() : new ImageDisplayData();

            newDisplayData.type = prevDispalyData.type;
            newDisplayData.name = prevDispalyData.name;
            newDisplayData.path = prevDispalyData.path;
            newDisplayData.transform.CopyFrom(prevDispalyData.transform);
            newDisplayData.parent = prevDispalyData.parent;
            newDisplayData.pivot.CopyFrom((prevDispalyData as ImageDisplayData).pivot);
            newDisplayData.texture = newTextureData;

            if (newDisplayData is MeshDisplayData)
            {
                (newDisplayData as MeshDisplayData).inheritAnimation = (prevDispalyData as MeshDisplayData).inheritAnimation;
                (newDisplayData as MeshDisplayData).offset           = (prevDispalyData as MeshDisplayData).offset;
                (newDisplayData as MeshDisplayData).weight           = (prevDispalyData as MeshDisplayData).weight;
            }

            ReplaceDisplay(slot, newDisplayData, displayIndex);
        }
Exemplo n.º 2
0
        /**
         * @language zh_CN
         * 用外部贴图替换display贴图。
         * @param dragonBonesName 指定的龙骨数据名称。
         * @param armatureName 指定的骨架名称。
         * @param slotName 指定的插槽名称。
         * @param displayName 指定的显示对象名称。
         * @param slot 指定的插槽实例。
         * @param texture 新的贴图。
         * @param material 新的材质。
         * @param isUGUI 是否为ugui。
         * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
         * @version DragonBones 4.5
         */
        public void ReplaceSlotDisplay(string dragonBonesName, string armatureName, string slotName, string displayName, Slot slot, Texture2D texture, Material material, bool isUGUI = false, int displayIndex = -1)
        {
            var dataPackage = new BuildArmaturePackage();

            if (_fillBuildArmaturePackage(dataPackage, dragonBonesName, armatureName, null, null))
            {
                var slotDisplayDataSet = dataPackage.skin.GetSlot(slotName);
                if (slotDisplayDataSet != null)
                {
                    DisplayData prevDispalyData = null;
                    foreach (var displayData in slotDisplayDataSet.displays)
                    {
                        if (displayData.name == displayName)
                        {
                            prevDispalyData = displayData;
                            break;
                        }
                    }
                    if (prevDispalyData == null)
                    {
                        return;
                    }

                    TextureData      prevTextureData = prevDispalyData.texture;
                    UnityTextureData newTextureData  = new UnityTextureData();
                    newTextureData.CopyFrom(prevTextureData);
                    newTextureData.rotated       = false;
                    newTextureData.region.x      = 0f;
                    newTextureData.region.y      = 0f;
                    newTextureData.region.width  = texture.width;
                    newTextureData.region.height = texture.height;
                    newTextureData.frame         = newTextureData.region;
                    newTextureData.name          = prevTextureData.name;
                    newTextureData.parent        = new UnityTextureAtlasData();
                    newTextureData.parent.width  = texture.width;
                    newTextureData.parent.height = texture.height;
                    if (isUGUI)
                    {
                        (newTextureData.parent as UnityTextureAtlasData).uiTexture = material;
                    }
                    else
                    {
                        (newTextureData.parent as UnityTextureAtlasData).texture = material;
                    }
                    material.mainTexture = texture;

                    DisplayData newDisplayData = new DisplayData();
                    newDisplayData.armature         = prevDispalyData.armature;
                    newDisplayData.boundingBox      = prevDispalyData.boundingBox;
                    newDisplayData.inheritAnimation = prevDispalyData.inheritAnimation;
                    newDisplayData.isRelativePivot  = prevDispalyData.isRelativePivot;
                    newDisplayData.name             = prevDispalyData.name;
                    newDisplayData.pivot.CopyFrom(prevDispalyData.pivot);
                    newDisplayData.texture = newTextureData;
                    newDisplayData.type    = prevDispalyData.type;
                    newDisplayData.transform.CopyFrom(prevDispalyData.transform);
                    newDisplayData.mesh = prevDispalyData.mesh;
                    if (newDisplayData.mesh != null && newDisplayData.mesh.uvs != null)
                    {
                        List <float> uvs = new List <float>();
                        for (int i = 0; i < newDisplayData.mesh.uvs.Count; i += 2)
                        {
                            Vector2 uv    = new Vector2(newDisplayData.mesh.uvs[i], newDisplayData.mesh.uvs[i + 1]);
                            Vector2 uvPos = new Vector2(newTextureData.frame.x, -newTextureData.frame.y) +
                                            new Vector2(newTextureData.frame.width * uv.x, newTextureData.frame.height * uv.y);
                            uv.x = uvPos.x / newTextureData.frame.width;
                            uv.y = uvPos.y / newTextureData.frame.height;
                            uvs.Add(uv.x);
                            uvs.Add(uv.y);
                        }
                        newDisplayData.mesh.uvs.Clear();
                        newDisplayData.mesh.uvs.AddRange(uvs);
                    }
                    _replaceSlotDisplay(dataPackage, newDisplayData, slot, displayIndex);
                }
            }
        }
Exemplo n.º 3
0
        /**
         * @private
         */
        protected void _updatePivot(DisplayData rawDisplayData, DisplayData currentDisplayData, TextureData currentTextureData)
        {
            var isReplaceDisplay = rawDisplayData != null && rawDisplayData != currentDisplayData;
            if (_meshData != null && _display == _meshDisplay)
            {
                if (_meshData != rawDisplayData.mesh && isReplaceDisplay)
                {
                    _pivotX = rawDisplayData.transform.x - currentDisplayData.transform.x;
                    _pivotY = rawDisplayData.transform.y - currentDisplayData.transform.y;
                }
                else
                {
                    _pivotX = 0.0f;
                    _pivotY = 0.0f;
                }
            }
            else
            {
                var scale = this._armature.armatureData.scale;
                _pivotX = currentDisplayData.pivot.x;
                _pivotY = currentDisplayData.pivot.y;

                if (currentDisplayData.isRelativePivot)
                {
                    var rect = currentTextureData.frame != null ? currentTextureData.frame : currentTextureData.region;
                    var width = rect.width * scale;
                    var height = rect.height * scale;

                    if (currentTextureData.rotated)
                    {
                        width = rect.height;
                        height = rect.width;
                    }

                    _pivotX *= width;
                    _pivotY *= height;
                }

                if (currentTextureData.frame != null)
                {
                    _pivotX += currentTextureData.frame.x * scale;
                    _pivotY += currentTextureData.frame.y * scale;
                }

                if (isReplaceDisplay)
                {
                    _pivotX += rawDisplayData.transform.x - currentDisplayData.transform.x;
                    _pivotY += rawDisplayData.transform.y - currentDisplayData.transform.y;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 用特定的显示对象数据替换特定插槽当前的显示对象数据。
        /// </summary>
        /// <param name="dragonBonesName">The DragonBonesData instance cache name</param>
        /// <param name="armatureName">The armature data name</param>
        /// <param name="slotName">The slot data name</param>
        /// <param name="displayName">The display data name</param>
        /// <param name="slot">The slot</param>
        /// <param name="texture">The new texture</param>
        /// <param name="material">The new material</param>
        /// <param name="isUGUI">is ugui。</param>
        /// <param name="displayIndex">The index of the display data that is replaced. (If it is not set, replaces the current display data)</param>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>

        /// <summary>
        /// 用特定的显示对象数据替换特定插槽当前的显示对象数据。
        /// </summary>
        /// <param name="dragonBonesName">指定的龙骨数据名称。</param>
        /// <param name="armatureName">指定的骨架名称。</param>
        /// <param name="slotName">指定的插槽名称。</param>
        /// <param name="displayName">指定的显示对象名称。</param>
        /// <param name="slot">指定的插槽实例。</param>
        /// <param name="texture">新的贴图。</param>
        /// <param name="material">新的材质。</param>
        /// <param name="isUGUI">是否为ugui。</param>
        /// <param name="displayIndex">被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据)。</param>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>
        public void ReplaceSlotDisplay(
            string dragonBonesName, string armatureName, string slotName, string displayName,
            Slot slot, Texture2D texture, Material material = null,
            bool isUGUI = false, int displayIndex = -1)
        {
            var armatureData = this.GetArmatureData(armatureName, dragonBonesName);

            if (armatureData == null || armatureData.defaultSkin == null)
            {
                return;
            }

            var displays = armatureData.defaultSkin.GetDisplays(slotName);

            if (displays == null)
            {
                return;
            }

            DisplayData prevDispalyData = null;

            foreach (var displayData in displays)
            {
                if (displayData.name == displayName)
                {
                    prevDispalyData = displayData;
                    break;
                }
            }

            if (prevDispalyData == null || !((prevDispalyData is ImageDisplayData) || (prevDispalyData is MeshDisplayData)))
            {
                return;
            }

            TextureData prevTextureData = null;

            if (prevDispalyData is ImageDisplayData)
            {
                prevTextureData = (prevDispalyData as ImageDisplayData).texture;
            }
            else
            {
                prevTextureData = (prevDispalyData as MeshDisplayData).texture;
            }

            UnityTextureData newTextureData = new UnityTextureData();

            newTextureData.CopyFrom(prevTextureData);
            newTextureData.rotated       = false;
            newTextureData.region.x      = 0.0f;
            newTextureData.region.y      = 0.0f;
            newTextureData.region.width  = texture.width;
            newTextureData.region.height = texture.height;
            newTextureData.frame         = newTextureData.region;
            newTextureData.name          = prevTextureData.name;
            newTextureData.parent        = new UnityTextureAtlasData();
            newTextureData.parent.width  = (uint)texture.width;
            newTextureData.parent.height = (uint)texture.height;
            newTextureData.parent.scale  = prevTextureData.parent.scale;

            //
            if (material == null)
            {
                if (isUGUI)
                {
                    material = UnityFactoryHelper.GenerateMaterial(defaultUIShaderName, texture.name + "_UI_Mat", texture);
                }
                else
                {
                    material = UnityFactoryHelper.GenerateMaterial(defaultShaderName, texture.name + "_Mat", texture);
                }
            }

            if (isUGUI)
            {
                (newTextureData.parent as UnityTextureAtlasData).uiTexture = material;
            }
            else
            {
                (newTextureData.parent as UnityTextureAtlasData).texture = material;
            }

            material.mainTexture = texture;

            DisplayData newDisplayData = null;

            if (prevDispalyData is ImageDisplayData)
            {
                newDisplayData      = new ImageDisplayData();
                newDisplayData.type = prevDispalyData.type;
                newDisplayData.name = prevDispalyData.name;
                newDisplayData.path = prevDispalyData.path;
                newDisplayData.transform.CopyFrom(prevDispalyData.transform);
                newDisplayData.parent = prevDispalyData.parent;
                (newDisplayData as ImageDisplayData).pivot.CopyFrom((prevDispalyData as ImageDisplayData).pivot);
                (newDisplayData as ImageDisplayData).texture = newTextureData;
            }
            else if (prevDispalyData is MeshDisplayData)
            {
                newDisplayData      = new MeshDisplayData();
                newDisplayData.type = prevDispalyData.type;
                newDisplayData.name = prevDispalyData.name;
                newDisplayData.path = prevDispalyData.path;
                newDisplayData.transform.CopyFrom(prevDispalyData.transform);
                newDisplayData.parent = prevDispalyData.parent;
                (newDisplayData as MeshDisplayData).texture = newTextureData;

                (newDisplayData as MeshDisplayData).vertices.inheritDeform = (prevDispalyData as MeshDisplayData).vertices.inheritDeform;
                (newDisplayData as MeshDisplayData).vertices.offset        = (prevDispalyData as MeshDisplayData).vertices.offset;
                (newDisplayData as MeshDisplayData).vertices.data          = (prevDispalyData as MeshDisplayData).vertices.data;
                (newDisplayData as MeshDisplayData).vertices.weight        = (prevDispalyData as MeshDisplayData).vertices.weight;
            }

            ReplaceDisplay(slot, newDisplayData, displayIndex);
        }
Exemplo n.º 5
0
        /// <private/>
        protected void _UpdateDisplayData()
        {
            var prevDisplayData = this._displayData;
            var prevTextureData = this._textureData;
            var prevMeshData    = this._meshData;
            var rawDisplayData  = this._displayIndex >= 0 && this._rawDisplayDatas != null && this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;

            if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.Count)
            {
                this._displayData = this._displayDatas[this._displayIndex];
            }
            else
            {
                this._displayData = null;
            }

            // Update texture and mesh data.
            if (this._displayData != null)
            {
                if (this._displayData.type == DisplayType.Image || this._displayData.type == DisplayType.Mesh)
                {
                    this._textureData = (this._displayData as ImageDisplayData).texture;
                    if (this._displayData.type == DisplayType.Mesh)
                    {
                        this._meshData = this._displayData as MeshDisplayData;
                    }
                    else if (rawDisplayData != null && rawDisplayData.type == DisplayType.Mesh)
                    {
                        this._meshData = rawDisplayData as MeshDisplayData;
                    }
                    else
                    {
                        this._meshData = null;
                    }
                }
                else
                {
                    this._textureData = null;
                    this._meshData    = null;
                }
            }
            else
            {
                this._textureData = null;
                this._meshData    = null;
            }

            // Update bounding box data.
            if (this._displayData != null && this._displayData.type == DisplayType.BoundingBox)
            {
                this._boundingBoxData = (this._displayData as BoundingBoxDisplayData).boundingBox;
            }
            else if (rawDisplayData != null && rawDisplayData.type == DisplayType.BoundingBox)
            {
                this._boundingBoxData = (rawDisplayData as BoundingBoxDisplayData).boundingBox;
            }
            else
            {
                this._boundingBoxData = null;
            }

            if (this._displayData != prevDisplayData || this._textureData != prevTextureData || this._meshData != prevMeshData)
            {
                // Update pivot offset.
                if (this._meshData != null)
                {
                    this._pivotX = 0.0f;
                    this._pivotY = 0.0f;
                }
                else if (this._textureData != null)
                {
                    var imageDisplayData = this._displayData as ImageDisplayData;
                    var scale            = this._textureData.parent.scale * this._armature._armatureData.scale;
                    var frame            = this._textureData.frame;

                    this._pivotX = imageDisplayData.pivot.x;
                    this._pivotY = imageDisplayData.pivot.y;

                    var rect   = frame != null ? frame : this._textureData.region;
                    var width  = rect.width;
                    var height = rect.height;

                    if (this._textureData.rotated && frame == null)
                    {
                        width  = rect.height;
                        height = rect.width;
                    }

                    this._pivotX *= width * scale;
                    this._pivotY *= height * scale;

                    if (frame != null)
                    {
                        this._pivotX += frame.x * scale;
                        this._pivotY += frame.y * scale;
                    }
                }
                else
                {
                    this._pivotX = 0.0f;
                    this._pivotY = 0.0f;
                }

                // Update mesh bones and ffd vertices.
                if (this._meshData != prevMeshData)
                {
                    if (this._meshData != null)// && this._meshData === this._displayData
                    {
                        if (this._meshData.weight != null)
                        {
                            this._ffdVertices.ResizeList(this._meshData.weight.count * 2);
                            this._meshBones.ResizeList(this._meshData.weight.bones.Count);

                            for (int i = 0, l = this._meshBones.Count; i < l; ++i)
                            {
                                this._meshBones[i] = this._armature.GetBone(this._meshData.weight.bones[i].name);
                            }
                        }
                        else
                        {
                            var vertexCount = this._meshData.parent.parent.parent.intArray[this._meshData.offset + (int)BinaryOffset.MeshVertexCount];
                            this._ffdVertices.ResizeList(vertexCount * 2);
                            this._meshBones.Clear();
                        }

                        for (int i = 0, l = this._ffdVertices.Count; i < l; ++i)
                        {
                            this._ffdVertices[i] = 0.0f;
                        }

                        this._meshDirty = true;
                    }
                    else
                    {
                        this._ffdVertices.Clear();
                        this._meshBones.Clear();
                    }
                }
                else if (this._meshData != null && this._textureData != prevTextureData)
                {
                    // Update mesh after update frame.
                    this._meshDirty = true;
                }

                if (this._displayData != null && rawDisplayData != null && this._displayData != rawDisplayData && this._meshData == null)
                {
                    rawDisplayData.transform.ToMatrix(Slot._helpMatrix);
                    Slot._helpMatrix.Invert();
                    Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                    this._pivotX -= Slot._helpPoint.x;
                    this._pivotY -= Slot._helpPoint.y;

                    this._displayData.transform.ToMatrix(Slot._helpMatrix);
                    Slot._helpMatrix.Invert();
                    Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                    this._pivotX += Slot._helpPoint.x;
                    this._pivotY += Slot._helpPoint.y;
                }

                // Update original transform.
                if (rawDisplayData != null)
                {
                    this.origin = rawDisplayData.transform;
                }
                else if (this._displayData != null)
                {
                    this.origin = this._displayData.transform;
                }

                this._displayDirty             = true;
                this._transformDirty           = true;
                this._skinedMeshTransformDirty = true;
            }
        }
Exemplo n.º 6
0
        /// <inheritDoc/>
        protected override void _OnClear()
        {
            base._OnClear();

            var disposeDisplayList = new List <object>();

            for (int i = 0, l = _displayList.Count; i < l; ++i)
            {
                var eachDisplay = _displayList[i];
                if (eachDisplay != _rawDisplay && eachDisplay != _meshDisplay && !disposeDisplayList.Contains(eachDisplay))
                {
                    disposeDisplayList.Add(eachDisplay);
                }
            }

            for (int i = 0, l = disposeDisplayList.Count; i < l; ++i)
            {
                var eachDisplay = disposeDisplayList[i];
                if (eachDisplay is Armature)
                {
                    (eachDisplay as Armature).Dispose();
                }
                else
                {
                    _DisposeDisplay(eachDisplay, false);
                }
            }

            if (this._meshDisplay != null && this._meshDisplay != this._rawDisplay)
            {
                // May be _meshDisplay and _rawDisplay is the same one.
                this._DisposeDisplay(this._meshDisplay, false);
            }

            if (this._rawDisplay != null)
            {
                this._DisposeDisplay(this._rawDisplay, false);
            }

            this.displayController = null;

            this._displayDirty             = false;
            this._zOrderDirty              = false;
            this._blendModeDirty           = false;
            this._colorDirty               = false;
            this._meshDirty                = false;
            this._transformDirty           = false;
            this._skinedMeshTransformDirty = false;
            this._visible               = true;
            this._blendMode             = BlendMode.Normal;
            this._displayIndex          = -1;
            this._animationDisplayIndex = -1;
            this._zOrder           = 0;
            this._cachedFrameIndex = -1;
            this._pivotX           = 0.0f;
            this._pivotY           = 0.0f;
            this._localMatrix.Identity();
            this._colorTransform.Identity();
            this._ffdVertices.Clear();
            this._displayList.Clear();
            this._displayDatas.Clear();
            this._meshBones.Clear();
            this._slotData           = null; //
            this._rawDisplayDatas    = null; //
            this._displayData        = null;
            this._textureData        = null;
            this._meshData           = null;
            this._boundingBoxData    = null;
            this._rawDisplay         = null;
            this._meshDisplay        = null;
            this._display            = null;
            this._childArmature      = null;
            this._cachedFrameIndices = null;
        }
Exemplo n.º 7
0
        /// <private/>
        protected void _UpdateDisplayData()
        {
            var prevDisplayData  = this._displayData;
            var prevVerticesData = this._deformVertices != null ? this._deformVertices.verticesData : null;
            var prevTextureData  = this._textureData;

            DisplayData  rawDisplayData      = null;
            VerticesData currentVerticesData = null;

            this._displayData     = null;
            this._boundingBoxData = null;
            this._textureData     = null;

            if (this._displayIndex >= 0)
            {
                if (this._rawDisplayDatas != null)
                {
                    rawDisplayData = this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;
                }

                if (rawDisplayData == null)
                {
                    rawDisplayData = this._GetDefaultRawDisplayData(this._displayIndex);
                }

                if (this._displayIndex < this._displayDatas.Count)
                {
                    this._displayData = this._displayDatas[this._displayIndex];
                }
            }

            // Update texture and mesh data.
            if (this._displayData != null)
            {
                if (this._displayData.type == DisplayType.Mesh)
                {
                    currentVerticesData = (this._displayData as MeshDisplayData).vertices;
                }
                else if (this._displayData.type == DisplayType.Path)
                {
                    currentVerticesData = (this._displayData as PathDisplayData).vertices;
                }
                else if (rawDisplayData != null)
                {
                    if (rawDisplayData.type == DisplayType.Mesh)
                    {
                        currentVerticesData = (rawDisplayData as MeshDisplayData).vertices;
                    }
                    else if (rawDisplayData.type == DisplayType.Path)
                    {
                        currentVerticesData = (rawDisplayData as PathDisplayData).vertices;
                    }
                }

                if (this._displayData.type == DisplayType.BoundingBox)
                {
                    this._boundingBoxData = (this._displayData as BoundingBoxDisplayData).boundingBox;
                }
                else if (rawDisplayData != null)
                {
                    if (rawDisplayData.type == DisplayType.BoundingBox)
                    {
                        this._boundingBoxData = (rawDisplayData as BoundingBoxDisplayData).boundingBox;
                    }
                }

                if (this._displayData.type == DisplayType.Image)
                {
                    this._textureData = (this._displayData as ImageDisplayData).texture;
                }
                else if (this._displayData.type == DisplayType.Mesh)
                {
                    this._textureData = (this._displayData as MeshDisplayData).texture;
                }
            }

            if (this._displayData != prevDisplayData || currentVerticesData != prevVerticesData || this._textureData != prevTextureData)
            {
                // Update pivot offset.
                if (currentVerticesData == null && this._textureData != null)
                {
                    var imageDisplayData = this._displayData as ImageDisplayData;
                    var scale            = this._textureData.parent.scale * this._armature._armatureData.scale;
                    var frame            = this._textureData.frame;

                    this._pivotX = imageDisplayData.pivot.x;
                    this._pivotY = imageDisplayData.pivot.y;

                    var rect   = frame != null ? frame : this._textureData.region;
                    var width  = rect.width;
                    var height = rect.height;

                    if (this._textureData.rotated && frame == null)
                    {
                        width  = rect.height;
                        height = rect.width;
                    }

                    this._pivotX *= width * scale;
                    this._pivotY *= height * scale;

                    if (frame != null)
                    {
                        this._pivotX += frame.x * scale;
                        this._pivotY += frame.y * scale;
                    }

                    // Update replace pivot. TODO
                    if (this._displayData != null && rawDisplayData != null && this._displayData != rawDisplayData)
                    {
                        rawDisplayData.transform.ToMatrix(Slot._helpMatrix);
                        Slot._helpMatrix.Invert();
                        Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                        this._pivotX -= Slot._helpPoint.x;
                        this._pivotY -= Slot._helpPoint.y;

                        this._displayData.transform.ToMatrix(Slot._helpMatrix);
                        Slot._helpMatrix.Invert();
                        Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                        this._pivotX += Slot._helpPoint.x;
                        this._pivotY += Slot._helpPoint.y;
                    }

                    if (!DragonBones.yDown)
                    {
                        this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY;
                    }
                }
                else
                {
                    this._pivotX = 0.0f;
                    this._pivotY = 0.0f;
                }

                // Update original transform.
                if (rawDisplayData != null)
                {
                    // Compatible.
                    this.origin = rawDisplayData.transform;
                }
                else if (this._displayData != null)
                {
                    // Compatible.
                    this.origin = this._displayData.transform;
                }
                else
                {
                    this.origin = null;
                }

                // Update vertices.
                if (currentVerticesData != prevVerticesData)
                {
                    if (this._deformVertices == null)
                    {
                        this._deformVertices = BaseObject.BorrowObject <DeformVertices>();
                    }

                    this._deformVertices.init(currentVerticesData, this._armature);
                }
                else if (this._deformVertices != null && this._textureData != prevTextureData)
                {
                    // Update mesh after update frame.
                    this._deformVertices.verticesDirty = true;
                }

                this._displayDirty   = true;
                this._transformDirty = true;
            }
        }