never mind, I unchecked indexes in texture pack setting options and it works
MisoStudio
16
Posts
12
Followers
27
Following
A member registered Mar 19, 2017 · View creator page →
Creator of
Recent community posts
Stickman Fighter Spine 2D Character Sprites comments · Replied to MisoStudio in Stickman Fighter Spine 2D Character Sprites comments
Stickman Fighter Spine 2D Character Sprites comments · Posted in Stickman Fighter Spine 2D Character Sprites comments
Stickman Fighter Spine 2D Character Sprites comments · Posted in Stickman Fighter Spine 2D Character Sprites comments
Try this: The code is not properly formatted, but you can search for _canvasRect.localScale.
only 3 parts are modified to make the logic work in different canvas scale
Let me know if you still have any issues
Thanks
void SetupCells(bool instantUpdate) { for (int i = 0; i < m_cellContainer.Count; i++) { RectTransform rt = m_cellContainer[i].GetComponent<recttransform>(); if (rt == null) continue; m_newPos = Vector3.zero; m_newScale = new Vector3(1, 1, 1); m_newRot = Vector3.zero; m_offset = (_panel.position - m_dragStartPos); m_offsetIndex = i - m_centerCellIndex; m_isCircularMovment = false; // Consider the canvas scale m_width = (rt.rect.width + _cellGap) * _canvasRect.localScale.x; switch (_carouselType) { case CarouselConstants.iCarouselType.iCarouselTypeLinear: { m_newPos.x = m_width * m_offsetIndex; } break; case CarouselConstants.iCarouselType.iCarouselTypeScaledLinear: { m_newPos.x = m_width * m_offsetIndex; float dis = Vector3.Distance(rt.position, _center.position); // Make sure it is not too small nor not too big float scaleRatio = Mathf.Clamp(1 - Mathf.Abs(dis / (_scrollRT.rect.width / 2)), 0.1f, 100); m_newScale = new Vector3(scaleRatio * _scaleRatio.x, scaleRatio * _scaleRatio.y, scaleRatio * _scaleRatio.z); } break; case CarouselConstants.iCarouselType.iCarouselTypeCoverFlow: { m_newPos.x = m_width * m_offsetIndex; if (m_offsetIndex < 0) { m_newRot = -_coverflowAngles; } else if (m_offsetIndex > 0) { m_newRot = _coverflowAngles; } } break; case CarouselConstants.iCarouselType.iCarouselTypeScaledCoverFlow: { m_newPos.x = m_width * m_offsetIndex; float dis = Vector3.Distance(rt.position, _center.position); // Make sure it is not too small nor not too big float scaleRatio = Mathf.Clamp(1 - Mathf.Abs(dis / (_scrollRT.rect.width / 2)), 0.1f, 100); m_newScale = new Vector3(scaleRatio * _scaleRatio.x, scaleRatio * _scaleRatio.y, scaleRatio * _scaleRatio.z); if (m_offsetIndex < 0) { m_newRot = -_coverflowAngles; } else if (m_offsetIndex > 0) { m_newRot = _coverflowAngles; } } break; } // Only allow one direction at a time if (!_isHorizontal) { m_newPos.y = m_newPos.x; m_newPos.x = 0; m_newRot.x = m_newRot.y; m_newRot.y = 0; } m_final = (_center.position + m_newPos + m_offset); if (instantUpdate || m_isCircularMovment) { rt.position = m_final; rt.localScale = m_newScale; rt.localRotation = Quaternion.Euler(m_newRot); _panel.ForceUpdateRectTransforms(); } else { rt.position = Vector3.Lerp(rt.position, m_final, Time.deltaTime * _moveSpeed); rt.localScale = Vector3.Lerp(rt.localScale, m_newScale, Time.deltaTime * _scaleSpeed); rt.localRotation = Quaternion.Lerp(rt.localRotation, Quaternion.Euler(m_newRot), Time.deltaTime * _rotateSpeed); } } } void CheckBoundary() { if (_cell == null) return; if (!_shouldLoop) return; if (m_cellContainer.Count == 0) return; RectTransform rt = _cell.GetComponent<recttransform>(); if (rt == null) return; float cellWidth = (rt.rect.width + _cellGap) * _canvasRect.localScale.x; float cellHeight = (rt.rect.height + _cellGap) * _canvasRect.localScale.y; // Calculate the boundaries m_boundary.x = m_cellContainer.Count * cellWidth; m_boundary.y = m_cellContainer.Count * cellHeight; float leftBoundary = (_center.position.x - m_boundary.x / 2); float rightBoundary = (_center.position.x + m_boundary.x / 2); float upBoundary = (_center.position.y + m_boundary.y / 2); float downBoundary = (_center.position.y - m_boundary.y / 2); // We only check the right most or left most if (_isHorizontal) { //if ((_panel.position - m_dragDir).x < 0) { GameObject go = m_cellContainer[0]; if (go.transform.position.x < leftBoundary) { //Debug.Log("left"); UpdateBoundaryCell(go, new Vector3(rightBoundary, go.transform.position.y, go.transform.position.z), false); } } //else if ((_panel.position - m_dragDir).x > 0) { GameObject go = m_cellContainer[m_cellContainer.Count - 1]; if (go.transform.position.x > rightBoundary) { //Debug.Log("right"); UpdateBoundaryCell(go, new Vector3(leftBoundary, go.transform.position.y, go.transform.position.z), true); } } } else { //if ((_panel.position - m_dragDir).y < 0) { GameObject go = m_cellContainer[0]; if (go.transform.position.y < downBoundary) { //Debug.Log("down"); UpdateBoundaryCell(go, new Vector3(go.transform.position.x, upBoundary, go.transform.position.z), false); } } //else if ((_panel.position - m_dragDir).y > 0) { GameObject go = m_cellContainer[m_cellContainer.Count - 1]; if (go.transform.position.y > upBoundary) { //Debug.Log("up"); UpdateBoundaryCell(go, new Vector3(go.transform.position.x, downBoundary, go.transform.position.z), true); } } } }