You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
74 lines
1.9 KiB
using DG.Tweening;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LookImg : MonoBehaviour
|
|
{
|
|
public Sprite[] sprites;
|
|
int curImgIndex = 0;
|
|
public Transform imgtip;
|
|
public Button up;
|
|
public Button down;
|
|
bool initEnd=false;
|
|
void Start() {
|
|
up.onClick.AddListener(() => {
|
|
if (curImgIndex <= 0)
|
|
{
|
|
curImgIndex = sprites.Length - 1;
|
|
}
|
|
else {
|
|
curImgIndex--;
|
|
}
|
|
ChangeTip(curImgIndex);
|
|
});
|
|
down.onClick.AddListener(() => {
|
|
if (curImgIndex >= sprites.Length - 1)
|
|
{
|
|
curImgIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
curImgIndex++;
|
|
}
|
|
ChangeTip(curImgIndex);
|
|
});
|
|
|
|
}
|
|
|
|
void Update() {
|
|
if (!initEnd) return;
|
|
GetComponent<Image>().sprite = sprites[curImgIndex];
|
|
imgtip.GetChild(curImgIndex).gameObject.SetActive(true);
|
|
}
|
|
|
|
void ChangeTip(int index) {
|
|
for (int i=0;i<imgtip.childCount;i++) {
|
|
if (i == index)
|
|
{
|
|
imgtip.GetChild(i).gameObject.SetActive(true);
|
|
}
|
|
else {
|
|
imgtip.GetChild(i).gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
public void ChangeWAH(float x,float y,float z) {
|
|
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("changeImg")) {
|
|
float width = -0.3f + ((x / 1 + y / 6 + z / 10) / 3) * 0.6f +1;
|
|
float height = -0.3f + ((x / 1 + y / 6 + z / 10) / 3) * 0.6f + 1;
|
|
obj.GetComponent<RectTransform>().localScale = new Vector2(width, height);
|
|
}
|
|
for (int i = 0; i < imgtip.childCount; i++)
|
|
{
|
|
imgtip.GetChild(i).gameObject.SetActive(false);
|
|
}
|
|
|
|
initEnd = true;
|
|
}
|
|
|
|
}
|