【发布时间】:2019-02-12 05:49:22
【问题描述】:
游戏对象(聚光灯)没有响应 UI(文本)
我的意图是使用rest api从firebase中获取值并根据值闪烁灯,问题在于它非常正确地获取值但我无法连接到游戏对象
例如:
在火力基地下 值:75(键值对)
它被正确获取,但根据值它没有改变颜色
using UnityEngine;
using UnityEngine.UI;
using Proyecto26;
public class valuesRetrieve : MonoBehaviour
{
int l;
Color color0 = Color.red;
Color color1 = Color.green;
Light lt;
public Text displayName;
public InputField nameText;
public static string name;
public Text valueText;
public static int store_values;
User user = new User();
void Start()
{
onSubmit();
//l = liver(l);
//lt = GetComponent<Light>();
}
public void onSubmit()
{
RetrieveFromDatabase();
}
private void RetrieveFromDatabase()
{
RestClient.Get<User>("https://feelsmart-******.firebaseio.com/" + nameText.text + ".json").Then(response =>
{
user = response;
UpdateValues();
});
}
public void UpdateValues()
{
valueText.text = "store value is " + user.StoreValues;
lt = GetComponent<Light>();
//user.StoreValues = 75;
if (user.StoreValues < 72 || user.StoreValues > 80)
{
lt.color = color0;
}
else
{
lt.color = color1;
}
}
我希望颜色会改变
【问题讨论】:
标签: c# visual-studio firebase unity3d