当前位置:网站首页>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找到脚本了,脚本中的參數也不會清空。
边栏推荐
- Wechat applet project example - Fitness calculator
- 【mysql】mysql安装
- Final summary of addition, deletion, modification and query
- Special materials | household appliances, white electricity, kitchen electricity
- Three ways for ORALCE to process column to row conversion and finally generate table style data
- Unity3d ugui translucent or linear gradient pictures display abnormally (blurred) problem solving (color space mismatch)
- Mosaïque d'images basée sur la matrice de transformation
- Requirements and business model innovation - Requirements 7- user requirements acquisition based on use case / scenario model
- [string] determine whether S2 is the rotation string 2 of S1
- Sed command
猜你喜欢
随机推荐
[point cloud compression] variable image compression with a scale hyperprior
Hacker + marathon =? Hacker marathon?
Unity3d ugui translucent or linear gradient pictures display abnormally (blurred) problem solving (color space mismatch)
Final summary of addition, deletion, modification and query
Sparse tensor based point cloud attribute compression
laravel 8 选用 jwt 进行接口验证
Leetcode 6[finding rules] Z-transform the leetcode path of heroding
string manipulation:
VIM command Encyclopedia
golang的gin框架,各种接收参数的方式和各种绑定的区别?
分數大小的比較
Laravel 8 selects JWT for interface verification
Recommend 6 office software, easy to use and free, double the efficiency
Requirements and business model analysis requirements 13 data modeling
Paper recommendation: relicv2, can the new self supervised learning surpass supervised learning on RESNET?
Batch automated e-mail: Vika Vige table x Tencent Qianfan scene connector has made new moves, and business communication and event marketing only need 3 steps
Sequence list and linked list - primary level
Hudi of data Lake (14): basic concepts of Apache Hudi
[Business Research Report] 2021 global mobile game player white paper - download link attached
How to modify the result name of MySQL query result 1 and result 2
![Leetcode 6[finding rules] Z-transform the leetcode path of heroding](/img/c0/aca2eb185ce4b423df9ee171ee91e1.jpg)







