Esempio n. 1
0
    //-------------------------------------------------------------------------
    void _initProject()
    {
        try
        {
            Directory.CreateDirectory(mPatchInfoTargetDirectory);
        }
        catch (Exception e)
        {
            _deleteDirectory(mPatchInfoTargetDirectory);
            Debug.LogError("GameCloudEditorInitProjectInfo CreateDirectory Error::" + e.Message);
        }

        try
        {
            GameCloudEditor.copyFile(mPatchInfoResouceDirectory, mPatchInfoTargetDirectory, mPatchInfoResouceDirectory);
        }
        catch (Exception e)
        {
            _deleteDirectory(mPatchInfoTargetDirectory);
            Debug.LogError("GameCloudEditorInitProjectInfo copyFile Error::" + e.Message);
        }

        PlayerSettings.companyName      = mComponyName;
        PlayerSettings.productName      = mProductName;
        PlayerSettings.bundleIdentifier = mBundleIdentifier;
        GameCloudEditor.changeBundleData(mBundleVersion, true);
        GameCloudEditor.changeDataData(mDataVersion, true);
    }
    //-------------------------------------------------------------------------
    void _startBuild()
    {
        mCommonLuaTargetPath = mCommonLuaDateFileListPath + "/" + CurrentVersion;

        if (Directory.Exists(mRowAssetPath))
        {
            GameCloudEditor.copyFile(mRowAssetPath, mCommonLuaTargetPath, mRowAssetPath, mDoNotCopyDir);
        }

        if (!Directory.Exists(mCommonLuaTargetPath))
        {
            Directory.CreateDirectory(mCommonLuaTargetPath);
        }

        StreamWriter sw;
        string       info = mCommonLuaTargetPath + "/" + PackInfoTextName;

        if (File.Exists(info))
        {
            File.Delete(info);
        }

        sw = File.CreateText(info);

        using (sw)
        {
            _checkPackInfo(sw, mCommonLuaTargetPath);
        }
        ShowNotification(new GUIContent("打包完成!"));
    }
    //-------------------------------------------------------------------------
    void _initProject()
    {
        foreach (var i in MapInitProjectInfo)
        {
            _InitProjectInfo project_info = i.Value;

            string target_directory = mPatchInfoTargetDirectory + "/" + project_info.BundleIdentify;
            try
            {
                Directory.CreateDirectory(target_directory);
            }
            catch (Exception e)
            {
                _deleteDirectory(target_directory);
                Debug.LogError("GameCloudEditorInitProjectInfo CreateDirectory Error::" + e.Message);
            }

            try
            {
                GameCloudEditor.copyFile(mPatchInfoResouceDirectory, target_directory, mPatchInfoResouceDirectory);
            }
            catch (Exception e)
            {
                _deleteDirectory(target_directory);
                Debug.LogError("GameCloudEditorInitProjectInfo copyFile Error::" + e.Message);
            }

            if (project_info.IsDefault)
            {
                PlayerSettings.companyName      = project_info.CompanyName;
                PlayerSettings.productName      = project_info.AppName;
                PlayerSettings.bundleIdentifier = project_info.BundleIdentify;
            }

            var    project_info_str = getFormatProjectInfo(project_info);
            byte[] bytes            = System.Text.Encoding.UTF8.GetBytes(project_info_str);

            string path = target_directory + "/" + PROJECT_INFO_FILE_NAME;
            using (FileStream fs = new FileStream(path, FileMode.CreateNew, FileAccess.Write))
            {
                fs.Write(bytes, 0, bytes.Length);
            }

            GameCloudEditor.changeBundleData(_ePlatform.None, target_directory, project_info.InitBundleVersion, true);
            GameCloudEditor.changeDataData(_ePlatform.None, target_directory, project_info.InitDataVersion, true);
        }
    }
    //-------------------------------------------------------------------------
    void _deleteProject()
    {
        string delete_project = mABTargetPathRoot + "/" + CurrentProject.BundleIdentify;

        GameCloudEditor.deleteFile(delete_project);

        ListInitProjectInfo.Remove(CurrentProject);
        _combineProjectIndexWithSelectIndex();
        ArrayProjectBundleIdentity = ListInitProjectInfo.Select(x => x.BundleIdentify).ToArray();
        if (ListInitProjectInfo.Count > 0)
        {
            CurrentProject     = ListInitProjectInfo[0];
            CurrentSelectIndex = CurrentProject.ProjectIndex;
        }
        else
        {
            MapProjectIndexCombineWithSelectIndex.Clear();
            GameCloudEditor.deleteFile(mABTargetPathRoot);
            CurrentProject = null;
        }
    }
    //-------------------------------------------------------------------------
    void _addProject()
    {
        string target_directory = mABTargetPathRoot + "/" + AddProject.BundleIdentify;

        try
        {
            Directory.CreateDirectory(target_directory);
        }
        catch (Exception e)
        {
            Debug.LogError("GameCloudEditorInitProjectInfo CreateDirectory Error::" + e.Message);
        }

        try
        {
            string resource_path = mAssetPath + GameCloudEditor.ABPathInfoResourceDirectory;
            GameCloudEditor.copyFile(resource_path, target_directory, resource_path);
        }
        catch (Exception e)
        {
            Debug.LogError("GameCloudEditorInitProjectInfo copyFile Error::" + e.Message);
        }

        StringBuilder sb = new StringBuilder();

        sb.AppendLine("{");
        sb.Append("    \"ProjectIndex\" : ");
        sb.Append(AddProject.ProjectIndex);
        sb.Append(",");
        sb.AppendLine();
        sb.Append("    \"IsDefault\" : \"");
        sb.Append(AddProject.IsDefault);
        sb.Append("\",");
        sb.AppendLine();
        sb.Append("    \"CompanyName\" : \"");
        sb.Append(AddProject.CompanyName);
        sb.Append("\",");
        sb.AppendLine();
        sb.Append("    \"AppName\" : \"");
        sb.Append(AddProject.AppName);
        sb.Append("\",");
        sb.AppendLine();
        sb.Append("    \"BundleIdentify\" : \"");
        sb.Append(AddProject.BundleIdentify);
        sb.Append("\",");
        sb.AppendLine();
        sb.Append("    \"InitBundleVersion\" : \"");
        sb.Append(AddProject.InitBundleVersion);
        sb.Append("\",");
        sb.AppendLine();
        sb.Append("    \"InitDataVersion\" : \"");
        sb.Append(AddProject.InitDataVersion);
        sb.Append("\",");
        sb.AppendLine();
        sb.Append("}");
        byte[] bytes = System.Text.Encoding.UTF8.GetBytes(sb.ToString());

        string path = target_directory + "/" + GameCloudEditorInitProjectInfo.PROJECT_INFO_FILE_NAME;

        using (FileStream fs = new FileStream(path, FileMode.CreateNew, FileAccess.Write))
        {
            fs.Write(bytes, 0, bytes.Length);
        }

        GameCloudEditor.changeBundleData(_ePlatform.None, target_directory, AddProject.InitBundleVersion, true);
        GameCloudEditor.changeDataData(_ePlatform.None, target_directory, AddProject.InitDataVersion, true);

        ListInitProjectInfo.Add(AddProject);
        _combineProjectIndexWithSelectIndex();
        ArrayProjectBundleIdentity = ListInitProjectInfo.Select(x => x.BundleIdentify).ToArray();
        if (CurrentProject == null)
        {
            CurrentProject = AddProject;
        }

        AddingProject = false;
        AddProject    = null;
    }