56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using Assets.Scripts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
{
|
|
public class ReviewItemScript : MonoBehaviour
|
|
{
|
|
private RawImage Head;
|
|
private Text Name;
|
|
private Text Distance;
|
|
|
|
private void Awake()
|
|
{
|
|
Head = transform.Find("Head").GetComponent<RawImage>();
|
|
Name = transform.Find("Name").GetComponent<Text>();
|
|
Distance = transform.Find("Distance").GetComponent<Text>();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
|
|
}
|
|
public void SetName(string name)
|
|
{
|
|
Name.text = name;
|
|
}
|
|
|
|
public void SetHead(string url)
|
|
{
|
|
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;
|
|
}
|
|
|
|
public void SetDistance(double distance)
|
|
{
|
|
_distance = distance;
|
|
var prefix = distance > 0 ? "+" : "";
|
|
Distance.text = prefix + distance.ToString() + "M";
|
|
}
|
|
private double _distance;
|
|
public double GetDistance()
|
|
{
|
|
return _distance;
|
|
}
|
|
}
|
|
}
|