## MisoStudio

13
Posts
12
Followers
25
Following
A member registered Mar 19, 2017 · View creator page →

### Recent community posts

It has  OnClick() event already

If I understand your question correctly, the button is being instantiated from a prefab, so you can modify the button prefab to suit your needs

Let me know if that's not the case

Thanks

It may take awhile before I upload a new version, but you can see from the screenshot where the _canvasRect is being referenced from

Thanks

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);
}
}
}
}```

while I am checking on this issue, I think one way you can do is to adjust the rect pos Z if you wanna make UI bigger/smaller

hi
Sorry I have been busy with other projects, and thus it may take me awhile to fix these.

But generally speaking, the scale needs to be included in every position update, I believe.

I will find time to update a new version.

Regards,

ok thanks for the screenshot, I will check

Is this the issue you are having?

Hi, in that case, I think you can  do this:

RectTransform _canvasRect;

m_final = new Vector3
(
m_final.x * _canvasRect.localScale.x,
m_final.y * _canvasRect.localScale.y,
m_final.z * _canvasRect.localScale.z
);

Hi, can you elaborate what you have done to cause this issue, thanks