当前位置:网站首页>Unity编辑器随机生成物体,更换场景之后物体丢失问题解决
Unity编辑器随机生成物体,更换场景之后物体丢失问题解决
2022-06-30 00:57:00 【每天死循环】
前言:
obj= (GameObject) PrefabUtility.InstantiatePrefab(configData.bigMainScene);我在编辑器开发的时候实例化预制体到场景中之后,在跳转场景之后,然后在返回实例化过物体的场景会导致之前我们创建的物体会丢失,这种情况!很坑,因为也不会提示未保存场景之类的,在这里记录下问题解决办法
解决:
我这也不算完全解决把,只不过这个方法会跟咱们右键创建物体的时候是一个道理,让Unity重新给咱们保存一下,记录到撤销数据里面,这样就解决了,代码如下,主要是用到了PrefabUtility .UnpackPrefabInstance()这个方法。
详情请看API
Unity - Scripting API: PrefabUtility.UnpackPrefabInstance
obj = (GameObject) PrefabUtility.InstantiatePrefab(configData.smallMainScene);
PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.OutermostRoot, InteractionMode.UserAction);边栏推荐
- Nested call and chained access of functions in handwritten C language
- Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture
- [MySQL basic] general syntax 2
- Analysis of IM instant messaging development technology on modern web
- Time does not spare
- 传统微服务框架如何无缝过渡到服务网格 ASM
- SFDP super form development platform v6.0.4 was officially released
- 视频转图像-cv2.VideoCapture()用法
- 【mysql篇-基础篇】通用语法2
- 字符串之间的比较之 localeCompare
猜你喜欢

如何查看一个文件夹下所有文件的大小?

If the amount exceeds 6 digits after the decimal point, only 6 digits will be reserved, and if it is less than 6 digits, it will remain the same - Basic accumulation

Crmeb SMS for program configuration of knowledge payment system

Antd - tree structure: default deployment node attribute failure - Basic promotion

How latex enters a matrix

简单的页面

Bytek suffered a disastrous defeat in the interview: he was hanged on one side, but fortunately Huawei pushed him in, and he got an offer on three sides

赛芯电子冲刺科创板上市:拟募资6.23亿元,共有64项专利申请信息
![[concurrent programming] if you use channel to solve concurrency problems?](/img/6c/76bcc9b63117bda57937a49cfd8696.jpg)
[concurrent programming] if you use channel to solve concurrency problems?

在线SQL转CSV工具
随机推荐
Small and medium-sized enterprises should pay attention to these points when signing ERP contracts
[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network
简单的页面
Go 中的 UDP 服务器和客户端
Birds in the corn field
PHP wechat merchant transfer to change initiating merchant transfer API
Arlo felt lost
如何在IDEA中创建Module、以及怎样在IDEA中删除Module?
降低打新的预期
我,33岁,字节跳动测试开发,揭开北京“测试岗”的真实收入
2022年最新最详细IDEA关联数据库方式、在IDEA中进行数据库的可视化操作(包含图解过程)
Which department should the company's fixed assets be managed? How should the company's fixed assets be managed
I / o initial et son fonctionnement de base
Common interview questions for network workers: Telnet, TTL, router and switch
Ml: introduction to confidence interval (the difference and relationship between precision / accuracy / accuracy), use method, and detailed introduction to case application
[mrctf2020]ezpop-1 | PHP serialization
Outsourcing for 3 years is a waste
清洁、对话、带娃,扫地机摆脱“人工智障”标签
字符串之间的比较之 localeCompare
视频转图像-cv2.VideoCapture()用法