1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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;
- NetworkManager.singleton.onlineScene = scenes[value];
- Bg.sprite = mod_images[value].GetComponent<Image>().sprite;
- GetComponent<AudioSource>().PlayOneShot(selectionSfx);
- }
- public void OnPointerExit()
- {
- //currentSelectedId = -1;
- }
- }
|