当前位置:网站首页>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);
边栏推荐
- Lower expectations
- 简单的页面
- 【mysql篇-基础篇】通用语法2
- 字节面试惨遭滑铁卢:一面就被吊打,幸得华为内推,三面拿到offer
- Ml: introduction to confidence interval (the difference and relationship between precision / accuracy / accuracy), use method, and detailed introduction to case application
- 阿洛觉得自己迷茫
- 出门在外保护好自己
- CSV文件格式——方便好用个头最小的数据传递方式
- MySQL installation steps (detailed)
- [MySQL basic] general syntax 2
猜你喜欢
浅析现代Web端im即时通讯开发技术
Too voluminous ~ eight part essay, the strongest king of interview!
Interviewer: how to solve the problem of massive requests for data that does not exist in redis, which affects the database?
开发者,为什么说容器技术的成熟预示着云原生时代的到来?
[MySQL basic] general syntax 2
2020-12-03
传统微服务框架如何无缝过渡到服务网格 ASM
Practical application of information security
Solve the problem of repairing Visual Basic exceptions with excel/wps plug-in of choice financial terminal
I / o initial et son fonctionnement de base
随机推荐
Seata 與三大平臺攜手編程之夏,百萬獎金等你來拿
数字垃圾是什么?跟随世界第一位AI艺术家,探索元碳艺术
Command line Basics
网易云音乐内测音乐社交 App“MUS”,通过音乐匹配同频朋友
如何在IDEA中创建Module、以及怎样在IDEA中删除Module?
In 2022, the latest and most detailed idea associated database method and visual operation of database in idea (including graphic process)
HC32M0+ GPIO
优秀的测试/开发程序员与普通的程序员对比......
Flask web minimalist tutorial (III) - Sqlalchemy (part a)
赛芯电子冲刺科创板上市:拟募资6.23亿元,共有64项专利申请信息
阿洛觉得自己迷茫
Practical application of information security
How to customize templates and quickly generate complete code in idea?
我,33岁,字节跳动测试开发,揭开北京“测试岗”的真实收入
SFDP super form development platform v6.0.4 was officially released
How to design test cases
Equivalence class partition method for test case design method
[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network
UDP servers and clients in go
Common settings in idea