Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何统一显示player.transform.position?_C#_Unity3d - Fatal编程技术网

C# 如何统一显示player.transform.position?

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),

在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),
                                       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