一開始按上一個時會直接消失,而安了下一個時可以按上一個(主要是實作不了回圈求大佬們解答

)
uj5u.com熱心網友回復:
比如索引0-2, 減到小于0:索引置為2,加到大于2:索引置為0 是這個意思吧?if("下一個"){
index = (index + 1) >= list.Count ? 0 : (index + 1);
}
if("上一個"){
index = (index - 1) < 0 ? (list.Count - 1) : (index - 1);
}
uj5u.com熱心網友回復:
對,我學的C#有點看不懂
uj5u.com熱心網友回復:
技術不過關
uj5u.com熱心網友回復:
樓主單純的技術不硬呀,C#也這么寫呀,通俗點就是:
if("下一個"){
index = (index + 1);
if(index >= list.Count)
{
index = 0;
}
}
if("上一個"){
index = (index - 1) ;
if(index < 0)
{
index = list.Count - 1;
}
}
uj5u.com熱心網友回復:
比如索引0-2, 減到小于0:索引置為2,加到大于2:索引置為0 是這個意思吧?
if("下一個"){
index = (index + 1) >= list.Count ? 0 : (index + 1);
}
if("上一個"){
index = (index - 1) < 0 ? (list.Count - 1) : (index - 1);
}
對,我學的C#有點看不懂
樓主單純的技術不硬呀,C#也這么寫呀,通俗點就是:
if("下一個"){
index = (index + 1);
if(index >= list.Count)
{
index = 0;
}
}
if("上一個"){
index = (index - 1) ;
if(index < 0)
{
index = list.Count - 1;
}
}
這種就明白了????新手我爭取多學點,老師不教這些,太難了
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/17346.html
標籤:Unity3D
