using Proyecto26;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class firebaseTEST : MonoBehaviour {
static string DB_URL = ""; // url deleted only now for security in my code exists
Coach coach = new Coach("coachP", "goalkeeperK", 10);
// Use this for initialization
void Start () {
OnSubmit();
}
void OnSubmit()
{
//PostToDatabase(); // i can Post
RetrieveFromDatabase(); // i have a runtime red warning
}
private void PostToDatabase()
{
int[] stats = new int[] { 5, 10, 3 };
Coach coach = new Coach("coachP", "goalkeeperK", 50);
Goalkeeper goalkeeper = new Goalkeeper("goalkeeperK", 15);
RestClient.Post(DB_URL + coach.coachName + ".json", goalkeeper);
}
private void RetrieveFromDatabase()
{
RestClient.Get<Goalkeeper>(DB_URL + "goalkeeperK" + ".json").Then(response =>
{
coach.goalkeeper= response;
Debug.Log(coach.goalkeeper); //this line not printed in console
});
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class Goalkeeper{
public string keeperName;
public int Totalstats;
public Goalkeeper(string keeperName, int Totalstats)
{
this.keeperName = keeperName;
this.Totalstats = Totalstats;
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class Coach {
public string coachName;
public Goalkeeper goalkeeper;
public Coach(string coachName, string keeperName, int Totalstats)
{
this.coachName = coachName;
goalkeeper = new Goalkeeper(keeperName, Totalstats);
}
}