firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
819 stars 424 forks source link

[Question] Document.ConvertTo<T>() for Derived classes #1262

Closed TaejunPark closed 2 years ago

TaejunPark commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the question here:

Hello, Thank you for your time.

I am trying to use derived classes for Firestore Unity and got stuck. my code is like this:


[FirestoreData]
public class SchdeuleRecord
{
    [FirestoreProperty] public List<RoundRecord> RoundRecords { get; set; }
}

[FirestoreData]
public abstract class RoundRecord {}

[FirestoreData]
public class RoundRecordA : RoundRecord {}

[FirestoreData]
public class RoundRecordB : RoundRecord {}

When I: document.ConvertTo< SchdeuleRecord >() I seems not working. not giving any message at all. I guess it is because of my derived classes, as I tried this in other cases

is there any way I can convert RoundRecord to RoundRecordA & RoundRecordB , of List ?? if there were any overloading method on class creation, it would be great. I know Firebase is the one greatest tool for Unity

Thank you!

paulinon commented 2 years ago

Hi @TaejunPark,

Could you provide the full sample code along with sample Cloud Firestore data so that we can identify what's causing this behavior?

google-oss-bot commented 2 years ago

Hey @TaejunPark. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

TaejunPark commented 2 years ago

Thank you for your time @paulinon .

My problem was approximately like this (same question for android) : https://stackoverflow.com/a/54225186/2017508

from there someone from google cloud says , "you can not have an interface or abstract class participate in object mapping serialization" and suggested "Maps and Lists as needed to represent your data" I would do that.

Have a good day all 👋👋