修改细节
This commit is contained in:
1 parent
b93fbd2f2e
commit
929fb0a1a7
15 files changed
+1093
-107
No files matched your search
@@ -91,12 +91,24 @@ public class RaceHomeScript : RaceScript
|
||||
game.transform.SetParent(rightContainer.Find("Container-2"));
|
||||
game.transform.localScale = Vector3.one;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < activityList.Count; i++)
|
||||
{
|
||||
var activity = activityList[i];
|
||||
var banner = Instantiate<GameObject>(bannerItem);
|
||||
var dot = Instantiate<GameObject>(dotItem);
|
||||
Utils.DisplayImage(banner.GetComponent<RawImage>(), activity.BannerPreview, true);
|
||||
//if (i == 0)
|
||||
//{
|
||||
// banner.GetComponent<RawImage>().color = Utils.HexToColorHtml("#ff0000");
|
||||
//}
|
||||
//else if (i == 1)
|
||||
//{
|
||||
// banner.GetComponent<RawImage>().color = Utils.HexToColorHtml("#00ff00");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// banner.GetComponent<RawImage>().color = Utils.HexToColorHtml("#0000ff");
|
||||
//}
|
||||
|
||||
UIManager.AddEvent(banner.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
@@ -138,16 +150,15 @@ public class RaceHomeScript : RaceScript
|
||||
void goLeft()
|
||||
{
|
||||
Debug.Log($"{scroll.horizontalNormalizedPosition}");
|
||||
if (scroll.horizontalNormalizedPosition<=0.0001) return;
|
||||
goMove(-1);
|
||||
if (scroll.horizontalNormalizedPosition <= 0.0001) goMoveEnd(1- scroll.horizontalNormalizedPosition);
|
||||
else goMove(-1);
|
||||
}
|
||||
void goRight()
|
||||
{
|
||||
|
||||
if (scroll.horizontalNormalizedPosition >= 0.9999) return;
|
||||
if (scroll.horizontalNormalizedPosition >= 0.9999) goMoveEnd(0 - scroll.horizontalNormalizedPosition);
|
||||
//if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
|
||||
|
||||
goMove();
|
||||
else goMove();
|
||||
}
|
||||
void goMove(int i = 1)
|
||||
{
|
||||
@@ -156,8 +167,20 @@ public class RaceHomeScript : RaceScript
|
||||
start = true;
|
||||
scrollValue = i * contentSize / 20;
|
||||
}
|
||||
void goMoveEnd(float pos)
|
||||
{
|
||||
//doAni();
|
||||
if (!startMoveEnd) startPosition = scroll.horizontalNormalizedPosition;
|
||||
totalScrollValue = 0;
|
||||
moveEndValue = pos;
|
||||
scrollValue = pos / 20;
|
||||
startMoveEnd = true;
|
||||
|
||||
}
|
||||
private bool start = false;
|
||||
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
|
||||
bool startMoveEnd = false;
|
||||
float moveEndValue = 0;
|
||||
// Update is called once per frame
|
||||
private void FixedUpdate()
|
||||
{
|
||||
@@ -177,8 +200,23 @@ public class RaceHomeScript : RaceScript
|
||||
totalScrollValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startMoveEnd)
|
||||
{
|
||||
scroll.horizontalNormalizedPosition += scrollValue;
|
||||
totalScrollValue += scrollValue;
|
||||
if (System.Math.Abs(totalScrollValue) >= System.Math.Abs(moveEndValue))
|
||||
{
|
||||
scrollValue = 0;
|
||||
startMoveEnd = false;
|
||||
scroll.horizontalNormalizedPosition = startPosition + moveEndValue;
|
||||
handleDotListMoveEnd(totalScrollValue);
|
||||
|
||||
Debug.Log(scrollIndex);
|
||||
//Debug.Log();
|
||||
totalScrollValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void handleDotList(float totalScrollValue)
|
||||
{
|
||||
scrollIndex = ((scrollIndex + content.childCount) + (totalScrollValue < 0 ? -1 : 1)) % content.childCount;
|
||||
@@ -195,7 +233,22 @@ public class RaceHomeScript : RaceScript
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleDotListMoveEnd(float totalScrollValue)
|
||||
{
|
||||
var dotList = scroll.transform.Find("DotList");
|
||||
scrollIndex = totalScrollValue < 0 ? 0 : dotList.childCount - 1;
|
||||
for (int i = 0; i < dotList.childCount; i++)
|
||||
{
|
||||
if (i == scrollIndex)
|
||||
{
|
||||
dotList.GetChild(i).GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
|
||||
}
|
||||
else
|
||||
{
|
||||
dotList.GetChild(i).GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
}
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
Reference in new issue
Block a user