当前位置:网站首页>Solution to missing in unity script

Solution to missing in unity script

2022-06-12 03:28:00 _ YiFei

Doing it unity Project time , We may encounter the problem of missing scripts as shown below :
 Insert picture description here

This problem occurs when we use software git During cooperative development , Finally, after investigation , Found to be .meta There's something wrong with the document , The reason is our gitignore Accidentally added *.meta( The official ignore The file doesn't notice this ), Then when developing ,pull Others' commit when ,meta The file was saved locally before the conflict was resolved :
 Insert picture description here

You can see that there is a pile of... In this file git Conflict information for , So if there is missing The situation of , You can go to your own .meta In the document , See if there are any inappropriate git Conflict information , If there are any problems, they can be solved as above .

Of course, only modifying this may not completely solve the problem , There may be guid There was a disorder . Let's talk about manual modification guid To restore the script , So you don't have to drag scripts one by one , It's troublesome .

Manual modification guid To load correctly miss Script

Of course , If not git The cause , Still there miss Words , So that's the script meta Medium guid There is a problem . Let's first take a brief look at meta Principle :

 Insert picture description here

You can see that this script actually has a guid,.unity This is actually how files find scripts . So if we know there are many places where we use this script , You can go to one first miss The place of , Drag the script to miss Where to go , Then check it out .unity Changes in the file , Manually modify :

1、 Drag the correct script to miss The place of :

 Insert picture description here

You can see the direct drag , Some settings of the script are still null Of , If you want to drag it all over again , Very trouble . But let's modify it directly guid To solve this problem .

2、 see .unity Changes in documents

 Insert picture description here

You can see , In fact, the scene is .unity Mapping of scripts in the file guid Changed , The reason why the scenario cannot find the script , Because of the script .meta In the file guid Changed , We just need to put this guid Change to the previous in the scene guid that will do , For example, the scene changes now :

from

m_Script: {fileID: 11500000, guid: 4324dfer1453a2343445596123450cba, type: 3}

Change for

m_Script: {fileID: 11500000, guid: 693980ce1453a064e9a5596448770cba, type: 3}

3、 Modify the script .meta Medium guid, Simultaneous recovery .unity file

take 693980ce1453a064e9a5596448770cba Change it to 4324dfer1453a2343445596123450cba that will do , Pay attention to .unity File change removal for , Because we are the first 2 Step is just to find the correct script guid.

 Insert picture description here

Now the scenarios that reference this script are back to normal , Because it can pass the previous guid Found the script , The parameters in the script will not be cleared .

原网站

版权声明
本文为[_ YiFei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206120327001527.html