LoopScrollRect icon indicating copy to clipboard operation
LoopScrollRect copied to clipboard

請問有 SrollToCell 跟 SrollToCellWithinTime 移動完成的判斷方法嗎?

Open SyaoranChang opened this issue 2 years ago • 1 comments

你好,

請問有 SrollToCell 跟 SrollToCellWithinTime 移動完成的判斷方法嗎?

1.我原本的寫法是用 yield return 去等 GetFirstItem() 回傳是否為已經移動到指定的Index 但是剛剛測試會一直卡在無法成立所以無法往下執行

2.然後 我想要進去 GetFirstItem() 看程式碼是哪邊判斷有問題 結果發現 我用 OpenUPM 安裝插件的方式,底層程式碼會有看不到原始碼的問題 不知道跟 LoopScrollRect.Runtime.asmdef 這個有沒有關係?

我的程式碼大概是這樣 int FindIndex = 1; m_InitOnStart.m_LoopScrollRect.SrollToCellWithinTime(FindIndex, 0.1f); float offset = 0; yield return new WaitWhile(() => m_InitOnStart.m_LoopScrollRect.GetFirstItem(out offset) != FindIndex);

SyaoranChang avatar Apr 27 '22 03:04 SyaoranChang

这个需求我其实建议直接修改ScrollToCellCoroutine额外暴露一个回调好了

public void SrollToCellWithinTime(int index, float time, System.Action callback = null)
{
     // ...
    StartCoroutine(ScrollToCellCoroutine(index, Mathf.Abs(dist) / time, callback));
}

IEnumerator ScrollToCellCoroutine(int index, float speed, System.Action callback)
{
    // ...
   StopMovement();
   UpdatePrevData();
   if (callback != null) callback();
}

如果是upm方式没有源代码,可以看下生成VS工程的地方是不是漏了 image

qiankanglai avatar May 05 '22 12:05 qiankanglai