コード例 #1
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");
            }
        }
    }
コード例 #2
0
    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);;
        }
    }