Quest Update
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChangeCharacterOnSelection : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
void Start(){
|
||||
CharacterSelection.OnCharacterChanged += RefreshCharacter;
|
||||
RefreshCharacter();
|
||||
}
|
||||
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
CharacterSelection.OnCharacterChanged -= RefreshCharacter;
|
||||
}
|
||||
|
||||
void RefreshCharacter(){
|
||||
if(CharacterSelection.selectedCharJson == null){return;}
|
||||
if(CharacterSelection.selectedCharJson.Length <= 0){return;}
|
||||
character.FromJson(CharacterSelection.selectedCharJson, true);
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChangeCharacterOnSelection : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
void Start(){
|
||||
CharacterSelection.OnCharacterChanged += RefreshCharacter;
|
||||
RefreshCharacter();
|
||||
}
|
||||
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
CharacterSelection.OnCharacterChanged -= RefreshCharacter;
|
||||
}
|
||||
|
||||
void RefreshCharacter(){
|
||||
if(CharacterSelection.selectedCharJson == null){return;}
|
||||
if(CharacterSelection.selectedCharJson.Length <= 0){return;}
|
||||
character.FromJson(CharacterSelection.selectedCharJson, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a01bf626125f48b38c14bb319871b4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 1a01bf626125f48b38c14bb319871b4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Firebase.Extensions;
|
||||
using Firebase.Firestore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterSelection : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] public static string selectedCharJson = "";
|
||||
public List<CharacterDataSO> predefinedCharacterJsons;
|
||||
public List<Button> predefinedCharacterButtons;
|
||||
|
||||
public static Action OnCharacterChanged;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < predefinedCharacterButtons.Count; i++)
|
||||
{
|
||||
int tempI = i;
|
||||
predefinedCharacterButtons[i].onClick.AddListener(() => { OnPredefinedCharButtonPress(tempI); });
|
||||
}
|
||||
LoadCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public void LoadCharacterFromString(string characterData)
|
||||
{
|
||||
selectedCharJson = characterData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPredefinedCharButtonPress(int i)
|
||||
{
|
||||
selectedCharJson = predefinedCharacterJsons[i].jsonCharData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
SaveCharacterSkinCloud();
|
||||
}
|
||||
|
||||
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>();
|
||||
skindataDictionary.Add("json", selectedCharJson);
|
||||
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
docRef.SetAsync(skindataDictionary).ContinueWithOnMainThread(task => {
|
||||
if(task.IsCompleted){
|
||||
Debug.Log("**** Save Completed Firestore ****");
|
||||
}
|
||||
else{
|
||||
Debug.Log("**** Failed to save data to firestore ****");
|
||||
}
|
||||
});
|
||||
|
||||
#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);
|
||||
docRef.GetSnapshotAsync().ContinueWithOnMainThread(task => {
|
||||
DocumentSnapshot snapshot = task.Result;
|
||||
if(snapshot.Exists){
|
||||
|
||||
LoadCharacterFromString(snapshot.GetValue<string>("json"));
|
||||
|
||||
}else{
|
||||
//show error previous data doesnt exists to load
|
||||
Debug.Log("**** No previous data to load ****");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Firebase.Extensions;
|
||||
using Firebase.Firestore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterSelection : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] public static string selectedCharJson = "";
|
||||
public List<CharacterDataSO> predefinedCharacterJsons;
|
||||
public List<Button> predefinedCharacterButtons;
|
||||
|
||||
public static Action OnCharacterChanged;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < predefinedCharacterButtons.Count; i++)
|
||||
{
|
||||
int tempI = i;
|
||||
predefinedCharacterButtons[i].onClick.AddListener(() => { OnPredefinedCharButtonPress(tempI); });
|
||||
}
|
||||
LoadCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public void LoadCharacterFromString(string characterData)
|
||||
{
|
||||
selectedCharJson = characterData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPredefinedCharButtonPress(int i)
|
||||
{
|
||||
selectedCharJson = predefinedCharacterJsons[i].jsonCharData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
SaveCharacterSkinCloud();
|
||||
}
|
||||
|
||||
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>();
|
||||
skindataDictionary.Add("json", selectedCharJson);
|
||||
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
docRef.SetAsync(skindataDictionary).ContinueWithOnMainThread(task => {
|
||||
if(task.IsCompleted){
|
||||
Debug.Log("**** Save Completed Firestore ****");
|
||||
}
|
||||
else{
|
||||
Debug.Log("**** Failed to save data to firestore ****");
|
||||
}
|
||||
});
|
||||
|
||||
#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);
|
||||
docRef.GetSnapshotAsync().ContinueWithOnMainThread(task => {
|
||||
DocumentSnapshot snapshot = task.Result;
|
||||
if(snapshot.Exists){
|
||||
|
||||
LoadCharacterFromString(snapshot.GetValue<string>("json"));
|
||||
|
||||
}else{
|
||||
//show error previous data doesnt exists to load
|
||||
Debug.Log("**** No previous data to load ****");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f46cf614fdb6e410695e435f02bfcd44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: f46cf614fdb6e410695e435f02bfcd44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
Reference in New Issue
Block a user