unity ui dll丢失

Unity3D 加载UnityEngine.UI.dll 失败导致 Prefab 上 脚本丢失,引发各种 NullException


在 Unity 官方论坛找到的解决方法是重新加载 UnityEngine.UI.dll ,把下面的脚本扔到项目里,然后右键菜单中就会出现 



[csharp]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. using UnityEngine;  
  2. using System.Collections.Generic;  
  3. using UnityEditor;  
  4. using System.Text.RegularExpressions;  
  5. using System.IO;  
  6. using System.Text;  
  7.   
  8. public class ReimportUnityEngineUI {  
  9.     [MenuItem("Assets/Reimport UI Assemblies"false, 100)]  
  10.     public static void ReimportUI() {  
  11. #if UNITY_4_6  
  12.         var path = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/GUISystem/{0}/{1}";  
  13.         var version = Regex.Match(Application.unityVersion, @"^[0-9]+\.[0-9]+\.[0-9]+").Value;  
  14. #elif UNITY_4_7  
  15.         var path = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/GUISystem/{0}/{1}";  
  16.         var version = Regex.Match(Application.unityVersion, @"^[0-9]+\.[0-9]+\.[0-9]+").Value;  
  17. #else  
  18.         var path = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/GUISystem/{1}";  
  19.         var version = string.Empty;  
  20. #endif  
  21.         string engineDll = string.Format(path, version, "UnityEngine.UI.dll");  
  22.         string editorDll = string.Format(path, version, "Editor/UnityEditor.UI.dll");  
  23.         ReimportDll(engineDll);  
  24.         ReimportDll(editorDll);  
  25.   
  26.     }  
  27.     static void ReimportDll(string path) {  
  28.         if (File.Exists(path))  
  29.             AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.DontDownloadFromCacheServer);  
  30.         else  
  31.             Debug.LogError(string.Format("DLL not found {0}", path));  
  32.     }  
  33. }   
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值