65 lines
1.6 KiB
C#
65 lines
1.6 KiB
C#
using Mirror;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class modSelector : MonoBehaviour
|
|
{
|
|
public Image Bg;
|
|
public RectTransform[] mod_images;
|
|
Vector2 defaultSize;
|
|
public GameObject[] descriptions;
|
|
[Scene]
|
|
public string[] scenes;
|
|
public int currentSelectedId = 0;
|
|
public AudioClip selectionSfx;
|
|
|
|
void Start()
|
|
{
|
|
if (mod_images.Length != descriptions.Length)
|
|
{
|
|
Debug.LogError("WHAT THE FUCK ARE YOU DOING");
|
|
}
|
|
defaultSize = mod_images[0].sizeDelta;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
for (int i = 0; i < mod_images.Length; i++)
|
|
{
|
|
if(i == currentSelectedId)
|
|
{
|
|
mod_images[i].sizeDelta = Vector2.Lerp(mod_images[i].sizeDelta, defaultSize * 1.5f, 0.1f);
|
|
descriptions[i].SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
mod_images[i].sizeDelta = Vector2.Lerp(mod_images[i].sizeDelta, defaultSize, 0.1f);
|
|
descriptions[i].SetActive(false);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void OnPointerEnter(int value)
|
|
{
|
|
currentSelectedId = value;
|
|
FindObjectOfType<loadingScreen>().setScene(scenes[value]);
|
|
Bg.sprite = mod_images[value].GetComponent<Image>().sprite;
|
|
playSelectedSound();
|
|
}
|
|
public void OnPointerExit()
|
|
{
|
|
//currentSelectedId = -1;
|
|
}
|
|
|
|
public void playSelectedSound()
|
|
{
|
|
GetComponent<AudioSource>().PlayOneShot(selectionSfx);
|
|
}
|
|
}
|