114 lines
3.4 KiB
C#
114 lines
3.4 KiB
C#
using Assets.Scripts;
|
|
using DG.Tweening;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.Networking;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
{
|
|
public class SelectPlayerItemScript:MonoBehaviour, IPointerExitHandler, IPointerEnterHandler, IPointerUpHandler
|
|
{
|
|
private string Id ;
|
|
private RawImage Head;
|
|
private Text Name;
|
|
private Text Timer;
|
|
private Text WeightKg;
|
|
private Button selectbutton;
|
|
public bool isSelected;
|
|
private void Awake()
|
|
{
|
|
selectbutton = transform.GetComponent<Button>();
|
|
}
|
|
private void Start()
|
|
{
|
|
|
|
}
|
|
public string GetRankingId()
|
|
{
|
|
return Id;
|
|
}
|
|
public string GetName()
|
|
{
|
|
Name = transform.Find("Name").GetComponent<Text>();
|
|
return Name.text;
|
|
}
|
|
public Texture GetImageTexture()
|
|
{
|
|
return Head.texture;
|
|
}
|
|
public Button GetButton()
|
|
{
|
|
return selectbutton;
|
|
}
|
|
public void SetRankingId(string id)
|
|
{
|
|
Id = id;
|
|
}
|
|
public void SetName(string name)
|
|
{
|
|
Name = transform.Find("Name").GetComponent<Text>();
|
|
Name.text = name;
|
|
}
|
|
public void SetTimer(string timer)
|
|
{
|
|
Timer = transform.Find("Timer").GetComponent<Text>();
|
|
Timer.text = timer;
|
|
}
|
|
|
|
public void SetWeightKg(string value)
|
|
{
|
|
WeightKg = transform.Find("WeightKg").GetComponent<Text>();
|
|
WeightKg.text = value+"W/KG";
|
|
}
|
|
public void SetHeadImage(string url)
|
|
{
|
|
Head = transform.Find("Head").GetComponent<RawImage>();
|
|
//if (App.TextureCache.ContainsKey(url))
|
|
//{
|
|
// Head.texture = App.TextureCache[url];
|
|
//}
|
|
//else
|
|
//{
|
|
Utils.DisplayImage(Head, url, true);
|
|
//}
|
|
|
|
var rect = ((RectTransform)Head.transform).rect;
|
|
Material material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
|
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
|
Head.material = material;
|
|
}
|
|
|
|
private void ImageCallBack(string url)
|
|
{
|
|
if (!App.TextureCache.ContainsKey(url))
|
|
App.TextureCache.Add(url, Head.texture);
|
|
}
|
|
float? localY = null;
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
//if (localY != null)
|
|
//{
|
|
// transform.DOLocalMoveY(localY.Value, 0.3f);
|
|
//}
|
|
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
//if (localY == null)
|
|
//{
|
|
// localY = transform.localPosition.y;
|
|
//}
|
|
//transform.DOLocalMoveY(localY.Value + 5, 0.3f);
|
|
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
|
|
}
|
|
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
{
|
|
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
|
}
|
|
}
|
|
}
|