powerfun-unity/Assets/Scenes/Ride/Scripts/SelectPlayerItemScript.cs

78 lines
2.1 KiB
C#
Raw Normal View History

2021-04-15 10:13:01 +08:00
using Assets.Cyp.Common;
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
namespace Assets.Scenes.Ride.Scripts
{
public class SelectPlayerItemScript:MonoBehaviour
{
private string Id ;
private RawImage Head;
private Text Name;
private Text Timer;
2021-04-25 13:33:43 +08:00
private Text WeightKg;
2021-04-15 10:13:01 +08:00
private Button selectbutton;
public bool isSelected;
private void Awake()
{
2021-04-25 13:33:43 +08:00
2021-04-15 10:13:01 +08:00
selectbutton = transform.GetComponent<Button>();
}
private void Start()
{
}
public string GetRankingId()
{
return Id;
}
public string GetName()
{
2021-04-25 13:33:43 +08:00
Name = transform.Find("Name").GetComponent<Text>();
2021-04-15 10:13:01 +08:00
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)
{
2021-04-25 13:33:43 +08:00
Name = transform.Find("Name").GetComponent<Text>();
2021-04-15 10:13:01 +08:00
Name.text = name;
}
public void SetTimer(string timer)
{
2021-04-25 13:33:43 +08:00
Timer = transform.Find("Timer").GetComponent<Text>();
2021-04-15 10:13:01 +08:00
Timer.text = timer;
}
2021-04-25 13:33:43 +08:00
public void SetWeightKg(string value)
{
WeightKg = transform.Find("WeightKg").GetComponent<Text>();
WeightKg.text = value+"W/KG";
}
2021-04-15 10:13:01 +08:00
public void SetHeadImage(string url)
{
2021-04-25 13:33:43 +08:00
Head = transform.Find("Head").GetComponent<RawImage>();
2021-04-15 10:13:01 +08:00
Utils.DisplayImage(StartCoroutine, Head, url);
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;
}
}
}