Exemple #1
0
    public static void RemovePackage(string url)
    {
        Utility_ManifestJson manifest = GetManifest();

        manifest.RemoveFromUrl(url);
        SetManifest(manifest);
    }
Exemple #2
0
    public static void AddPackage(string namespaceId, string url)
    {
        Utility_ManifestJson manifest = GetManifest();

        manifest.Add(namespaceId, url);
        SetManifest(manifest);
    }
Exemple #3
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);
    }
Exemple #4
0
    private void OnValidate()
    {
        if (string.IsNullOrEmpty(m_name) && !string.IsNullOrEmpty(m_manifestUrl))
        {
            int index = m_manifestUrl.LastIndexOf('/');
            if (index < 0)
            {
                m_name = m_manifestUrl;
            }
            else
            {
                m_name = m_manifestUrl.Substring(index);
            }
        }
        if (string.IsNullOrEmpty(m_name))
        {
            m_name = "Not set yet";
        }
        this.gameObject.name = m_name;

        if (m_previousValue != m_manifestUrl)
        {
            m_previousValue = m_manifestUrl;
            if (string.IsNullOrEmpty(m_manifestUrl))
            {
                m_downloaded = "";
                m_manifest   = new Utility_ManifestJson();
            }
            else
            {
                DownloadWebManifest();
            }
        }
    }
Exemple #5
0
    public static Utility_ManifestJson CreateFromJson(string json)
    {
        Utility_ManifestJson man = new Utility_ManifestJson();

        try
        {
            man.dependencies = DependencyJson.GetDependeciesFromText(json);
        }
        catch (Exception e)
        {
            UnityEngine.Debug.LogWarning(e);
        }
        return(man);
    }
    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();
    }
Exemple #7
0
 public static Utility_ManifestJson CreateManifestFrom(string json)
 {
     return(Utility_ManifestJson.CreateFromJson(json));
 }
Exemple #8
0
 public static void SetManifest(Utility_ManifestJson manifest)
 {
     File.WriteAllText(GetManifestPath(), manifest.ToJson());
 }
Exemple #9
0
 public static Utility_ManifestJson GetManifest()
 {
     return(Utility_ManifestJson.CreateFromUnityEditor());
 }
Exemple #10
0
 public void DownloadWebManifest()
 {
     m_manifest =
         UnityPackageUtility.DownloadPackageManifest(m_manifestUrl, out m_downloaded);
 }