Beispiel #1
0
    public static void AddPackage(string namespaceId, string url)
    {
        Utility_ManifestJson manifest = GetManifest();

        manifest.Add(namespaceId, url);
        SetManifest(manifest);
    }
Beispiel #2
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);
    }
    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();
    }