[英]Apply coordinates after scene restart in hololens
I have the following setup right now: 我现在有以下设置:
Once the users interacts with the program the scene restarts at some point, then the following should happen: 用户与程序交互后,场景将在某个时间点重新开始,然后将发生以下情况:
Code: 码:
DataPositionStorer positionStorer = new GameObject("DataPositionStorer").AddComponent<DataPositionStorer>();
DontDestroyOnLoad(positionStorer.gameObject);
// dataPoints is the specific object I need to keep the coordinates of
positionStorer.Position = dataPoints.transform.position;
positionStorer.Rotation = dataPoints.transform.rotation;
positionStorer.Zoom = dataPoints.transform.localScale;
// Reload current scene ("Main")
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
And in the startup method of the object: 并在对象的启动方法中:
DataPositionStorer positionStorer = FindObjectOfType<DataPositionStorer>();
if (positionStorer!= null)
{
dataPoints.transform.position = positionStorer.Position;
dataPoints.transform.localRotation = positionStorer.Rotation;
dataPoints.transform.localScale = positionStorer.Zoom;
}
This setup works in the unity player but once I run it in the hololens emulator / on a hololens the position afterwards isn't correct anymore. 此设置可在统一播放器中使用,但是一旦我在hololens仿真器中/在hololens上运行它,此后的位置就不再正确了。
Can somebody help me resolve this problem on the emulator / hololens? 有人可以帮助我解决模拟器/ Hololens上的此问题吗?
Thanks to the two guys commenting I've found a solution: 感谢两个人的评论,我找到了一个解决方案:
This however only works on the emulator / HoloLens itself. 但是,这仅适用于仿真器/ HoloLens本身。 In the Unity Editor World Anchors don't work!
在Unity编辑器中,世界锚不起作用! So just copy paste the coordinates over like I did in my initial post.
因此,只需像我在初始帖子中那样复制坐标即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.