public virtual void updateTransform() { if (_isUpdateTransformDirty) { //position Vector2 pInParentAR = _position; if (_parent != null) { if (_parent.ignoreAnchorPointForPosition) { if (FloatUtils.NEQ(_parent.scaleX, 0) && FloatUtils.NEQ(_parent.scaleY, 0)) { pInParentAR += new Vector2(_parent.anchorPointInPixels.x * (1 / _parent.scaleX - 1), _parent.anchorPointInPixels.y * (1 / _parent.scaleY - 1)); } } else { pInParentAR -= _parent.anchorPointInPixels; } } Vector2 uPInParentAR = ccUtils.PixelsToUnits(pInParentAR); Vector3 pos = transform.localPosition; pos.x = uPInParentAR.x; pos.y = uPInParentAR.y; pos.z = 0; transform.localPosition = pos; //rotation Vector3 rotation = calculateRotation(); transform.localEulerAngles = Vector3.zero; transform.Rotate(rotation.x, 0, 0); transform.Rotate(0, rotation.y, 0); transform.Rotate(0, 0, rotation.z); //scale transform.localScale = new Vector3(Mathf.Abs(_scaleX), Mathf.Abs(_scaleY), transform.localScale.z); _isUpdateTransformDirty = false; } }
public override void updateTransform() { if (_isUpdateTransformDirty) { //position Vector2 pInParentAR = _position; if (_parent != null) { if (_parent.ignoreAnchorPointForPosition) { if (FloatUtils.NEQ(_parent.scaleX, 0) && FloatUtils.NEQ(_parent.scaleY, 0)) { pInParentAR += new Vector2(_parent.anchorPointInPixels.x * (1 / _parent.scaleX - 1), _parent.anchorPointInPixels.y * (1 / _parent.scaleY - 1)); } } else { pInParentAR -= _parent.anchorPointInPixels; } } Vector2 uPInParentAR = ccUtils.PixelsToUnits(pInParentAR); Vector3 pos = transform.localPosition; pos.x = uPInParentAR.x; pos.y = uPInParentAR.y; pos.z = _positionZ / UIWindow.PIXEL_PER_UNIT; transform.localPosition = pos; //rotation transform.localPosition = pos; transform.localEulerAngles = Vector3.zero; switch (_rotationSortingOrder) { case kRotationSortingOrder.XYZ: transform.Rotate(-_rotationX, 0, 0); transform.Rotate(0, -_rotationY, 0); transform.Rotate(0, 0, -_rotation); break; case kRotationSortingOrder.XZY: transform.Rotate(-_rotationX, 0, 0); transform.Rotate(0, 0, -_rotation); transform.Rotate(0, -_rotationY, 0); break; case kRotationSortingOrder.YXZ: transform.Rotate(0, -_rotationY, 0); transform.Rotate(-_rotationX, 0, 0); transform.Rotate(0, 0, -_rotation); break; case kRotationSortingOrder.YZX: transform.Rotate(0, -_rotationY, 0); transform.Rotate(0, 0, -_rotation); transform.Rotate(-_rotationX, 0, 0); break; case kRotationSortingOrder.ZXY: transform.Rotate(0, 0, -_rotation); transform.Rotate(-_rotationX, 0, 0); transform.Rotate(0, -_rotationY, 0); break; case kRotationSortingOrder.ZYX: transform.Rotate(0, 0, -_rotation); transform.Rotate(0, -_rotationY, 0); transform.Rotate(-_rotationX, 0, 0); break; } //scale transform.localScale = new Vector3(_scaleX, _scaleY, _scaleZ); _isUpdateTransformDirty = false; } }