Unity3d 加载UnityEngine UI dll 失败导致 Prefab 上 脚本丢失

               

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


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



using UnityEngine;using System.Collections.Generic;using UnityEditor;using System.Text.RegularExpressions;using System.IO;using System.Text;public class ReimportUnityEngineUI {    [MenuItem("Assets/Reimport UI Assemblies", false, 100)]    public static void ReimportUI() {#if UNITY_4_6        var path = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/GUISystem/{0}/{1}";        var version = Regex.Match(Application.unityVersion, @"^[0-9]+\.[0-9]+\.[0-9]+").Value;#elif UNITY_4_7        var path = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/GUISystem/{0}/{1}";        var version = Regex.Match(Application.unityVersion, @"^[0-9]+\.[0-9]+\.[0-9]+").Value;#else        var path = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/GUISystem/{1}";        var version = string.Empty;#endif        string engineDll = string.Format(path, version, "UnityEngine.UI.dll");        string editorDll = string.Format(path, version, "Editor/UnityEditor.UI.dll");        ReimportDll(engineDll);        ReimportDll(editorDll);    }    static void ReimportDll(string path) {        if (File.Exists(path))            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.DontDownloadFromCacheServer);        else            Debug.LogError(string.Format("DLL not found {0}", path));    }} 


           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

你可能感兴趣的:(Unity3d 加载UnityEngine UI dll 失败导致 Prefab 上 脚本丢失)