Unity專案中UI指令碼丟失解決方案
阿新 • • 發佈:2019-01-11
//此指令碼是解決UI指令碼丟失
//步驟:將此指令碼放到專案下的Edit資料夾下,如果沒有,請自行建立
//步驟:點選視窗的Asstes → Reimport ui assemblies
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; #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)); } }