当前位置:网站首页>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);边栏推荐
- Time does not spare
- Briefly: how are fragments communicated?
- Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
- After the element uses align items center and overflow auto, some contents are not fully displayed
- Experience of C language course design: open source sharing of "push box" course design works
- [deep learning compilation] operator compilation IR conversion
- [qnx hypervisor 2.2 user manual]6.2.2 communication between guest and host
- 如何查看一个文件夹下所有文件的大小?
- Vant weave - remove (clear) < van button > button component Click to display gray background effect
- How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
猜你喜欢

SFDP super form development platform v6.0.4 was officially released

How to customize templates and quickly generate complete code in idea?

Solve the problem of repairing Visual Basic exceptions with excel/wps plug-in of choice financial terminal

Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business

CSV文件格式——方便好用个头最小的数据传递方式

Yunna | how to use the system to manage fixed assets? How to manage fixed assets?

Yunna | fixed assets system management, NC system management where are the fixed assets
![[mrctf2020]ezpop-1 | PHP serialization](/img/f8/6164b4123e0d1f3b90980ebb7b4097.png)
[mrctf2020]ezpop-1 | PHP serialization

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

How to switch to root in xshell
随机推荐
Common interview questions for network workers: Telnet, TTL, router and switch
如何查看一个文件夹下所有文件的大小?
浅析现代Web端im即时通讯开发技术
What are the top ten securities companies? In addition, is it safe to open a mobile account?
赛芯电子冲刺科创板上市:拟募资6.23亿元,共有64项专利申请信息
The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications
[deep learning compilation] operator compilation IR conversion
shell 规范日期格式
Go 中的 UDP 服务器和客户端
Twitter launches the test of anti abuse tool "safe mode" and adds enabling prompt
一些生活的思考
@Bugs caused by improper use of configurationproperties
Text classification using huggingface
Good test / development programmers vs. average programmers
How to create a module in the idea and how to delete a module in the idea?
[three.js] Web3D first experience
2022-06-29: x = {a, B, C, D}, y = {e, F, G, H}, the length of the two small arrays X and Y is 4. If yes: a + e = B + F = C + G = D + H
2022 6 月25 日交易总结
[MRCTF2020]Ezpop-1|php序列化
【three.js】WEB3D初次体验