Example #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();


        ManifestFromWeb myScript = (ManifestFromWeb)target;


        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Reload"))
        {
            myScript.DownloadWebManifest();
        }

        if (GUILayout.Button("Merge"))
        {
            Utility_ManifestJson manifest = UnityPackageUtility.GetManifest();
            manifest.Add(myScript.m_manifest.dependencies);
            UnityPackageUtility.SetManifest(manifest);
            AssetDatabase.Refresh();
        }
        if (GUILayout.Button("Override"))
        {
            UnityPackageUtility.SetManifest(myScript.m_manifest);
            AssetDatabase.Refresh();
        }
        GUILayout.EndHorizontal();
        UnityPackageEditorDrawer.DrawManifrest(ref myScript.m_manifest, ref myScript.m_toAddName, ref myScript.m_toAddValue, ref myScript.m_scollState, false);
    }
Example #2
0
    //public static void RemoveLocker(string nameId)
    //{
    //    throw new NotImplementedException();
    //}

    public static Utility_ManifestJson DownloadPackageManifest(string url, out string received)
    {
        WebClient client = new WebClient();

        received = client.DownloadString(url);
        return(UnityPackageUtility.CreateManifestFrom(received));
    }
    public static void DrawPackageDownUpButton(GitLinkOnDisk disk, bool affectPackage = true)
    {
        if (!disk.HasUrl())
        {
            return;
        }

        bool     isDirectoryCreated = Directory.Exists(disk.GetDirectoryPath());
        bool     isGitFolderPresent = disk.HasUrl();
        GUIStyle disableStyle       = GetDisableStyle();
        GUIStyle enableStyle        = GetEnableStyle();


        GUILayout.BeginHorizontal();
        bool downAllow = true;

        if (GUILayout.Button("Down", downAllow ? enableStyle : disableStyle))
        {
            UnityPackageUtility.Down(disk.GetDirectoryPath(), disk.GetUrl(), affectPackage);
        }
        bool upAllow = isDirectoryCreated && isGitFolderPresent;

        if (GUILayout.Button("Up", upAllow ? enableStyle : disableStyle))
        {
            if (upAllow)
            {
                UnityPackageUtility.Up(disk.GetDirectoryPath(), affectPackage);
            }
        }
        GUILayout.EndHorizontal();
    }
Example #4
0
    public void RefreshInfo()
    {
        QuickGit.SetDebugOn(m_useDebug);
        m_useDebug = QuickGit.GetDebugState();

        m_isValideLink = UnityPackageUtility.IsGitLinkValide(m_gitLink);
        m_projectName  = UnityPackageUtility.GetProjectNameFromGitLink(m_gitLink);
    }
Example #5
0
 private void Reset()
 {
     if (string.IsNullOrEmpty(m_directory))
     {
         m_directory = Application.dataPath + "/../";
     }
     m_gitLinksPath = QuickGit.GetAllFolders(m_directory, true);
     QuickGit.GetGitsInDirectory(m_directory, out m_gitLinks);
     m_packageInfo = UnityPackageUtility.GetGitUnityPackageInDirectory(m_directory);
 }
Example #6
0
    public void OnValidate()
    {
        RefreshInfo();
        string path = GetProjectPathInUnity() + "/package.json";

        if (File.Exists(path))
        {
            Utility_PackageJson pack = UnityPackageUtility.GetPackageInfo(path);
            if (pack != null)
            {
                m_namespaceId = pack.GetNamespaceID();
            }
        }
    }
Example #7
0
    public static void Up(string directory, string namespaceId, string gitUrl, bool affectManifest = true)
    {
        string directoryPath = directory;

        QuickGit.AddFileInEmptyFolder(directoryPath);
        QuickGit.PullPushWithAddAndCommit(directoryPath, "Update: " + DateTime.Now.ToString("yyyy/mm/dd -  hh:mm"));

        #if UNITY_EDITOR
        UnityEditor.FileUtil.DeleteFileOrDirectory(directoryPath);
        UnityEditor.AssetDatabase.Refresh();
        #endif
        if (affectManifest && !string.IsNullOrEmpty(namespaceId) && !string.IsNullOrEmpty(gitUrl))
        {
            UnityPackageUtility.AddPackage(namespaceId, gitUrl);
        }
    }
Example #8
0
    public static void Down(string directory, string gitUrl, bool affectManifest = true)
    {
        string directoryPath = directory;

        Directory.CreateDirectory(directoryPath);
        if (!Directory.Exists(directoryPath + "/.git"))
        {
            QuickGit.Clone(gitUrl, directoryPath);
        }
        else
        {
            QuickGit.Pull(directoryPath);
        }

        if (affectManifest && !string.IsNullOrEmpty(gitUrl))
        {
            UnityPackageUtility.RemovePackage(gitUrl);
        }
    }
Example #9
0
 public static Utility_ManifestJson CreateFromUnityEditor()
 {
     return(CreateFromFile(UnityPackageUtility.GetManifestPath()));
 }
Example #10
0
 public string GetProjectPathInUnity()
 {
     return(UnityPackageUtility.GetGitDirectoryPropositionRootPathInUnity(m_gitLink));
 }
Example #11
0
 public static void OpenManifestJson()
 {
     UnityPackageUtility.OpenManifestFile();
 }
Example #12
0
    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");
            }
        }
    }
Example #13
0
 private void SetJsonProjectManifestAsText(string json)
 {
     File.WriteAllText(UnityPackageUtility.GetManifestPath(), json);
 }
Example #14
0
 public void DownloadWebManifest()
 {
     m_manifest =
         UnityPackageUtility.DownloadPackageManifest(m_manifestUrl, out m_downloaded);
 }
Example #15
0
 public static void OpenPackageHiddenFolder()
 {
     UnityPackageUtility.OpenPackageHiddenFolder();
 }
Example #16
0
 public static void RemoveLocker()
 {
     UnityPackageUtility.RemoveLocker();
     AssetDatabase.Refresh();
 }
Example #17
0
 public static string GetGitDirectoryPropositionRootPathInUnity(string gitLink)
 {
     return(Application.dataPath + "/" + UnityPackageUtility.GetProjectNameFromGitLink(gitLink));
 }
Example #18
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PackagePullPushMono myScript = (PackagePullPushMono)target;
        string gitPath      = myScript.GetProjectPathInUnity() + "/.git";
        string projectPath  = myScript.GetProjectPathInUnity();
        string gitFolderUrl = "";

        QuickGit.GetGitUrl(projectPath, out gitFolderUrl);
        bool   isGitFolderDefine      = !string.IsNullOrEmpty(gitFolderUrl);
        string projectPathTmp         = projectPath + "tmp";
        string requiredPathFile       = projectPath + "/requiredpackages.json";
        ListOfClassicPackages package = ListOfClassicPackages.FromJsonPath(requiredPathFile);

        if (string.IsNullOrEmpty(myScript.GetGitLink()))
        {
            return;
        }
        GUILayout.Label("Commands", EditorStyles.boldLabel);
        bool isLinkValide       = myScript.IsGitLinkValide();
        bool isDirectoryCreated = myScript.IsDirectoryCreated();

        GUILayout.BeginHorizontal();
        var disableStyle = new GUIStyle(GUI.skin.button);

        disableStyle.normal.textColor = new Color(0.6627451f, 0.6627451f, 0.6627451f);
        var enableStyle = new GUIStyle(GUI.skin.button);

        enableStyle.normal.textColor = new Color(0f, 0.4f, 0f);
        if (GUILayout.Button("Down", isDirectoryCreated?disableStyle: enableStyle))
        {
            if (!isDirectoryCreated)
            {
                UnityPackageUtility.Down(projectPath, myScript.GetGitLink(), myScript.m_affectPackageManager);
            }
        }
        if (GUILayout.Button("Up", (isDirectoryCreated && isGitFolderDefine) ? enableStyle : disableStyle))
        {
            if (isGitFolderDefine)
            {
                UnityPackageUtility.Up(projectPath, myScript.m_namespaceId, myScript.GetGitLink(), myScript.m_affectPackageManager);
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(6);


        GUILayout.BeginHorizontal();
        //if (isLinkValide && !isDirectoryCreated && GUILayout.Button("Clone"))
        //{
        //    myScript.PullProject();
        //}
        if (isGitFolderDefine && GUILayout.Button("Pull"))
        {
            myScript.UpdateProject();
        }
        if (isGitFolderDefine && GUILayout.Button("Pull & Push"))
        {
            myScript.PullAndPush();
        }
        if (isDirectoryCreated && GUILayout.Button("Remove Project"))
        {
            RemoveFolderWithUnityTool(myScript);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (isDirectoryCreated && GUILayout.Button("Open Folder"))
        {
            myScript.OpenDirectory();
        }
        if (isDirectoryCreated && isGitFolderDefine && GUILayout.Button("Open Cmd"))
        {
            myScript.OpenStatusInCommentLine();
        }
        if (isLinkValide && GUILayout.Button("Open Git Server"))
        {
            Application.OpenURL(myScript.GetGitLink());
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();

        if (isDirectoryCreated && isGitFolderDefine && GUILayout.Button("Remove Git Info"))
        {
            FileUtil.DeleteFileOrDirectory(gitPath);
        }
        if (isDirectoryCreated && !isGitFolderDefine && GUILayout.Button("Add Git Info"))
        {
            Directory.CreateDirectory(projectPathTmp);
            FileUtil.ReplaceDirectory(projectPath, projectPathTmp);
            FileUtil.DeleteFileOrDirectory(projectPath);
            Directory.CreateDirectory(projectPath);

            //QuickGit.CreateLocal(projectPath);
            // QuickGit.PushLocalToGitLab(projectPath, myScript.m_gitUserName, GetProjectDatedNameId(myScript), out gitUrl);
            QuickGit.Clone(myScript.GetGitLink(), projectPath);
            FileUtil.ReplaceDirectory(gitPath, projectPathTmp + "/.git");
            FileUtil.DeleteFileOrDirectory(projectPath);
            FileUtil.ReplaceDirectory(projectPathTmp, projectPath);
            FileUtil.DeleteFileOrDirectory(projectPathTmp);

            //FileUtil.ReplaceDirectory(projectPathTmp, projectPath);
            // FileUtil.DeleteFileOrDirectory(projectPathTmp);
        }

        GUILayout.EndHorizontal();


        if (package.m_packageLinks.Length > 0)
        {
            GUILayout.Label("Required Unitypackage:", EditorStyles.boldLabel);
        }
        GUILayout.BeginHorizontal();
        for (int i = 0; i < package.m_packageLinks.Length; i++)
        {
            ClassicUnityPackageLink link = package.m_packageLinks[i];
            string path = package.m_packageLinks[i].m_pathOrLink;

            if (link.IsUnityPackage())
            {
                if (link.IsWebPath() && GUILayout.Button("Web: " + link.m_name))
                {
                    string pathUnityPackage = Application.dataPath + "/../Temp/lastpackagedownloaded.unitypackage";
                    using (var client = new WebClient())
                    {
                        File.WriteAllBytes(pathUnityPackage, client.DownloadData(path));
                    }
                    Application.OpenURL(pathUnityPackage);
                    // FileUtil.DeleteFileOrDirectory(pathUnityPackage);
                }
                else if (link.IsWindowPath() && GUILayout.Button("Local: " + link.m_name))
                {
                    Application.OpenURL(path);
                }
            }

            if (link.IsAssetStoreLink() && GUILayout.Button("Store: " + link.m_name))
            {
                Application.OpenURL(path);
            }
        }
        GUILayout.EndHorizontal();
    }
Example #19
0
    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();
    }
Example #20
0
 public GitUnityPackageLinkOnDisk(string directoryPath)
 {
     UnityPackageUtility.GetUnityPackage(directoryPath, out m_packageInfo);
     QuickGit.GetGitUrl(directoryPath, out m_gitLink);
     this.m_projectDirectoryPath = directoryPath;
 }
Example #21
0
 private static string GetJsonProjectManifestAsText()
 {
     return(File.ReadAllText(UnityPackageUtility.GetManifestPath()));
 }
    public static void DrawManifrest(ref Utility_ManifestJson manifestInfo, ref string addname, ref string addvalue, ref Vector2 scrollValue, bool withButtonToPushAndLoad = true)
    {
        int buttonlenght = 30;
        int nameLength   = 250;

        if (withButtonToPushAndLoad)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Load"))
            {
                manifestInfo = UnityPackageUtility.GetManifest();
            }
            if (GUILayout.Button("Push"))
            {
                UnityPackageUtility.SetManifest(manifestInfo);
                AssetDatabase.Refresh();
            }
            if (GUILayout.Button("Go 2 Manifest"))
            {
                UnityPackageUtility.OpenManifestFile();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("", GUILayout.Width(buttonlenght));
        GUILayout.Label("Namespace Id", GUILayout.Width(nameLength));
        GUILayout.Label("https://server.com/user/project.git#branch");


        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("+", GUILayout.Width(buttonlenght)))
        {
            manifestInfo.Add(addname, addvalue);
        }
        addname = GUILayout.TextField(addname, GUILayout.Width(nameLength));
        if (addvalue.Length > 0 && GUILayout.Button("<o"))
        {
            bool   found;
            string nameId;
            DownloadInfoFromGitServer.LoadNamespaceFromProjectGitLink(addvalue, out found, out nameId);
            addname = nameId;
        }

        addvalue = GUILayout.TextField(addvalue);



        GUILayout.EndHorizontal();
        if (addvalue.Length > 0 && addvalue.ToLower().IndexOf(".git") < 0)
        {
            EditorGUILayout.HelpBox("Are you sure it is a git link ?", MessageType.Warning);
            if (GUILayout.Button("Add .git at the end of the link"))
            {
                addvalue += ".git";
            }
        }

        scrollValue = GUILayout.BeginScrollView(scrollValue, false, true);
        List <DependencyJson> m_dependencies = manifestInfo.dependencies;

        if (m_dependencies != null && m_dependencies.Count > 0)
        {
            GUILayout.Label("Current package");
            for (int i = 0; i < m_dependencies.Count; i++)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("-", GUILayout.Width(buttonlenght)))
                {
                    manifestInfo.Remove(m_dependencies[i].nameId);
                }

                GUILayout.TextField(m_dependencies[i].nameId, GUILayout.Width(nameLength));
                if (m_dependencies[i].value.IndexOf("http") > -1)
                {
                    if (GUILayout.Button("Update", GUILayout.Width(60)))
                    {
                        manifestInfo.RemoveLocker(m_dependencies[i].nameId);
                        AssetDatabase.Refresh();
                    }
                    if (GUILayout.Button("Down", GUILayout.Width(50)))
                    {
                        UnityPackageUtility.Down(m_dependencies[i].value);
                        AssetDatabase.Refresh();
                    }

                    if (GUILayout.Button("Go", GUILayout.Width(30)))
                    {
                        Application.OpenURL(m_dependencies[i].value);
                    }
                }
                GUILayout.TextField(m_dependencies[i].value);



                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndScrollView();
    }
Example #23
0
 public bool IsGitLinkValide()
 {
     return(UnityPackageUtility.IsGitLinkValide(m_gitLink));
 }