private void DrawGitIniCreateAndPush() { ResetInfo(); if (!m_lockSelection) { m_relativeSelection = GetFolderSelectedInUnity(); } m_absoluteSelection = Application.dataPath + "/" + m_relativeSelection; // propose to create folder if none are selected if (m_relativeSelection == "") { GitForFacilitationEditor.ProposeToCreateFolder(m_info.m_selector, ref m_info.m_tmpFolderToCreate); GitForFacilitationEditor.DisplayMessageToHelp("Please select or create a empty folder"); return; } DisplayLocker(); DisplayFolderSelectionnedInUnity(); bool hasGitInParent; m_gitLinkedToSelectedAsset = GetGitFolderAbsolutPath(out hasGitInParent); if (!hasGitInParent) { ProposeToCreateLocalGit(); return; } /// IF as local git but no url; /// m_gitfolderName = GetGitFolderNameFromFolderPathInUnity(); QuickGit.GetGitUrl(m_gitLinkedToSelectedAsset, out m_linkedGitUrl); DisplayGitPathAndLink(); DisplayGitProjectName(); UnityPackageUtility.TryToAccessPackageNamespaceIdFromFolder(m_absoluteSelection, out m_packageNamespaceId); DisplayPackageInformation(); if (string.IsNullOrEmpty(m_linkedGitUrl)) { //PushLocalGitToOnlineAccount(ref m_info.m_hideGitUtilitary); } if (!string.IsNullOrEmpty(m_linkedGitUrl)) { GitLinkOnDisk gd = new GitLinkOnDisk(m_gitLinkedToSelectedAsset); GitEditorDrawer.DisplayGitCommands(gd); //UnityPackageEditorDrawer.DrawPackageDownUpButton(m_absoluteSelection, m_gitLinkedToSelectedAsset, true); } if (m_gitLinkedToSelectedAsset == "") { return; } m_absolutPathOfFolderToWorkOn = m_gitLinkedToSelectedAsset; m_createPackageFoldout = EditorGUILayout.Foldout(m_createPackageFoldout, "Structure package"); if (m_createPackageFoldout) { CreatePackageStructure(); } m_dangerousButton = EditorGUILayout.Foldout(m_dangerousButton, "Dangerous Option"); if (m_dangerousButton) { if (GUILayout.Button("Remove Repository")) { FileUtil.DeleteFileOrDirectory(m_gitLinkedToSelectedAsset); } if (GUILayout.Button("Remove .git")) { FileUtil.DeleteFileOrDirectory(m_gitLinkedToSelectedAsset + "/.git"); } } }
void OnGUI() { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Back-up:", EditorStyles.boldLabel); if (GUILayout.Button("Save")) { WindowPlayerPref.Save("PackageBasicBuilderBackup", JsonUtility.ToJson(m_info)); } if (WindowPlayerPref.Has("PackageBasicBuilderBackup") && GUILayout.Button("Load")) { try { string json = WindowPlayerPref.Load("PackageBasicBuilderBackup"); Info i = JsonUtility.FromJson <Info>(json); if (i != null) { m_info = i; } } catch (Exception) { } } EditorGUILayout.EndHorizontal(); m_info.m_selector = null; m_info.m_targetedGit = null; UnityPathSelectionInfo.Get(out m_info.m_selectorpathFound, out m_info.m_selector); AccessGitWithPathSelector.GetAffectedGit(m_info.m_selector, out m_info.m_targetedGit); if (m_info.m_targetedGit != null) { string p = m_info.m_targetedGit.GetRelativeDirectoryPath(); m_info.m_selector = new UnityPathSelectionInfo(p); } EditorGUILayout.HelpBox("Reminder: Git must be install and Git.exe must be add in System Variable Path.", MessageType.Warning, true); m_info.m_packageTargeted = PackageJsonUtility.GetPackageFile(m_info.m_selector); if (GUILayout.Button("Select: " + m_info.m_selector.GetSelectName(false))) { m_info.m_selector.Open(); } if (m_info.m_targetedGit == null) { string path = m_info.m_selector.GetAbsolutePath(true); if (GUILayout.Button("Git Init. in " + m_info.m_selector.GetSelectName(true))) { QuickGit.CreateLocal(path); } GitForFacilitationEditor.ProposeCloneProject(m_info.m_selector, ref m_info.m_tmpCloneProposed); GitForFacilitationEditor.ProposeToCreateFolder(m_info.m_selector, ref m_info.m_tmpFolderToCreate); } else { if (!m_info.m_targetedGit.IsHosted()) { GitForFacilitationEditor.PushLocalGitToOnlineAccount(m_info.m_targetedGit, ref m_info.m_userNameToCreateGit, ref m_info.m_projectNameToCreate, ref m_info.m_dropDownSelectionServer, ref m_info.m_hideGitUtilitary); } GUILayout.Space(20); if (GUILayout.Button("Git: " + m_info.m_selector.GetSelectName(true), EditorStyles.boldLabel)) { Application.OpenURL(m_info.m_selector.GetAbsolutePath(false)); } if (QuickGit.IsPathHasGitRootFolder(m_info.m_selector.GetAbsolutePath(true))) { GitEditorDrawer.DisplayGitCommands(m_info.m_targetedGit); UnityPackageEditorDrawer.DrawPackageDownUpButton(m_info.m_targetedGit, true); } PackageJsonEditor.DrawEditorDefaultInterface(m_info.m_selector, m_info.m_packageTargeted, ref m_info.m_packageBuilder, ref m_info.m_tmpPackageJsonProposition, ref m_info.m_tmp_rawDisplayJsonPackage, ref m_info.m_hidePackageBuilder);; } }
void OnGUI() { // DisplayPullPushInProject(); m_pushPullInfo = (PackagePullPushObject)EditorGUILayout.ObjectField(m_pushPullInfo, typeof(PackagePullPushObject)); if (m_pushPullInfo != null) { m_pushPull = m_pushPullInfo.m_data; } else { m_pushPull = null; } if (m_pushPullInfo == null) { GUILayout.BeginHorizontal(); GUILayout.Label("Name:", GUILayout.Width(50)); m_folderToCreate = GUILayout.TextArea(m_folderToCreate); GUILayout.EndHorizontal(); DisplayCopyPastField(); if (GUILayout.Button("Create Default")) { m_pushPullInfo = GetDefaultPullPushObject(m_folderToCreate); m_pushPullInfo.m_data.m_gitUrl = m_copyPastShortCut; m_pushPullInfo.m_data.m_packageNamespaceId = m_nameSpaceToCreate; } } if (!string.IsNullOrEmpty(m_copyPastShortCut)) { //\w*\.git string isGitLink = "\\w*\\.git"; //".*"\s*:\s*".*\.git["\s\n\r\z] string isPackageManagerLink = "\".*\"\\s*:\\s*\".*\\.git[\"\\s\\n\\r\\a,]"; //"be.eloistree.overrideandroidvolume":"https://gitlab.com/eloistree/2019_06_30_overrideandroidvolume.git", if (MathRegex(m_copyPastShortCut, isPackageManagerLink)) { string[] tokens = Regex.Split(m_copyPastShortCut, "\"\\s*:\\s*\""); tokens[0] = tokens[0].Replace("\"", ""); tokens[1] = tokens[1].Replace("\"", ""); CheckOrCreateDefault(); m_pushPullInfo.m_data.m_gitUrl = tokens[1]; m_pushPullInfo.m_data.m_packageNamespaceId = tokens[0]; m_pushPullInfo.m_data.m_relativeFolderPath = GetGitProjectName(m_copyPastShortCut); m_copyPastShortCut = ""; } //https://gitlab.com/eloistree/HeyMyFriend //https://gitlab.com/eloistree/2019_06_30_overrideandroidvolume.git else if (MathRegex(m_copyPastShortCut, isGitLink)) { CheckOrCreateDefault(); m_pushPullInfo.m_data.m_gitUrl = m_copyPastShortCut; UnityPackageUtility.TryToAccessPackageNamespaceIdFromGitCloneUrl(m_copyPastShortCut, out m_pushPullInfo.m_data.m_packageNamespaceId); if (string.IsNullOrEmpty(m_pushPullInfo.m_data.m_relativeFolderPath)) { m_pushPullInfo.m_data.m_relativeFolderPath = GetGitProjectName(m_copyPastShortCut); } m_copyPastShortCut = ""; } } scroll = EditorGUILayout.BeginScrollView(scroll); if (m_pushPull != null) { GUILayout.BeginHorizontal(); string pathToWork = GetPathOfFolder(); if (!Directory.Exists(pathToWork) && GUILayout.Button("Create folder")) { Directory.CreateDirectory(GetPathOfFolder()); RefreshDataBase(); } else if (Directory.Exists(pathToWork) && GUILayout.Button("Remove Folder")) { FileUtil.DeleteFileOrDirectory(GetPathOfFolder()); RefreshDataBase(); } if (!(Directory.Exists(pathToWork) && Directory.GetFiles(pathToWork).Length > 0) && GUILayout.Button("Clone Git")) { Directory.CreateDirectory(GetPathOfFolder()); QuickGit.Clone(m_pushPull.m_gitUrl, GetPathOfFolder()); RefreshDataBase(); } GUILayout.EndHorizontal(); // UnityPackageEditorDrawer.DrawPackageDownUpButton(GetPathOfFolder(), m_pushPull.m_gitUrl, true); GitLinkOnDisk gd = new GitLinkOnDisk(GetPathOfFolder()); GitEditorDrawer.DisplayGitCommands(gd); m_folderFoldout = EditorGUILayout.Foldout(m_folderFoldout, "Folder & Git"); if (m_folderFoldout) { DisplayCopyPastField(); GUILayout.BeginHorizontal(); GUILayout.Label("Folder", GUILayout.Width(40)); m_pushPull.m_relativeFolderPath = GUILayout.TextArea(m_pushPull.m_relativeFolderPath); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Namespace", GUILayout.Width(70)); m_pushPull.m_packageNamespaceId = GUILayout.TextArea(m_pushPull.m_packageNamespaceId); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Git", GUILayout.Width(40)); m_pushPull.m_gitUrl = GUILayout.TextArea(m_pushPull.m_gitUrl); GUILayout.EndHorizontal(); } //m_upDownFoldout = EditorGUILayout.Foldout(m_upDownFoldout, "Pull Push"); //if (m_upDownFoldout) //{ //} GUILayout.Space(6); } EditorGUILayout.EndScrollView(); }
void OnGUI() { if (m_info == null) { m_info = new Info(); } bool foundPath = false; string previousPath = m_info.m_directoryRelative; UnityPathSelectionInfo selected; UnityPathSelectionInfo.Get(out foundPath, out selected); m_info.m_directoryRelative = selected.GetRelativePath(true); m_info.m_directoryAbsolute = selected.GetAbsolutePath(true); bool changeFound = m_info.m_directoryRelative != previousPath; bool resquestRefresh = GUILayout.Button("Refresh"); if (resquestRefresh || changeFound) { m_gitInProject.Refresh(); m_info.m_gitLinksPath = QuickGit.GetAllFolders(m_info.m_directoryAbsolute, true); QuickGit.GetGitsInDirectory(m_info.m_directoryAbsolute, out m_info.m_gitLinks); m_info.m_projectGitInParent = ""; GitLinkOnDisk gd; QuickGit.GetGitInParents(selected.GetAbsolutePath(true), QuickGit.PathReadDirection.LeafToRoot, out gd); if (gd != null) { m_info.m_projectGitInParent = gd.GetDirectoryPath(); } } EditorGUILayout.TextField("Relative >", m_info.m_directoryRelative); EditorGUILayout.TextField("Abosluete > ", m_info.m_directoryAbsolute); // if (foundPath) { if (!string.IsNullOrEmpty(m_info.m_projectGitInParent)) { EditorGUILayout.TextField("Parent Git", m_info.m_projectGitInParent.Length <= 0?"Project is not in a git.": m_info.m_projectGitInParent); } m_info.m_displayAllFolder = EditorGUILayout.Toggle("All Directory", m_info.m_displayAllFolder); if (m_info.m_displayAllFolder) { for (int i = 0; i < m_info.m_gitLinksPath.Length; i++) { m_info.m_gitLinksPath[i] = EditorGUILayout.TextField("Directory", m_info.m_gitLinksPath[i]); } } m_info.m_displayAllGitInFolder = EditorGUILayout.Toggle("All Repository", m_info.m_displayAllGitInFolder); if (m_info.m_displayAllGitInFolder) { for (int i = 0; i < m_info.m_gitLinks.Count; i++) { GitEditorDrawer.DisplayGitInfoWithCommand(m_info.m_gitLinks[i], ref m_info.m_displayprojectsInfo[i], ref m_info.m_displayInfoInGits[i]); EditorGUILayout.Space(); } } } GUILayout.BeginHorizontal(); GitEditorDrawer.ButtonDeleteEmptyFiles(m_info.m_directoryAbsolute); GitEditorDrawer.ButtonRefreshGitKeeper(m_info.m_directoryAbsolute); GUILayout.EndHorizontal(); }
void OnGUI() { if (m_info == null) { m_info = new Info(50); } m_info.m_scollrPackagePosition = GUILayout.BeginScrollView(m_info.m_scollrPackagePosition); if (m_info == null) { m_info = new Info(50); } if (GUILayout.Button("Refresh")) { m_gitInProject.Refresh(); } GUILayout.BeginHorizontal(); GitEditorDrawer.ButtonDeleteEmptyFiles(UnityPaths.GetUnityAssetsPath()); GitEditorDrawer.ButtonRefreshGitKeeper(UnityPaths.GetUnityAssetsPath()); GUILayout.EndHorizontal(); if (GUILayout.Button("Save Them All (Add>Commit)")) { m_gitInProject.AutoSaveLocal(); } if (GUILayout.Button("Push Them All (A>C>Pull>Push)")) { m_gitInProject.AutoSaveAndPush(); } m_info.m_inParent = EditorGUILayout.Toggle(" > Git(s) In Parent", m_info.m_inParent, EditorStyles.boldLabel); if (m_info.m_inParent) { List <GitLinkOnDisk> gits = m_gitInProject.GetParents(); if (gits.Count <= 0) { GUILayout.Label("None found"); } for (int i = 0; i < gits.Count; i++) { if (i >= m_info.m_tableCapacity) { break; } GitEditorDrawer.DisplayGitInfoWithCommand(gits[i], ref m_info.m_displayprojectsInfoParent[i], ref m_info.m_displayInfoInGitsParent[i]); EditorGUILayout.Space(); } } GUILayout.Space(space); m_info.m_inProject = EditorGUILayout.Toggle(" > Git(s) In Assets", m_info.m_inProject, EditorStyles.boldLabel); if (m_info.m_inProject) { List <GitLinkOnDisk> gits = m_gitInProject.GetGitInProject(); if (gits.Count <= 0) { GUILayout.Label("None found"); } for (int i = 0; i < gits.Count; i++) { if (i >= m_info.m_tableCapacity) { break; } GitEditorDrawer.DisplayGitInfoWithCommand(gits[i], ref m_info.m_displayprojectsInfoInProject[i], ref m_info.m_displayInfoInGitsInProject[i]); EditorGUILayout.Space(); } } GUILayout.Space(space); GUILayout.EndScrollView(); }