I am new to Unity. My Unity version is 2022.3.21f1c1.
I have a class called CardData which is inherited from ScriptableObject:
public class CardData : ScriptableObject
{
public string id;
public string title;
// ... many other type of variables, including list, dict and objects of custom classes
}
And then I instantiate it using
CardData ref_card = card_list[0];
CardData card = UnityEngine.Object.Instantiate(ref_card);
if(card.title.Contains("test"))
{
Debug.Log($"ref_card.title = {ref_card.title}, ref_card = {ref_card}");
Debug.Log($"card.title = {card.title}, card = {card}");
}
In Editor mode, when I press Run, the log is
ref_card.title = test1, ref_card = test (TcgEngine.CardData)
card.title = test1, card = test(Clone) (TcgEngine.CardData)
But after I built the project, the log (enable Development Build and Player Log) is
ref_card.title = test1, ref_card = test (TcgEngine.CardData)
card.title = test1, card = null
The same code, without any modification, and test many times. Why the instantiated one is null in build mode?