Skin network sync, new server build
This commit is contained in:
@@ -18,6 +18,7 @@ public class ChangeCharacterOnSelection : MonoBehaviour
|
||||
}
|
||||
|
||||
void RefreshCharacter(){
|
||||
if(CharacterSelection.selectedCharJson == null){return;}
|
||||
if(CharacterSelection.selectedCharJson.Length <= 0){return;}
|
||||
character.FromJson(CharacterSelection.selectedCharJson, true);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Firebase.Extensions;
|
||||
using Firebase.Firestore;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterSelection : MonoBehaviour
|
||||
{
|
||||
|
||||
public static string selectedCharJson;
|
||||
public static string selectedCharJson = "";
|
||||
public List<string> predefinedCharacterJsons;
|
||||
public List<Button> predefinedCharacterButtons;
|
||||
|
||||
@@ -19,30 +17,33 @@ public class CharacterSelection : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
for(int i=0; i < predefinedCharacterButtons.Count; i++){
|
||||
for (int i = 0; i < predefinedCharacterButtons.Count; i++)
|
||||
{
|
||||
int tempI = i;
|
||||
predefinedCharacterButtons[i].onClick.AddListener(()=>{OnPredefinedCharButtonPress(tempI);});
|
||||
predefinedCharacterButtons[i].onClick.AddListener(() => { OnPredefinedCharButtonPress(tempI); });
|
||||
}
|
||||
LoadCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public void LoadCharacterFromString(string characterData){
|
||||
public void LoadCharacterFromString(string characterData)
|
||||
{
|
||||
selectedCharJson = characterData;
|
||||
OnCharacterChanged.Invoke();
|
||||
}
|
||||
|
||||
void OnPredefinedCharButtonPress(int i){
|
||||
void OnPredefinedCharButtonPress(int i)
|
||||
{
|
||||
selectedCharJson = predefinedCharacterJsons[i];
|
||||
OnCharacterChanged.Invoke();
|
||||
SaveCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public static void SaveCharacterSkinCloud(){
|
||||
#if UNITY_EDITOR
|
||||
PlayerPrefs.SetString("skinData", selectedCharJson);
|
||||
PlayerPrefs.Save();
|
||||
#endif
|
||||
|
||||
public static void SaveCharacterSkinCloud()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
PlayerPrefs.SetString("skinData", selectedCharJson);
|
||||
PlayerPrefs.Save();
|
||||
#else
|
||||
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
|
||||
|
||||
Dictionary<string,object> skindataDictionary = new Dictionary<string, object>();
|
||||
@@ -58,16 +59,18 @@ public class CharacterSelection : MonoBehaviour
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void LoadCharacterSkinCloud(){
|
||||
#if UNITY_EDITOR
|
||||
if(PlayerPrefs.HasKey("skinData")){
|
||||
LoadCharacterFromString(PlayerPrefs.GetString("skinData"));
|
||||
}
|
||||
#endif
|
||||
void LoadCharacterSkinCloud()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (PlayerPrefs.HasKey("skinData"))
|
||||
{
|
||||
LoadCharacterFromString(PlayerPrefs.GetString("skinData"));
|
||||
}
|
||||
#else
|
||||
|
||||
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
@@ -84,6 +87,8 @@ public class CharacterSelection : MonoBehaviour
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user