当前位置:网站首页>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);边栏推荐
- 初始I/O及其基本操作
- 如何拒绝期末复习无用功?猿辅导:找准适合自己的复习方法很重要
- 赛芯电子冲刺科创板上市:拟募资6.23亿元,共有64项专利申请信息
- Cloud, IPv6 and all-optical network
- Live broadcast configuration of crmeb knowledge payment system program configuration (method 2)
- Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
- 2020-12-03
- How to create a module in the idea and how to delete a module in the idea?
- Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture
- Comment personnaliser les modèles et générer rapidement le code complet dans l'idée?
猜你喜欢

初始I/O及其基本操作

Which department should the company's fixed assets be managed? How should the company's fixed assets be managed

How to switch to root in xshell

latex如何输入一个矩阵

手写C语言之函数的嵌套调用和链式访问

科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头

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

Citation of Dissertation

数据中台咋就从“小甜甜”变成了“牛夫人”?

Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture
随机推荐
[three.js] Web3D first experience
[mrctf2020]ezpop-1 | PHP serialization
如何在IDEA中自定義模板、快速生成完整的代碼?
A Si's mood swings
Cloud, IPv6 and all-optical network
Twitter launches the test of anti abuse tool "safe mode" and adds enabling prompt
CSV文件格式——方便好用个头最小的数据传递方式
UDP servers and clients in go
元素使用 align-items center 和 overflow auto 之后,部分内容显示不全
Crmeb SMS for program configuration of knowledge payment system
测试用例设计方法之等价类划分方法
【Spark】scala基础操作(持续更新)
Ml: introduction to confidence interval (the difference and relationship between precision / accuracy / accuracy), use method, and detailed introduction to case application
How to design test cases
How to switch to root in xshell
Yunna | how to use the system to manage fixed assets? How to manage fixed assets?
Which direction of network development is better? Data communication engineer learning path sharing
Outsourcing for 3 years is a waste
面试官:大量请求 Redis 不存在的数据,从而影响数据库,该如何解决?
C语言课设心得之“推箱子”课设作品开源分享