Exemplo n.º 1
0
        internal void _Update()
        {
            if (_bone != null && _proxy != null && _proxy.armature != null)
            {
                GameObject parent = null;
                if (_proxy.boneHierarchy)
                {
                    parent = GetParentGameObject();
                    if (parent)
                    {
                        transform.SetParent(_proxy.bonesRoot.transform);
                    }
                }
                else if (transform.parent != _proxy.bonesRoot)
                {
                    transform.SetParent(_proxy.bonesRoot.transform);
                }

                _bone.UpdateGlobalTransform();

                Armature armature = _proxy.armature;

                var flipX  = armature.flipX;
                var flipY  = armature.flipY;
                var scaleX = flipX ? -_bone.global.scaleX : _bone.global.scaleX;
                var scaleY = flipY ? -_bone.global.scaleY : _bone.global.scaleY;

                _helpVector3.x = _bone.globalTransformMatrix.tx;
                _helpVector3.y = _bone.globalTransformMatrix.ty;

                if (flipX)
                {
                    _helpVector3.x = -_helpVector3.x;
                }

                if (flipY)
                {
                    _helpVector3.y = -_helpVector3.y;
                }

                _helpVector3.z          = 0f;
                transform.localPosition = _helpVector3;

                if (scaleY >= 0.0f)
                {
                    _helpVector3.x = 0.0f;
                }
                else
                {
                    _helpVector3.x = 180.0f;
                }

                if (scaleX >= 0.0f)
                {
                    _helpVector3.y = 0.0f;
                }
                else
                {
                    _helpVector3.y = 180.0f;
                }

                //_helpVector3.z = -_bone.global.skew * Mathf.Rad2Deg;
                _helpVector3.z             = -_bone.global.skew * Transform.RAD_DEG;
                transform.localEulerAngles = _helpVector3;

                _helpVector3.x = scaleX >= 0.0f ? scaleX : -scaleX;
                _helpVector3.y = scaleY >= 0.0f ? scaleY : -scaleY;
                _helpVector3.z = 1f;

                transform.localScale = _helpVector3;

                if (_proxy.boneHierarchy && parent)
                {
                    transform.SetParent(parent.transform);
                }
            }
        }
Exemplo n.º 2
0
        internal void _Update()
        {
            if (_bone != null && _proxy != null && _proxy.armature != null)
            {
                GameObject parent = null;
                if (_proxy.boneHierarchy)
                {
                    parent = GetParentGameObject();
                    if (parent)
                    {
                        transform.SetParent(_proxy.bonesRoot.transform);
                    }
                }
                else if (transform.parent != _proxy.bonesRoot)
                {
                    transform.SetParent(_proxy.bonesRoot.transform);
                }

                _bone.UpdateGlobalTransform();

                Armature armature = _proxy.armature;

                var flipX = armature.flipX;
                var flipY = armature.flipY;

                // localPosition
                _helpVector3.x          = _bone.globalTransformMatrix.tx;
                _helpVector3.y          = _bone.globalTransformMatrix.ty;
                _helpVector3.z          = 0f;
                transform.localPosition = _helpVector3;

                // localEulerAngles
                _helpVector3.x = flipY ? 180.0f : 0.0f;
                _helpVector3.y = flipX ? 180.0f : 0.0f;
                _helpVector3.z = _bone.global.rotation * Transform.RAD_DEG;

                if (flipX || flipY)
                {
                    if (flipX && flipY)
                    {
                        _helpVector3.z += 180.0f;
                    }
                    else
                    {
                        if (flipX)
                        {
                            _helpVector3.z = 180.0f - _helpVector3.z;
                        }
                        else
                        {
                            _helpVector3.z = -_helpVector3.z;
                        }
                    }
                }

                transform.localEulerAngles = _helpVector3;

                // localScale
                _helpVector3.x = _bone.global.scaleX;
                _helpVector3.y = _bone.global.scaleY;
                _helpVector3.z = 1.0f;

                transform.localScale = _helpVector3;

                if (_proxy.boneHierarchy && parent)
                {
                    transform.SetParent(parent.transform);
                }
            }
        }