コード例 #1
0
        protected override void _onClear()
        {
            base._onClear();

            skin    = null;
            slot    = null;
            display = null;
        }
コード例 #2
0
ファイル: ArmatureData.cs プロジェクト: zyz120/AfterDeath
 public void AddSlot(SkinSlotData value)
 {
     if (value != null && value.slot != null && !slots.ContainsKey(value.slot.name))
     {
         slots[value.slot.name] = value;
     }
     else
     {
         DragonBones.Assert(false, DragonBones.ARGUMENT_ERROR);
     }
 }
コード例 #3
0
        /**
         * @private
         */
        internal void _init(SkinSlotData skinSlotData, object rawDisplay, object meshDisplay)
        {
            if (_skinSlotData != null)
            {
                return;
            }

            _skinSlotData = skinSlotData;

            var slotData = _skinSlotData.slot;

            name = slotData.name;

            _zOrder    = slotData.zOrder;
            _blendMode = slotData.blendMode;
            _colorTransform.CopyFrom(slotData.color);
            _rawDisplay  = rawDisplay;
            _meshDisplay = meshDisplay;

            _blendModeDirty = true;
            _colorDirty     = true;
        }
コード例 #4
0
        /**
         * @private
         */
        internal void _init(SkinSlotData skinSlotData, object rawDisplay, object meshDisplay)
        {
            if (_skinSlotData != null)
            {
                return;
            }

            _skinSlotData = skinSlotData;

            var slotData = _skinSlotData.slot;

            name = slotData.name;

            _zOrder    = slotData.zOrder;
            _blendMode = slotData.blendMode;
            _colorTransform.CopyFrom(slotData.color);
            _rawDisplay  = rawDisplay;
            _meshDisplay = meshDisplay;
            DragonBones.ResizeList(_textureDatas, _skinSlotData.displays.Count, null);

            _blendModeDirty = true;
            _colorDirty     = true;
        }
コード例 #5
0
        /**
         * @private
         */
        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);
                }
            }

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

            if (_rawDisplay != null)
            {
                _disposeDisplay(_rawDisplay);
            }

            displayController = null;

            _displayDirty     = false;
            _zOrderDirty      = false;
            _blendModeDirty   = false;
            _colorDirty       = false;
            _originalDirty    = false;
            _transformDirty   = false;
            _meshDirty        = false;
            _updateState      = -1;
            _blendMode        = BlendMode.Normal;
            _displayIndex     = -1;
            _cachedFrameIndex = -1;
            _zOrder           = -1;
            _pivotX           = 0.0f;
            _pivotY           = 0.0f;
            _localMatrix.Identity();
            _colorTransform.Identity();
            _ffdVertices.Clear();
            _displayList.Clear();
            _replacedDisplayDatas.Clear();
            _meshBones.Clear();
            _skinSlotData        = null;
            _displayData         = null;
            _replacedDisplayData = null;
            _textureData         = null;
            _meshData            = null;
            _boundingBoxData     = null;
            _rawDisplay          = null;
            _meshDisplay         = null;
            _display             = null;
            _childArmature       = null;
            _cachedFrameIndices  = null;
        }
コード例 #6
0
 /**
  * @private
  */
 protected abstract Slot _generateSlot(BuildArmaturePackage dataPackage, SkinSlotData skinSlotData, Armature armature);
コード例 #7
0
ファイル: UnityFactory.cs プロジェクト: zyz120/AfterDeath
        /**
         * @private
         */
        override protected Slot _generateSlot(BuildArmaturePackage dataPackage, SkinSlotData skinSlotData, Armature armature)
        {
            var slotData    = skinSlotData.slot;
            var slot        = BaseObject.BorrowObject <UnitySlot>();
            var displayList = new List <object>();

            DragonBones.ResizeList(displayList, skinSlotData.displays.Count, null);

            var armatureDisplay = armature.display as GameObject;
            var transform       = armatureDisplay.transform.Find(skinSlotData.slot.name);
            var gameObject      = transform == null ? null : transform.gameObject;

            if (gameObject == null)
            {
                gameObject = new GameObject(slotData.name);
                gameObject.AddComponent <MeshRenderer>();
                gameObject.AddComponent <MeshFilter>();
            }

            slot._init(
                skinSlotData,
                gameObject,
                gameObject
                );

            for (int i = 0, l = skinSlotData.displays.Count; i < l; ++i)
            {
                var displayData = skinSlotData.displays[i];
                switch (displayData.type)
                {
                case DisplayType.Image:
                    if (displayData.texture == null)
                    {
                        displayData.texture = _getTextureData(dataPackage.dataName, displayData.path);
                    }

                    if (!string.IsNullOrEmpty(dataPackage.textureAtlasName))
                    {
                        slot._textureDatas[i] = _getTextureData(dataPackage.textureAtlasName, displayData.path);
                    }

                    displayList[i] = slot.rawDisplay;
                    break;

                case DisplayType.Mesh:
                    if (displayData.texture == null)
                    {
                        displayData.texture = _getTextureData(dataPackage.dataName, displayData.path);
                    }

                    if (!string.IsNullOrEmpty(dataPackage.textureAtlasName))
                    {
                        slot._textureDatas[i] = _getTextureData(dataPackage.textureAtlasName, displayData.path);
                    }

                    displayList[i] = slot.meshDisplay;
                    break;

                case DisplayType.Armature:
                    var childDisplayName = slotData.name + " (" + displayData.path + ")";     //
                    var childTransform   = armatureDisplay.transform.Find(childDisplayName);
                    var childArmature    = childTransform == null?
                                           BuildArmature(displayData.path, dataPackage.dataName) :
                                               BuildArmatureComponent(displayData.path, dataPackage.dataName, null, dataPackage.textureAtlasName, childTransform.gameObject).armature;

                    if (childArmature != null)
                    {
                        childArmature.inheritAnimation = displayData.inheritAnimation;
                        if (!childArmature.inheritAnimation)
                        {
                            var actions = slotData.actions.Count > 0 ? slotData.actions : childArmature.armatureData.actions;
                            if (actions.Count > 0)
                            {
                                foreach (var actionData in actions)
                                {
                                    childArmature._bufferAction(actionData);
                                }
                            }
                            else
                            {
                                childArmature.animation.Play();
                            }
                        }

                        displayData.armature = childArmature.armatureData;     //

                        // Hide
                        var childArmatureDisplay = childArmature.display as GameObject;
                        childArmatureDisplay.name = childDisplayName;
                        childArmatureDisplay.gameObject.hideFlags = HideFlags.HideInHierarchy;
                        childArmatureDisplay.SetActive(false);
                    }

                    displayList[i] = childArmature;
                    break;

                default:
                    displayList[i] = null;
                    break;
                }
            }

            slot._setDisplayList(displayList);

            return(slot);
        }