浏览器嵌入,国旗文件

This commit is contained in:
Caiyanpeng committed 2021-04-09 09:19:04 +08:00
1 parent e7a3214cb5
commit 07feba912c
552 files changed
+39279 -8128

No files matched your search

-86
View File
@@ -1,86 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;
public class ScrollTest2 : MonoBehaviour
{
// Start is called before the first frame update
private ScrollRect scroll;
private Transform content;
private float contentSize;
private int count;
[SerializeField] Button L, R;
void Start()
{
scroll = gameObject.GetComponent<ScrollRect>();
content = gameObject.transform.Find("Viewport").Find("Content");
count = content.childCount;
contentSize = 1f / (content.childCount - 2);
scroll.horizontalNormalizedPosition = contentSize / 2;
SetColor();
if (L != null)
{
L.onClick.AddListener(goLeft);
}
if (R != null)
{
R.onClick.AddListener(goRight);
}
}
void goLeft()
{
if (scroll.horizontalNormalizedPosition <= contentSize) return;
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = -1 * contentSize / 30;
}
void goRight()
{
if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = contentSize / 30;
}
private bool start = false, _lock = false;
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
void SetColor()
{
int index = (int)System.Math.Round(
(scroll.horizontalNormalizedPosition + (contentSize / 2)) / contentSize,
0);
for (int i = 1; i < content.childCount-1; i++)
{
string c = "#FFF";
if (i == index)
{
c = "#FF2742";
}
ColorUtility.TryParseHtmlString(c, out Color color);
content.GetChild(i).Find("Image").GetComponent<Image>().color = color;
}
}
// Update is called once per frame
void Update()
{
if (start)
{
totalScrollValue += scrollValue;
if (System.Math.Abs(totalScrollValue) >= contentSize)
{
scrollValue = 0;
start = false;
scroll.horizontalNormalizedPosition = startPosition + totalScrollValue;
//Debug.Log();
SetColor();
totalScrollValue = 0;
}
else
{
scroll.horizontalNormalizedPosition += scrollValue;
}
}
}
}
-11
View File
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: a77e784c857a15f4593d004821ce2757
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: