当前位置:网站首页>The unity editor randomly generates objects. After changing the scene, the problem of object loss is solved
The unity editor randomly generates objects. After changing the scene, the problem of object loss is solved
2022-06-30 01:02:00 【Daily dead cycle】
Preface :
obj= (GameObject) PrefabUtility.InstantiatePrefab(configData.bigMainScene);When I develop the editor, I instantiate the prefab into the scene , After jump scene , Then returning to the scene of the instantiated object will cause the object we created before to be lost , This situation ! Very pit , Because there will be no prompt for unsaved scenes , Record the solution here
solve :
I don't think this is a complete solution , But this method is the same as when we right-click to create an object , Give Way Unity Save it for us again , Record it in the cancellation data , That's it , The code is as follows , Mainly used PrefabUtility .UnpackPrefabInstance() This method .
Details please see API
Unity - Scripting API: PrefabUtility.UnpackPrefabInstance
obj = (GameObject) PrefabUtility.InstantiatePrefab(configData.smallMainScene);
PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.OutermostRoot, InteractionMode.UserAction);边栏推荐
- Sfdp 超级表单开发平台 V6.0.4 正式发布
- [three.js] Web3D first experience
- [proteus simulation] 8-bit port detection 8 independent keys
- Quick pow: how to quickly find power
- Visual studio 2017 cannot open the include file: 'qopenglfunctions_3_3_core': no such file or directory
- 面试官:大量请求 Redis 不存在的数据,从而影响数据库,该如何解决?
- How to customize templates and quickly generate complete code in idea?
- 我,33岁,字节跳动测试开发,揭开北京“测试岗”的真实收入
- I learned database at station B (V): DQL exercise
- Arlo felt lost
猜你喜欢
随机推荐
如何在IDEA中创建Module、以及怎样在IDEA中删除Module?
【深度学习编译】算子编译 IR 转换
Developers, why does the maturity of container technology herald the arrival of cloud native era?
干外包3年,真废了...
81. 搜索旋转排序数组 II
Visual Studio 2017 无法打开包括文件: “QOpenGLFunctions_3_3_Core”: No such file or directory
[deep learning compilation] operator compilation IR conversion
【Proteus仿真】8比特端口檢測8獨立按鍵
How to switch to root in xshell
Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
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
Sfdp 超级表单开发平台 V6.0.4 正式发布
Lower expectations
UDP servers and clients in go
Stimulsoft Reports报告工具,Stimulsoft创建和构建报告
英伟达Jetson Nano的初步了解
Some thoughts on life
【Spark】scala基础操作(持续更新)
外包干了三年,废的一踏糊涂...
[mrctf2020]ezpop-1 | PHP serialization









