void LateUpdate()
        {
            if (_armature == null)
            {
                return;
            }

            _flipX = _armature.flipX;
            _flipY = _armature.flipY;

#if UNITY_5_6_OR_NEWER
            var hasSortingGroup = GetComponent <UnityEngine.Rendering.SortingGroup>() != null;
            if (hasSortingGroup != _hasSortingGroup)
            {
                _hasSortingGroup = hasSortingGroup;

                _UpdateSortingGroup();
            }
#endif
            if (unityBones != null)
            {
                int len = unityBones.Count;
                for (int i = 0; i < len; ++i)
                {
                    UnityBone bone = unityBones[i];
                    if (bone)
                    {
                        bone._Update();
                    }
                }
            }
        }
Example #2
0
        void LateUpdate()
        {
            if (_armature == null)
            {
                return;
            }

            flipX = _armature.flipX;
            flipY = _armature.flipY;

                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                                #if UNITY_5_6_OR_NEWER
                if (!isUGUI)
                {
                    _sortingGroup = GetComponent <UnityEngine.Rendering.SortingGroup>();
                    if (_sortingGroup)
                    {
                        sortingMode       = SortingMode.SortByOrder;
                        _sortingLayerName = _sortingGroup.sortingLayerName;
                        _sortingOrder     = _sortingGroup.sortingOrder;
                    }
                }
                                #endif
                foreach (var slot in _armature.GetSlots())
                {
                    var display = slot.display as GameObject;
                    if (display != null)
                    {
                        display.transform.localPosition = new Vector3(display.transform.localPosition.x, display.transform.localPosition.y, -slot._zOrder * (_zSpace + 0.001f));
                        if (!isUGUI && sortingMode == SortingMode.SortByOrder)
                        {
                            UnitySlot us = slot as UnitySlot;
                            if (us.meshRenderer != null)
                            {
                                us.meshRenderer.sortingOrder = slot._zOrder;
                            }
                        }
                    }
                }
            }
                        #endif
            if (zorderIsDirty)
            {
                _sortedSlots = new List <Slot>(_armature.GetSlots());
                _sortedSlots.Sort(delegate(Slot x, Slot y) {
                    return(x._zOrder - y._zOrder);
                });
                for (int i = 0; i < _sortedSlots.Count; ++i)
                {
                    Slot slot    = _sortedSlots[i];
                    var  display = slot.display as GameObject;
                    if (display != null)
                    {
                        display.transform.SetSiblingIndex(i);
                        if (!isUGUI && sortingMode == SortingMode.SortByOrder)
                        {
                            UnitySlot us = slot as UnitySlot;
                            if (us.meshRenderer != null)
                            {
                                us.meshRenderer.sortingOrder = i;
                            }
                        }
                    }
                }
                zorderIsDirty = false;
            }
            if (unityBones != null)
            {
                int len = unityBones.Count;
                for (int i = 0; i < len; ++i)
                {
                    UnityBone bone = unityBones[i];
                    if (bone)
                    {
                        bone._Update();
                    }
                }
            }
        }