private static string CreatePackCommandArgs(PackSettings packSettings) { var command = new StringBuilder(); command.Append(" /action: Pack"); command.Append($" /zipfile: \"{Path.Combine(packSettings.ProjectSolutionFolder, packSettings.FileName)}\""); command.Append($" /folder: \"{packSettings.ProjectPackageFolder}\""); // Add a mapping file which should be in the root folder of the project and be named mapping.xml if (packSettings.SolutionPackageConfig.map != null && packSettings.UseMapFile) { MapFile.Create(packSettings.SolutionPackageConfig, Path.Combine(packSettings.ProjectPath, ExtensionConstants.SolutionPackagerMapFile)); if (File.Exists(Path.Combine(packSettings.ProjectPath, ExtensionConstants.SolutionPackagerMapFile))) { command.Append($" /map: \"{Path.Combine(packSettings.ProjectPath, ExtensionConstants.SolutionPackagerMapFile)}\""); } } // Write Solution Package output to a log file named SolutionPackager.log in the root folder of the project if (packSettings.EnablePackagerLogging) { command.Append($" /log: \"{Path.Combine(packSettings.ProjectPath, ExtensionConstants.SolutionPackagerLogFile)}\""); } // Pack managed or unmanaged command.Append($" /packagetype:{packSettings.SolutionPackageConfig.packagetype}"); return(command.ToString()); }
public static PackSettings CreateNewPack() { PackSettings pack = CreateInstance <PackSettings>(); pack.root = new Node(); pack.root.name = "/"; pack.root.parent = null; return(pack); }
void OnGUI() { Rect dropdownRect = new Rect(0, 0, position.width - 132, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); m_EditedPackIndex = EditorGUI.Popup(dropdownRect, m_EditedPackIndex, m_PacksNames); if (EditorGUI.EndChangeCheck()) { if (m_EditedPackIndex == m_PacksNames.Length - 1) { string newPath = EditorUtility.SaveFilePanelInProject("Save a new Pack Settings", "Pack", "asset", "Choose where to save your new pack"); if (!String.IsNullOrEmpty(newPath)) { PackSettings setting = PackSettings.CreateNewPack(); m_EditedPack = setting; m_ExplorerView.LoadNewPack(m_EditedPack); AssetDatabase.CreateAsset(setting, newPath.Replace(Application.dataPath, "Assets/")); AssetDatabase.Refresh(); RefreshPacksList(); } } else if (m_EditedPackIndex != -1) { m_EditedPack = m_AvailablePacks[m_EditedPackIndex]; m_ExplorerView.LoadNewPack(m_EditedPack); } } Rect buildSingleRect = new Rect(position.width - 130, 0, 128, EditorGUIUtility.singleLineHeight); if (m_EditedPack != null && m_EditedPack.entries.Length > 0) { if (!String.IsNullOrEmpty(m_EditedPack.entries[0].originalPath)) { if (GUI.Button(buildSingleRect, "Revert Pack")) { RevertPackFiles(); } } else { if (GUI.Button(buildSingleRect, "Build This pack")) { BuildPack(m_EditedPack); } } } Rect exploreRect = new Rect(0, dropdownRect.height, position.width, position.height - dropdownRect.height); m_ExplorerView.OnGUI(exploreRect); }
public static string GetPackageCommandArgs(PackSettings packSettings) { if (!FileSystem.ConfirmOverwrite( new[] { packSettings.FullFilePath, packSettings.FullFilePath.Replace(".zip", "_managed.zip") }, true)) { return(null); } var commandArgs = CreatePackCommandArgs(packSettings); return(commandArgs); }
public override void Run(MyContext context) { //- If you build during the test, the dependent projects will be rebuilt and you will loose version info //- Options: // - Run test step first (NoBuild = false), followed by build (pack) for non-test projects with NoBuild set to false // - Run build (pack) first (NoBuild = false) for non-test projects, followed by test step (NoBuild = false) // - Build every project first (pack or build), then run test (NoBuild = true) and optionally pack (NoBuild = true) var versionModel = _versionService.ParseAppVersion(); var buildSettings = BuildSettings.Default(versionModel); var packSettings = PackSettings.Default(versionModel, "Adam Salvo"); _dotNetCore.Pack($"{context.ProjectsPath}/{Projects.Aero}/{Projects.Aero}.csproj", packSettings); _dotNetCore.Pack($"{context.ProjectsPath}/{Projects.AeroCake}/{Projects.AeroCake}.csproj", packSettings); _dotNetCore.Pack($"{context.ProjectsPath}/{Projects.AeroCakeTestSupport}/{Projects.AeroCakeTestSupport}.csproj", packSettings); _dotNetCore.Build($"{context.ProjectsPath}/{Projects.Aero}.Tests/{Projects.Aero}.Tests.csproj", buildSettings); _dotNetCore.Build($"{context.ProjectsPath}/{Projects.AeroCake}.Tests/{Projects.AeroCake}.Tests.csproj", buildSettings); }
public static bool CreatePackage(string toolPath, PackSettings packSettings, string commandArgs) { var command = new SolutionPackagerCommand { Action = SolutionPackagerAction.Pack.ToString(), CommandArgs = commandArgs, ToolPath = toolPath, SolutionName = packSettings.CrmSolution.Name }; ExecuteSolutionPackager(command); if (!packSettings.SaveSolutions) { return(true); } packSettings.Project.ProjectItems.AddFromFile(packSettings.FullFilePath); return(true); }
void RefreshPacksList() { m_AvailablePacks = new PackSettings[0]; m_PacksNames = new string[0]; m_EditedPackIndex = -1; string[] packsIDs = AssetDatabase.FindAssets("t:PackSettings"); foreach (string id in packsIDs) { PackSettings setting = AssetDatabase.LoadAssetAtPath <PackSettings>(AssetDatabase.GUIDToAssetPath(id)); if (setting == m_EditedPack) { m_EditedPackIndex = m_AvailablePacks.Length; } ArrayUtility.Add(ref m_AvailablePacks, setting); ArrayUtility.Add(ref m_PacksNames, setting.name); } ArrayUtility.Add(ref m_PacksNames, "New..."); }
public void Pack(PackSettings settings, List<PackInput> inputs, List<PackOutputList> outputs) { int X_LIMIT = settings.Size.Width - settings.Border; int Y_LIMIT = settings.Size.Height - settings.Border; List<Tree> trees = new List<Tree>(); trees.Add(new Tree(settings.Size)); // create a LUT for sort input List<int> sorted = new List<int>(inputs.Count); for (int i = 0; i < inputs.Count; ++i) sorted.Add(i); sorted.Sort(delegate(int a, int b) { Size sza = inputs[a].Size; Size szb = inputs[b].Size; int areaa = sza.Width * sza.Height; int areab = szb.Width * szb.Height; return areab - areaa; }); // perform packing foreach(int i in sorted) { Size sz = inputs[i].Size; if (sz.Width > settings.Size.Width || sz.Height > settings.Size.Height) { if(debug) Console.WriteLine("warning: input {0}:{1} is too large!", i, sz); continue; } // apply borders, if the input is small enough if (sz.Width < X_LIMIT) sz.Width += settings.Border * 2; if (sz.Height < Y_LIMIT) sz.Height += settings.Border * 2; Size szr = new Size(sz.Height, sz.Width); int ret = -1; // find a tree to insert the input foreach (Tree tree in trees) { ret = tree.Insert(sz); if (-1 != ret) // packed { tree.Nodes[ret].Input = i; break; } else if (AllowRotate) { ret = tree.Insert(szr); if (-1 != ret) // packed { tree.Nodes[ret].Input = i; tree.Nodes[ret].Rotated = true; //Console.WriteLine("input {0} is rotated", i); break; } } } // if running out of spaces, create a new tree for packing if(-1 == ret) { if(debug) Console.WriteLine("Running out of space, allocate a new texture"); Tree tree = new Tree(settings.Size); trees.Add(tree); ret = tree.Insert(sz); if (-1 != ret) // packed tree.Nodes[ret].Input = i; else if(debug) Console.WriteLine("still cannot pack input {0}:{1}!", i, sz); } } // output pack results foreach (Tree tree in trees) { PackOutputList polist = new PackOutputList(); foreach (Node node in tree.Nodes) { if (!node.IsFilled()) continue; PackOutput po = new PackOutput(); PackInput pi = inputs[node.Input]; if (pi.Size.Width < settings.Size.Width - 1) po.X = node.Rect.X + settings.Border; if (pi.Size.Height < settings.Size.Height - 1) po.Y = node.Rect.Y + settings.Border; po.Input = node.Input; po.Rotated = node.Rotated; polist.Add(po); } outputs.Add(polist); } }
public override List<Mesh> Unwrap(Mesh mesh, int packSize, float worldScale) { List<GroupedFaceUV> faceuvs = new List<GroupedFaceUV>(); BeginEvent(); int fcnt = mesh.FaceCount; for (int i = 0; i < fcnt; ++i) { Vector3 p0, p1, p2, e1, e2; // computer the face normal mesh.Positions.GetFace(out p0, out p1, out p2, i); e1 = p1 - p0; e1.Normalize(); e2 = p2 - p0; e2.Normalize(); Vector3 n = Vector3.Cross(e1, e2); n.Normalize(); // get major axis & assign texcoord TC tc = GetMajorAxis(ref n); GroupedFaceUV fuv = new GroupedFaceUV(); fuv.Texcrd[0] = tc(p0, worldScale); fuv.Texcrd[1] = tc(p1, worldScale); fuv.Texcrd[2] = tc(p2, worldScale); fuv.Normal = n; fuv.ComputeVtxHash(p0, p1, p2, Precision); faceuvs.Add(fuv); } EndEvent("Generate faceuvs"); // group the faces BeginEvent(); int gCnt = CreateGroups(faceuvs); Console.WriteLine("{0} faces created {1} groups", fcnt, gCnt); List<Group> groups = new List<Group>(); EndEvent("Group faceuvs"); // packing BeginEvent(); PackSettings packSettings = new PackSettings(); List<PackOutputList> packOutputs = new List<PackOutputList>(); List<PackInput> packInputs = new List<PackInput>(); for (int i = 0; i < gCnt; ++i) { Group gp = new Group(); gp.Count = GroupedFaceUV.Bounding(out gp.Min, out gp.Max, faceuvs, i); groups.Add(gp); PackInput pi = new PackInput(); pi.Size.Width = (int)Math.Ceiling(gp.Max.X - gp.Min.X); pi.Size.Height = (int)Math.Ceiling(gp.Max.Y - gp.Min.Y); packInputs.Add(pi); if (debug) { Console.Write("gp{0}: ", i); GroupedFaceUV.Dump(faceuvs, i); } } EndEvent("Prepare pack inputs"); BeginEvent(); bool ok = false; do { packSettings.Size.Width = packSize; packSettings.Size.Height = packSize; packSettings.Border = Border; packOutputs.Clear(); JimScottPacker packer = new JimScottPacker(); packer.debug = debug; packer.Pack(packSettings, packInputs, packOutputs); if (SingleMeshOutput) { ok = packOutputs.Count == 1; if (!ok) packSize = packSize * 2; } } while (SingleMeshOutput && !ok); EndEvent("Packing"); BeginEvent(); Vector2 scale = new Vector2(1.0f / packSize, 1.0f / packSize); // convert pack outputs back to faceuv foreach (PackOutputList polist in packOutputs) { foreach (PackOutput po in polist) { Group gp = groups[po.Input]; foreach (GroupedFaceUV fuv in faceuvs) { if (fuv.GroupId != po.Input) continue; fuv.Translate(new Vector2(po.X, po.Y) - gp.Min); fuv.Scale(scale); } } } // create output meshes List<Mesh> output = new List<Mesh>(); foreach (PackOutputList polist in packOutputs) { Mesh omesh = new Mesh(); int ofcnt = 0; for (int i = 0; i < polist.Count; ++i) ofcnt += groups[polist[i].Input].Count; omesh.Init(ofcnt * 3); int dst = 0; for (int i = 0; i < polist.Count; ++i) { for (int src = 0; src < fcnt; ++src) { GroupedFaceUV fuv = faceuvs[src]; if (fuv.GroupId != polist[i].Input) continue; mesh.Positions.CopyFaceTo(omesh.Positions, src, dst); mesh.Normals.CopyFaceTo(omesh.Normals, src, dst); mesh.Texcrds0.CopyFaceTo(omesh.Texcrds0, src, dst); omesh.Texcrds1.SetFace(dst, fuv.Texcrd[0], fuv.Texcrd[1], fuv.Texcrd[2]); if(debug) omesh.FaceProps[dst] = src; else omesh.FaceProps[dst] = mesh.FaceProps[src]; ++dst; } } output.Add(omesh); } OutputSize = packSize; EndEvent("Prepare pack outputs"); return output; }
public void LoadNewPack(PackSettings setting) { m_EditedPack = setting; Reload(); }
void BuildPack(PackSettings pack) { //this will force to regenerate the files list pack.OnBeforeSerialize(); string packDestination = Application.dataPath + "/_PACK_EXPORT/" + pack.name + "/"; string relativePackDestination = "Assets/_PACK_EXPORT/" + pack.name + "/"; if (Directory.Exists(packDestination)) { Debug.LogErrorFormat("That folder {0} already exist, you should revert before re_exporting", relativePackDestination); return; } Undo.SetCurrentGroupName("Create Pack Hierarchy"); int group = Undo.GetCurrentGroup(); AssetDatabase.CreateFolder("Assets", "_PACK_EXPORT"); AssetDatabase.CreateFolder("Assets/_PACK_EXPORT", pack.name); string folderRoot = "Assets/_PACK_EXPORT/" + pack.name; int fileCount = 1; //AssetDatabase.StartAssetEditing(); foreach (var file in pack.entries) { EditorUtility.DisplayProgressBar("Moving Assets", string.Format("Exporting file {0}/{1}", fileCount, pack.entries.Length), fileCount / (float)pack.entries.Length); string assetPath = AssetDatabase.GetAssetPath(file.obj); string folderHierarchy = Path.GetDirectoryName(file.path); string currentPath = folderRoot; for (int i = 0; i < file.pathPart.Length - 1; ++i) { if (!AssetDatabase.IsValidFolder(currentPath + "/" + file.pathPart[i].name)) { AssetDatabase.CreateFolder(currentPath, file.pathPart[i].name); } currentPath += "/" + file.pathPart[i].name; } //Directory.CreateDirectory(packDestination + folderHierarchy); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); file.originalPath = assetPath; string result = AssetDatabase.MoveAsset(assetPath, relativePackDestination + file.path); if (!String.IsNullOrEmpty(result)) { Debug.LogError(result); } fileCount++; } //AssetDatabase.StopAssetEditing(); EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); Undo.CollapseUndoOperations(group); }