我想知道......在Unity游戏中保存数据的最佳方法是什么.JSONs?如果是这样,怎么样?谢谢
我正在编写一个方法来检查gameObject是否有一个组件.
这里是:
public static bool HasComponent <T>(this GameObject obj)
{
return obj.GetComponent<T>() != null;
}
Run Code Online (Sandbox Code Playgroud)
而我正在使用它:
void Update()
{
if (Input.GetKey("w"))
{
if (gameObject.HasComponent<Rigidbody>())
{
print("Has a rigid body.");
return;
}
print("Does not have rigid body.");
}
}
Run Code Online (Sandbox Code Playgroud)
gameObject没有刚体,但它仍然打印它确实有.