当前位置:网站首页>Unity脚本出現missing時的解决方法
Unity脚本出現missing時的解决方法
2022-06-12 03:28:00 【_YiFei】
在做unity項目時,我們可能會遇上如下所示的脚本丟失問題:
這個問題出現在我們軟工使用git進行合作開發時,最後經過排查,發現是.meta文件出現了問題,原因是我們的gitignore中不小心加入了*.meta(直接使用了官方的ignore文件沒有注意到這個),然後在開發時,pull別人的commit時,meta文件沒有解决完沖突就保存到本地了:
可以看到這個文件裏存了一堆git的沖突信息,因此如果出現了missing的情况,可以先去自己的.meta文件裏,看看是否有不恰當的git沖突信息,如果有的話可以像我上面一樣解决便好了。
當然只修改這個不一定完全解决問題,有可能guid出現了錯亂。下面講講手動改guid來恢複脚本,這樣就不用一個一個脚本重新拖了,怪麻煩的。
手動改guid以正確加載miss脚本
當然,如果沒有這些git導致的原因,還是出現了miss的話,那麼便是脚本的meta中的guid出現了問題。我們首先簡單了解一下meta的原理:

可以看到這個脚本實際上有一個guid,.unity文件實際上就是通過這個來找脚本的。因此我們如果已知有很多地方都使用了這個脚本,可以先去一個miss的地方,將這個脚本拖到miss的地方去,然後查看.unity文件中變化的地方,手動修改:
1、將正確的脚本拖到miss的地方:

可以看到直接拖過去,脚本的一些設置還是null的,如果要全部重新拖一遍的話,非常麻煩。但是我們下面直接修改guid來解决這個問題。
2、查看.unity文件的變化

可以看到,實際上這個場景的.unity文件中脚本的映射guid變化了,場景之所以找不到脚本,是因為脚本的.meta文件裏的guid變化了,我們只需要將這個guid改為場景中之前的guid即可,比如現在場景的變化是:
從
m_Script: {fileID: 11500000, guid: 4324dfer1453a2343445596123450cba, type: 3}
變化為了
m_Script: {fileID: 11500000, guid: 693980ce1453a064e9a5596448770cba, type: 3}
3、修改脚本.meta中的guid,同時複原.unity文件
將693980ce1453a064e9a5596448770cba改為4324dfer1453a2343445596123450cba即可,注意要把.unity的文件改動清除,因為我們第2步只是為了找到脚本正確的guid。

現在引用了這個脚本的場景都恢複正常了,因為可以通過之前的guid找到脚本了,脚本中的參數也不會清空。
边栏推荐
- 2020-12-07
- Steamvr--- grab objects
- MySQL创建用户并授权
- KV storage separation principle and performance evaluation of nebula graph
- [Business Research Report] the salary growth rate report of each industry in 2022 includes regional growth rate - download link is attached
- 2020-12-06
- Oracle schema object
- Functions (arguments, formal parameters, bubbling)
- 根据变换矩阵进行图像拼接
- 简单的数据库连接示例
猜你喜欢
随机推荐
Final summary of addition, deletion, modification and query - 2.1 (single table - addition, deletion, modification and query)
3768 string pruning (double pointer)
推荐6款办公软件,好用还免费,效率翻倍
Wechat applet project example - renju for two
微信小程序项目实例——体质计算器
CA certificate and key pair application notes
laravel 8 选用 jwt 进行接口验证
PHP life cycle and swoole life cycle
Community Conference | the mosn community will release version 1.0 and promote the evolution of the next generation architecture
(idea)the file size(2.85M) exceeds configured limit(2.56M). Code insight features are not available
JSON and XML pros and cons
Leetcode 6[finding rules] Z-transform the leetcode path of heroding
The rise of another domestic mobile phone chip is close to the height reached by Huawei
分數大小的比較
Sequence list and linked list - primary level
What is the difference between the gin framework of golang and the various methods of receiving parameters and various bindings?
MySQL创建用户并授权
postgresql基本介绍以及部署使用
2020-12-10
mysql/oracle 以唯一时间为分界,小于等于该时间求和,大于该时间求和








