static void UpdatePackage() { AssetDatabase.ExportPackage("Assets/TrackingTools", "TrackingTools.unitypackage", ExportPackageOptions.Recurse); AssetDatabase.ExportPackage("Assets/TrackingTools.KinectAzure", "TrackingTools.KinectAzure.unitypackage", ExportPackageOptions.Recurse); Debug.Log("Updated packages\n"); }
static void UpdatePackage() { string[] pathNames = { "Assets/Reaktion", "Assets/MidiJack", "Assets/OscJack" }; AssetDatabase.ExportPackage(pathNames, "Reaktion.unitypackage", ExportPackageOptions.Recurse); }
static void UpdatePackage() { AssetDatabase.ExportPackage("Assets/Kino", "KinoDatamosh.unitypackage", ExportPackageOptions.Recurse); }
public static void ExportPackage(string assetPathName, string fileName) { AssetDatabase.ExportPackage(assetPathName, fileName, ExportPackageOptions.Recurse); }
public static void export() { string[] projectContent = new string[] { "Assets", "ProjectSettings/TagManager.asset", "ProjectSettings/InputManager.asset", "ProjectSettings/ProjectSettings.asset" }; AssetDatabase.ExportPackage(projectContent, "Done.unitypackage", ExportPackageOptions.Interactive | ExportPackageOptions.Recurse | ExportPackageOptions.IncludeDependencies); Debug.Log("Project Exported"); }
static void CreateMyFontSprite() { if (Selection.objects == null) { return; } if (Selection.objects.Length == 0) { Debug.LogWarning("没有选中Sprite文件,需要将Sprite Mode设置成Multiple,切分好,并且以以名字的最后一个字符当做ascii码"); return; } string resoursePath = "Resources"; Object o = Selection.objects[0]; if (o.GetType() != typeof(Texture2D)) { Debug.LogWarning("选中的并不是图片文件"); return; } string selectionPath = AssetDatabase.GetAssetPath(o); if (selectionPath.Contains(resoursePath)) { string selectionExt = Path.GetExtension(selectionPath); if (selectionExt.Length == 0) { return; } string loadPath = selectionPath.Remove(selectionPath.Length - selectionExt.Length); string fontPathName = loadPath + ".fontsettings"; string matPathName = loadPath + ".mat"; float lineSpace = 0.1f;//字体行间距,下面会根据最高的字体得到行间距,如果是固定高度,可以在这里自行调整 loadPath = Path.GetFileNameWithoutExtension(selectionPath); Sprite[] sprites = Resources.LoadAll <Sprite>(loadPath); if (sprites.Length > 0) { //以textrue方式获得该资源,可以设置到创建的材质中去 Texture2D tex = o as Texture2D; //创建字体材质,并且将图片设置好 Material mat = new Material(Shader.Find("GUI/Text Shader")); AssetDatabase.CreateAsset(mat, matPathName); mat.SetTexture("_MainTex", tex); //创建字体文件,设置字体文件的材质 Font m_myFont = new Font(); m_myFont.material = mat; AssetDatabase.CreateAsset(m_myFont, fontPathName); //创建字体中的字符集数组 CharacterInfo[] characterInfo = new CharacterInfo[sprites.Length]; //得到最高的高度,设置行高和进行偏移计算 for (int i = 0; i < sprites.Length; i++) { if (sprites[i].rect.height > lineSpace) { lineSpace = sprites[i].rect.height; } } for (int i = 0; i < sprites.Length; i++) { Sprite spr = sprites[i]; CharacterInfo info = new CharacterInfo(); //设置ascii码,使用切分sprite的最后一个字母 info.index = (int)spr.name[spr.name.Length - 1]; Rect rect = spr.rect; //根据pivot设置字符的偏移,具体需要做成什么样的,可以根据自己需要修改公式 float pivot = spr.pivot.y / rect.height - 0.5f; if (pivot > 0) { pivot = -lineSpace / 2 - spr.pivot.y; } else if (pivot < 0) { pivot = -lineSpace / 2 + rect.height - spr.pivot.y; } else { pivot = -lineSpace / 2; } Debug.Log(pivot); int offsetY = (int)(pivot + (lineSpace - rect.height) / 2); //设置字符映射到材质上的坐标 info.uvBottomLeft = new Vector2((float)rect.x / tex.width, (float)(rect.y) / tex.height); info.uvBottomRight = new Vector2((float)(rect.x + rect.width) / tex.width, (float)(rect.y) / tex.height); info.uvTopLeft = new Vector2((float)rect.x / tex.width, (float)(rect.y + rect.height) / tex.height); info.uvTopRight = new Vector2((float)(rect.x + rect.width) / tex.width, (float)(rect.y + rect.height) / tex.height); //设置字符顶点的偏移位置和宽高 info.minX = 0; info.minY = -(int)rect.height - offsetY; info.maxX = (int)rect.width; info.maxY = -offsetY; //设置字符的宽度 info.advance = (int)rect.width; characterInfo[i] = info; } // lineSpace += 2; m_myFont.characterInfo = characterInfo; EditorUtility.SetDirty(m_myFont); //设置变更过的资源 AssetDatabase.SaveAssets(); //保存变更的资源 AssetDatabase.Refresh(); //刷新资源,貌似在Mac上不起作用 //由于上面fresh之后在编辑器中依然没有刷新,所以暂时想到这个方法, //先把生成的字体导出成一个包,然后再重新导入进来,这样就可以直接刷新了 //这是在Mac上遇到的,不知道Windows下面会不会出现,如果不出现可以把下面这一步注释掉 AssetDatabase.ExportPackage(fontPathName, "temp.unitypackage"); AssetDatabase.DeleteAsset(fontPathName); AssetDatabase.ImportPackage("temp.unitypackage", true); AssetDatabase.Refresh(); //最佳高度:上下各留一个像素的间距,如果不需要可以注释掉,根据需求更改 //打印是为了使使用者方便填写行高,因为font不支持设置行高。 Debug.Log("创建字体成功, 最大高度:" + lineSpace + ", 最佳高度:" + (lineSpace + 2)); } else { Debug.LogWarning("没有选中Sprite文件,需要将Sprite放到Resources文件夹下面,可以参考函数上方的说明操作"); } } }
static void CreateMyFont() { if (Selection.objects == null) { return; } if (Selection.objects.Length == 0) { Debug.LogWarning("没有选中fnt文件,或者图片文件"); return; } //至少需要保证选中文件的目录下面有fnt文件,否则不会生成字体 Font m_myFont = null; TextAsset m_data = null; string filePath = ""; Material mat = null; Texture2D tex = null; bool bln = false; //不管选中fnt、png、mat、fontsettings其中的任何一个,都可以创建字体 foreach (UnityEngine.Object o in Selection.objects) { if (o.GetType() == typeof(TextAsset)) { m_data = o as TextAsset; bln = true; } else if (o.GetType() == typeof(Material)) { mat = o as Material; bln = true; } else if (o.GetType() == typeof(Texture2D)) { tex = o as Texture2D; bln = true; } else if (o.GetType() == typeof(Font)) { m_myFont = o as Font; bln = true; } if (bln) { filePath = AssetDatabase.GetAssetPath(o); filePath = filePath.Substring(0, filePath.LastIndexOf('.')); } } //获取fnt文件,我们在这里加一次判断,为了可以直接选择图片也能导出字体 string dataPathName = filePath + ".fnt"; if (m_data == null) { m_data = (TextAsset)AssetDatabase.LoadAssetAtPath(dataPathName, typeof(TextAsset)); } if (m_data != null) { string matPathName = filePath + ".mat"; string fontPathName = filePath + ".fontsettings"; string texPathName = filePath + ".png"; //获取图片,如果没有图片,不影响,可以生成之后,再手动设置 if (tex == null) { tex = (Texture2D)AssetDatabase.LoadAssetAtPath(texPathName, typeof(Texture2D)); } if (tex == null) { Debug.LogWarning("没找到图片,或者图片名称和fnt文件名称不匹配"); } //获取材质,如果没有则创建对应名字的材质 if (mat == null) { mat = (Material)AssetDatabase.LoadAssetAtPath(matPathName, typeof(Material)); } if (mat == null) { mat = new Material(Shader.Find("GUI/Text Shader")); AssetDatabase.CreateAsset(mat, matPathName); } else { mat.shader = Shader.Find("GUI/Text Shader"); } mat.SetTexture("_MainTex", tex); //获取font文件,如果没有则创建对应名字的font文件 if (m_myFont == null) { m_myFont = (Font)AssetDatabase.LoadAssetAtPath(fontPathName, typeof(Font)); } if (m_myFont == null) { m_myFont = new Font(); AssetDatabase.CreateAsset(m_myFont, fontPathName); } m_myFont.material = mat; BMFont mbFont = new BMFont(); //借助NGUI的类,读取字体fnt文件信息,可以不用自己去解析了 BMFontReader.Load(mbFont, m_data.name, m_data.bytes); CharacterInfo[] characterInfo = new CharacterInfo[mbFont.glyphs.Count]; for (int i = 0; i < mbFont.glyphs.Count; i++) { BMGlyph bmInfo = mbFont.glyphs[i]; CharacterInfo info = new CharacterInfo(); //设置ascii码 info.index = bmInfo.index; //设置字符映射到材质上的坐标 info.uvBottomLeft = new Vector2((float)bmInfo.x / mbFont.texWidth, 1f - (float)(bmInfo.y + bmInfo.height) / mbFont.texHeight); info.uvBottomRight = new Vector2((float)(bmInfo.x + bmInfo.width) / mbFont.texWidth, 1f - (float)(bmInfo.y + bmInfo.height) / mbFont.texHeight); info.uvTopLeft = new Vector2((float)bmInfo.x / mbFont.texWidth, 1f - (float)(bmInfo.y) / mbFont.texHeight); info.uvTopRight = new Vector2((float)(bmInfo.x + bmInfo.width) / mbFont.texWidth, 1f - (float)(bmInfo.y) / mbFont.texHeight); //设置字符顶点的偏移位置和宽高 info.minX = bmInfo.offsetX; info.minY = -bmInfo.offsetY - bmInfo.height; info.maxX = bmInfo.offsetX + bmInfo.width; info.maxY = -bmInfo.offsetY; //设置字符的宽度 info.advance = bmInfo.advance; characterInfo[i] = info; } m_myFont.characterInfo = characterInfo; EditorUtility.SetDirty(m_myFont); //设置变更过的资源 EditorUtility.SetDirty(mat); //设置变更过的资源 AssetDatabase.SaveAssets(); //保存变更的资源 AssetDatabase.Refresh(); //刷新资源,貌似在Mac上不起作用 //由于上面fresh之后在编辑器中依然没有刷新,所以暂时想到这个方法, //先把生成的字体导出成一个包,然后再重新导入进来,这样就可以直接刷新了 //这是在Mac上遇到的,不知道Windows下面会不会出现,如果不出现可以把下面这一步注释掉 AssetDatabase.ExportPackage(fontPathName, "temp.unitypackage"); AssetDatabase.DeleteAsset(fontPathName); AssetDatabase.ImportPackage("temp.unitypackage", true); AssetDatabase.Refresh(); Debug.Log("创建字体成功"); } else { Debug.LogWarning("没有找到fnt文件,或者文件名称和图片名称不匹配"); } }
static void UpdatePackage() { AssetDatabase.ExportPackage("Assets/Spektr", "SpektrLightning.unitypackage", ExportPackageOptions.Recurse); }
private static void ExportPackageImpl() { DisplayProgressBar("Preparing for export...", 0f); // Disable auto recompile. var wasAutoRefreshEnabled = EditorPrefs.GetBool(autoRefreshKey); EditorPrefs.SetBool(autoRefreshKey, false); // Load a temp scene and unload assets to prevent reference errors. sceneSetup = EditorSceneManager.GetSceneManagerSetup(); EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); EditorUtility.UnloadUnusedAssetsImmediate(true); DisplayProgressBar("Pre-processing assets...", 0f); var processors = GetProcessors(); foreach (var proc in processors) { proc.OnPackagePreProcess(); } var assetPaths = AssetDatabase.GetAllAssetPaths().Where(p => p.StartsWith(AssetsPath)); var ignoredPaths = assetPaths.Where(p => IsAssetIgnored(p)); var unignoredPaths = assetPaths.Where(p => !IsAssetIgnored(p)); // Temporary hide ignored assets. DisplayProgressBar("Hiding ignored assets...", .1f); if (IsAnyPathsIgnored) { foreach (var path in ignoredPaths) { File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); } AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); } // Add license file. var needToAddLicense = File.Exists(LicenseFilePath); if (needToAddLicense) { File.Copy(LicenseFilePath, LicenseAssetPath); AssetDatabase.ImportAsset(LicenseAssetPath, ImportAssetOptions.ForceSynchronousImport); } // Modify scripts (namespace and copyright). DisplayProgressBar("Modifying scripts...", .25f); modifiedScripts.Clear(); var needToModify = !string.IsNullOrEmpty(Copyright); if (needToModify) { foreach (var path in unignoredPaths) { if (!path.EndsWith(".cs") && !path.EndsWith(".shader") && !path.EndsWith(".cginc")) { continue; } var fullpath = Application.dataPath.Replace("Assets", string.Empty) + path; var originalScriptText = File.ReadAllText(fullpath, Encoding.UTF8); string scriptText = string.Empty; var isImportedScript = path.Contains("ThirdParty"); var copyright = isImportedScript || string.IsNullOrEmpty(Copyright) ? string.Empty : "// " + Copyright; if (!string.IsNullOrEmpty(copyright) && !isImportedScript) { scriptText += copyright + "\r\n\r\n"; } scriptText += originalScriptText; File.WriteAllText(fullpath, scriptText, Encoding.UTF8); modifiedScripts.Add(fullpath, originalScriptText); } } // Export the package. DisplayProgressBar("Writing package file...", .5f); AssetDatabase.ExportPackage(AssetsPath, OutputPath + "/" + OutputFileName + ".unitypackage", ExportPackageOptions.Recurse); // Restore modified scripts. DisplayProgressBar("Restoring modified scripts...", .75f); if (needToModify) { foreach (var modifiedScript in modifiedScripts) { File.WriteAllText(modifiedScript.Key, modifiedScript.Value, Encoding.UTF8); } } // Remove previously added license asset. if (needToAddLicense) { AssetDatabase.DeleteAsset(LicenseAssetPath); } // Un-hide ignored assets. DisplayProgressBar("Un-hiding ignored assets...", .95f); if (IsAnyPathsIgnored) { foreach (var path in ignoredPaths) { File.SetAttributes(path, File.GetAttributes(path) & ~FileAttributes.Hidden); } AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); } DisplayProgressBar("Post-processing assets...", 1f); foreach (var proc in processors) { proc.OnPackagePostProcess(); } EditorPrefs.SetBool(autoRefreshKey, wasAutoRefreshEnabled); EditorSceneManager.RestoreSceneManagerSetup(sceneSetup); EditorUtility.ClearProgressBar(); }
static void UpdatePackage() { AssetDatabase.ExportPackage("Assets/Kvant", "KvantSwarm.unitypackage", ExportPackageOptions.Recurse); }
protected virtual void ProcessPackaging() { ExportOptions.UpdateOptions(); AssetDatabase.ExportPackage(FolderPath, FileName + FileExtension, ExportOptions.Options); }
static void UpdatePackage() { AssetDatabase.ExportPackage("Assets/Neuron", "NeuronAnimator.unitypackage", ExportPackageOptions.Recurse); }
public static void BuildPackage() { AssetDatabase.ExportPackage(new[] { "Assets/WebXR", "Assets/WebGLTemplates/" + TemplateFolderName }, "WebXR-Assets.unitypackage", ExportPackageOptions.Recurse); }
static void UpdatePackage() { AssetDatabase.ExportPackage("Assets/Klak", "Klak.unitypackage", ExportPackageOptions.Recurse); }
static void Export() { AssetDatabase.ExportPackage("Assets", "JOKER.unitypackage", ExportPackageOptions.Interactive | ExportPackageOptions.Recurse | ExportPackageOptions.IncludeLibraryAssets | ExportPackageOptions.IncludeDependencies); }
public static void ExportAdjustUnityPackage() { string exportedFileName = "Adjust.unitypackage"; string assetsPath = "Assets/Adjust"; List <string> assetsToExport = new List <string>(); // Adjust Assets. assetsToExport.Add(assetsPath + "/3rd Party/SimpleJSON.cs"); assetsToExport.Add(assetsPath + "/Android/adjust-android.jar"); assetsToExport.Add(assetsPath + "/Android/AdjustAndroid.cs"); assetsToExport.Add(assetsPath + "/Android/AdjustAndroidManifest.xml"); assetsToExport.Add(assetsPath + "/Editor/AdjustEditor.cs"); assetsToExport.Add(assetsPath + "/Editor/AdjustSettings.cs"); assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.cs"); assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.prefab"); assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.unity"); assetsToExport.Add(assetsPath + "/iOS/ADJAttribution.h"); assetsToExport.Add(assetsPath + "/iOS/ADJConfig.h"); assetsToExport.Add(assetsPath + "/iOS/ADJEvent.h"); assetsToExport.Add(assetsPath + "/iOS/ADJEventFailure.h"); assetsToExport.Add(assetsPath + "/iOS/ADJEventSuccess.h"); assetsToExport.Add(assetsPath + "/iOS/ADJLogger.h"); assetsToExport.Add(assetsPath + "/iOS/ADJSessionFailure.h"); assetsToExport.Add(assetsPath + "/iOS/ADJSessionSuccess.h"); assetsToExport.Add(assetsPath + "/iOS/ADJSubscription.h"); assetsToExport.Add(assetsPath + "/iOS/Adjust.h"); assetsToExport.Add(assetsPath + "/iOS/AdjustiOS.cs"); assetsToExport.Add(assetsPath + "/iOS/AdjustSdk.a"); assetsToExport.Add(assetsPath + "/iOS/AdjustUnity.h"); assetsToExport.Add(assetsPath + "/iOS/AdjustUnity.mm"); assetsToExport.Add(assetsPath + "/iOS/AdjustUnityDelegate.h"); assetsToExport.Add(assetsPath + "/iOS/AdjustUnityDelegate.mm"); assetsToExport.Add(assetsPath + "/Prefab/Adjust.prefab"); assetsToExport.Add(assetsPath + "/Unity/Adjust.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustAppStoreSubscription.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustAttribution.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustConfig.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustEnvironment.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustEvent.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustEventFailure.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustEventSuccess.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustLogLevel.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustPlayStoreSubscription.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustSessionFailure.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustSessionSuccess.cs"); assetsToExport.Add(assetsPath + "/Unity/AdjustUtils.cs"); assetsToExport.Add(assetsPath + "/Windows/AdjustWindows.cs"); assetsToExport.Add(assetsPath + "/Windows/WindowsPcl.dll"); assetsToExport.Add(assetsPath + "/Windows/WindowsUap.dll"); assetsToExport.Add(assetsPath + "/Windows/Stubs/Win10Interface.dll"); assetsToExport.Add(assetsPath + "/Windows/Stubs/Win81Interface.dll"); assetsToExport.Add(assetsPath + "/Windows/Stubs/WinWsInterface.dll"); assetsToExport.Add(assetsPath + "/Windows/W81/AdjustWP81.dll"); assetsToExport.Add(assetsPath + "/Windows/W81/Win81Interface.dll"); assetsToExport.Add(assetsPath + "/Windows/WS/AdjustWS.dll"); assetsToExport.Add(assetsPath + "/Windows/WS/WinWsInterface.dll"); assetsToExport.Add(assetsPath + "/Windows/WU10/AdjustUAP10.dll"); assetsToExport.Add(assetsPath + "/Windows/WU10/Win10Interface.dll"); assetsToExport.Add(assetsPath + "/Windows/Newtonsoft.Json.dll"); AssetDatabase.ExportPackage( assetsToExport.ToArray(), exportedFileName, ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Interactive); }
static void export() { AssetDatabase.ExportPackage(AssetDatabase.GetAllAssetPaths(), PlayerSettings.productName + ".unitypackage", ExportPackageOptions.Interactive | ExportPackageOptions.Recurse | ExportPackageOptions.IncludeDependencies | ExportPackageOptions.IncludeLibraryAssets); }
public static void BuildUnityPackage() { AssetDatabase.ExportPackage(m_PackageInputPaths, m_PackageOutputPath, ExportPackageOptions.Recurse); }
public static void ExportPackage() { AssetDatabase.ExportPackage(assets, "ArucoUnity.unitypackage", ExportPackageOptions.Interactive | ExportPackageOptions.Recurse); }