C# 如何统一显示player.transform.position?
在Unity3d上的游戏中,我处理保存/加载游戏,我想显示C# 如何统一显示player.transform.position?,c#,unity3d,C#,Unity3d,在Unity3d上的游戏中,我处理保存/加载游戏,我想显示player.transform.position,但它总是显示0,0,0。不明白为什么 加载数据 Debug.Log("transform before: " + transform.position); // all time 0,0,0 playerTransform.position = new Vector3(PlayerPrefs.GetFloat("x" + currentActiveSlot),
player.transform.position
,但它总是显示0,0,0
。不明白为什么
加载数据
Debug.Log("transform before: " + transform.position); // all time 0,0,0
playerTransform.position = new Vector3(PlayerPrefs.GetFloat("x" + currentActiveSlot),
PlayerPrefs.GetFloat("y" + currentActiveSlot),
PlayerPrefs.GetFloat("z" + currentActiveSlot));
Debug.Log("transform after: " + transform.position); // all time 0,0,0
Debug.Log("transform before: " + transform.position); // all time 0,0,0
transform.position = new Vector3(PlayerPrefs.GetFloat("x" + currentActiveSlot),
PlayerPrefs.GetFloat("y" + currentActiveSlot),
PlayerPrefs.GetFloat("z" + currentActiveSlot));
Debug.Log("transform after: " + transform.position); // all time 0,0,0
您正在显示transform.position,它未在任何位置设置 加载数据
Debug.Log("transform before: " + transform.position); // all time 0,0,0
playerTransform.position = new Vector3(PlayerPrefs.GetFloat("x" + currentActiveSlot),
PlayerPrefs.GetFloat("y" + currentActiveSlot),
PlayerPrefs.GetFloat("z" + currentActiveSlot));
Debug.Log("transform after: " + transform.position); // all time 0,0,0
Debug.Log("transform before: " + transform.position); // all time 0,0,0
transform.position = new Vector3(PlayerPrefs.GetFloat("x" + currentActiveSlot),
PlayerPrefs.GetFloat("y" + currentActiveSlot),
PlayerPrefs.GetFloat("z" + currentActiveSlot));
Debug.Log("transform after: " + transform.position); // all time 0,0,0
或
Debug.Log("transform before: " + playerTransform.position); // all time 0,0,0
playerTransform.position = new Vector3(PlayerPrefs.GetFloat("x" + currentActiveSlot),
PlayerPrefs.GetFloat("y" + currentActiveSlot),
PlayerPrefs.GetFloat("z" + currentActiveSlot));
Debug.Log("transform after: " + playerTransform.position); // all time 0,0,0