82 lines
2.1 KiB
C#
82 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Windows;
|
|
|
|
public class CustomItem : MonoBehaviour
|
|
{
|
|
public int id;
|
|
public Text textID;
|
|
public Slider sliderOne;
|
|
public Text m_input;
|
|
public CustomItemData data;
|
|
public string value;
|
|
private void Awake()
|
|
{
|
|
|
|
textID = gameObject.transform.GetChild(0).GetComponent<Text>();
|
|
sliderOne = gameObject.transform.GetChild(1).GetComponent<Slider>();
|
|
}
|
|
public void Init(CustomItemData _data, int _id)
|
|
{
|
|
data = _data;
|
|
id = _id;
|
|
sliderOne.value = _data.values[id - 1] / 1000f;
|
|
m_input.text = ((int)_data.values[id - 1]).ToString();
|
|
value = m_input.text;
|
|
textID.text = "ID: " + id;
|
|
CustomPanel.robot.GetComponent<Robot>().HVBUSSERVOs.Find(x => x.indexNo.Equals(id)).UpdateValue(int.Parse(value), 0);
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
sliderOne.onValueChanged.AddListener((x) =>
|
|
{
|
|
if (!CustomPanel.instance.isPlayAction)
|
|
{
|
|
m_input.text = ((int)(sliderOne.value * 1000)).ToString();
|
|
value = m_input.text;
|
|
CustomPanel.robot.GetComponent<Robot>().HVBUSSERVOs.Find(x => x.indexNo.Equals(id)).UpdateValue(int.Parse(value), 0);
|
|
}
|
|
|
|
});
|
|
}
|
|
public void IsActivation(bool flag)
|
|
{
|
|
if (flag)
|
|
{
|
|
sliderOne.interactable = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
sliderOne.interactable = false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ¸Ä¶¯»¬¶¯Ìõ
|
|
/// </summary>
|
|
/// <param name="ThousandNormalizedValue"></param>
|
|
/// <param name="_value"></param>
|
|
public void ValueChange(float ThousandNormalizedValue, int _value)
|
|
{
|
|
m_input.text = ((int)ThousandNormalizedValue).ToString();
|
|
sliderOne.value = _value / 1000f;
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|
|
public class CustomItemData
|
|
{
|
|
public int index;
|
|
public int time;
|
|
public List<int> values;
|
|
|
|
}
|