Esempio n. 1
0
    void OnGUI()
    {
        GUILayout.Label("Manifest Configuration", EditorStyles.boldLabel);
        UnityPackageEditorDrawer.DrawManifrest(ref m_info.m_manifestInfo, ref m_info.m_manifestaddNamespace, ref m_info.m_manifestaddgitlink, ref m_info.m_scollValue);
        m_info.m_windowScrollValue = EditorGUILayout.BeginScrollView(m_info.m_windowScrollValue, false, false);
        GUILayout.Label("Copy past gits", EditorStyles.boldLabel);
        EditorGUILayout.HelpBox("Copy/past your git links split by a line return '\\n'", MessageType.Info);
        if (GUILayout.Button("Load in the manifest"))
        {
            string[] lines = m_info.m_pastSeveralLinks.Split('\n');
            for (int i = 0; i < lines.Length; i++)
            {
                string l = lines[i];
                l = l.Trim();
                string nameId;
                bool   found;
                DownloadInfoFromGitServer.LoadNamespaceFromProjectGitLink(l, out found, out nameId);
                if (found)
                {
                    if (l.ToLower().IndexOf(".git") < 0)
                    {
                        l += ".git";
                    }
                    m_info.m_manifestInfo.Add(nameId, l);
                }
            }
            m_info.m_pastSeveralLinks = "";
        }
        GUILayout.BeginHorizontal();
        //https://raw.githubusercontent.com/EloiStree/UnityToolbox/master/CopyPast/GitLinks/TestGroup.md

        List <string> urlsFound;

        if (GUILayout.Button("Extract gits"))
        {
            DownloadInfoFromGitServer.LoadGitClassicGitLinksInUrl(m_info.givenUrlLink, out urlsFound);
            for (int i = 0; i < urlsFound.Count; i++)
            {
                m_info.m_pastSeveralLinks += urlsFound[i].Trim() + '\n';
            }
        }
        m_info.givenUrlLink = GUILayout.TextField(m_info.givenUrlLink);
        GUILayout.EndHorizontal();
        //be.eloistree.teleportvirtualrealityuser
        m_info.m_pastSeveralLinks = GUILayout.TextArea(m_info.m_pastSeveralLinks, GUILayout.MinHeight(200));
        EditorGUILayout.EndScrollView();
    }
    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();
    }