예제 #1
0
    /// <summary>
    /// 获取SDK目录
    /// </summary>
    /// <returns></returns>

    /*private static string GetSDKDir()
     * {
     *  return EditorUtility.OpenFolderPanel("Please select the android sdk directory", SDK_PATH_DEFAULT, "");
     * }*/

    /// <summary>
    /// 更改标题画面
    /// </summary>
    /// <param name="titleName"></param>
    private static bool CopyLogo()
    {
        try
        {
            string src  = Application.dataPath + "/Projects/" + PlayerSettings.companyName + "/Logo";
            string desc = Application.dataPath + "/Logo";

            Debug.Log("copy file from:" + src + " to:" + desc);

            if (!Directory.Exists(src))
            {
                Debug.Log(src + " dir is not exists");
                return(true);
            }

            if (Directory.Exists(desc))
            {
                CFile.DeleteDirectory(desc);
            }

            CFile.CopyDirectory(src, desc);

            AssetDatabase.Refresh();
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
            return(false);
        }

        return(true);
    }
예제 #2
0
    /// <summary>
    /// 拷贝自定义文件
    /// </summary>
    /// <returns></returns>
    private static bool CopyCustomAssets(ProjectBuildData data)
    {
        try
        {
            var srcDirs  = new[] { "Streaming", "Audio", "Res" };
            var destDirs = new[] { "StreamingAssets", "Audio", "Resources" };
            for (int i = 0; i < srcDirs.Length; i++)
            {
                string srcDir  = srcDirs[i];
                string destDir = destDirs[i];

                string src        = Application.dataPath + "/Projects/" + PlayerSettings.companyName + "/" + srcDir;
                string defaultSrc = Application.dataPath + "/Projects/default/" + srcDir;
                string dest       = Application.dataPath + "/" + destDir;

                Debug.Log("copy file from:" + src + " to:" + dest);

                if (!Directory.Exists(src))
                {
                    src = defaultSrc;
                    if (!Directory.Exists(src))
                    {
                        Debug.Log(src + " dir is not exists");
                        continue;
                    }
                }

                CFile.CopyDirectory(src, dest);
            }

            AssetDatabase.Refresh();
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
            return(false);
        }

        return(true);
    }
예제 #3
0
        private void Rename(string FullPathSrcOld, FileInfo fiSrc)
        {
            bool IsFile = !CFile.GetIsFolder(fiSrc);

            for (int i = 0, i2 = this._aRootFolderDest.Length; i < i2; i++)
            {
                string   FullPathDestOld = this._aRootFolderDest[i] + FullPathSrcOld.Substring(this._RootFolderSrc.Length);
                FileInfo fiDestOld       = null;
                if (IsFile)
                {
                    if (File.Exists(FullPathDestOld))
                    {
                        fiDestOld = new FileInfo(FullPathDestOld);
                    }
                }
                else
                {
                    if (Directory.Exists(FullPathDestOld))
                    {
                        fiDestOld = new FileInfo(FullPathDestOld);
                    }
                }

                if (IsFile)
                {
                    if (!IsValidExtension(fiSrc))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!IsValidFolder(fiSrc))
                    {
                        continue;
                    }
                }

                string FullPathDestNew = this._aRootFolderDest[i] + fiSrc.FullName.Substring(this._RootFolderSrc.Length);

                if (fiDestOld == null)
                {
                    try
                    {
                        string Folder = "";
                        if (IsFile)
                        {
                            Folder = Path.GetDirectoryName(FullPathDestNew);
                        }
                        else
                        {
                            Folder = FullPathDestNew;
                        }

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

                        if (IsFile)
                        {
                            File.Copy(fiSrc.FullName, FullPathDestNew, true);
                        }
                        else
                        {
                            CFile f = new CFile();
                            f.BeforeFileCopy += new EventHandler <CBeforeFileCopyEventArgs>(f_BeforeFileCopy);
                            f.CopyDirectory(fiSrc.FullName, FullPathDestNew);
                        }

                        WriteLog(LogTypes.Copy, fiSrc.FullName, "", FullPathDestNew, null);
                    }
                    catch (Exception ex)
                    {
                        WriteLog(LogTypes.FailCopy, fiSrc.FullName, "", FullPathDestNew, ex);
                    }
                }
                else
                {
                    try
                    {
                        fiDestOld.MoveTo(FullPathDestNew);

                        WriteLog(LogTypes.Rename, FullPathDestOld, "", FullPathDestNew, null);
                    }
                    catch (Exception ex)
                    {
                        WriteLog(LogTypes.FailRename, FullPathDestOld, "", FullPathDestNew, ex);
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 설정된 조건에 따라 원본 폴더의 모든 파일을 대상 폴더에 복사함.
        /// </summary>
        public void CopyAll()
        {
            string FolderSrc = this._RootFolderSrc;

            if (_DestType == DestTypes.FileSystem)
            {
                List <string> aDirectoryChecked = new List <string>();

                for (int i = 0, i2 = this._aRootFolderDest.Length; i < i2; i++)
                {
                    if (this._aFullPathSrc != null)
                    {
                        for (int j = 0; j < this._aFullPathSrc.Length; j++)
                        {
                            string FullPathSrc  = this._aFullPathSrc[j];
                            string FullPathDest = CPath.GetFullPathDest(FolderSrc, this._aRootFolderDest[i], FullPathSrc);

                            string FolderDest = CPath.GetFolderName(FullPathDest);
                            if (aDirectoryChecked.IndexOf(FolderDest) == -1)
                            {
                                if (!Directory.Exists(FolderDest))
                                {
                                    Directory.CreateDirectory(FolderDest);
                                }

                                aDirectoryChecked.Add(FolderDest);
                            }

                            _File.CopyFile(FullPathSrc, FullPathDest);
                        }
                    }
                    else
                    {
                        _File.CopyDirectory(FolderSrc, this._aRootFolderDest[i]);
                    }
                }
            }
            else if (_DestType == DestTypes.Ftp)
            {
                for (int i = 0, i2 = this._aFtpInfoDest.Length; i < i2; i++)
                {
                    CFtp2        FtpCur   = _aFtp[i];
                    CFtpInfoSync InfoSync = (CFtpInfoSync)FtpCur.Info;

                    List <string> aDirectoryChecked = new List <string>();

                    if (this._aFullPathSrc != null)
                    {
                        for (int j = 0; j < this._aFullPathSrc.Length; j++)
                        {
                            string FullPathSrc  = this._aFullPathSrc[j];
                            string FullPathDest = CUrl.GetFullUrlDest(FolderSrc, InfoSync.Folder, FullPathSrc);

                            string FolderDest = CUrl.GetDirectoryName(FullPathDest);
                            if (aDirectoryChecked.IndexOf(FolderDest) == -1)
                            {
                                if (!FtpCur.DirectoryExists(FolderDest))
                                {
                                    FtpCur.CreateDirectory(FolderDest);
                                }

                                aDirectoryChecked.Add(FolderDest);
                            }

                            FtpCur.UploadFile(FullPathSrc, FullPathDest);
                        }
                    }
                    else
                    {
                        FtpCur.UploadDirectory(FolderSrc, InfoSync.Folder);
                    }
                }
            }
        }
예제 #5
0
    private static bool Encrypt(string dir, string fileName)
    {
        try
        {
            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows)
            {
                //step1, encrypt the lib
                string name = dir + fileName.Replace(".exe", "_Data") + "/Managed/Assembly-CSharp.dll";
                Debug.Log("encrypt assymble file:" + name);
                var bytes = File.ReadAllBytes(name);
                ;
                bytes = Encrypt(bytes, DesKeysVector);
                File.WriteAllBytes(name, bytes);

                //step2, copy libmono into the lib dir
                string src  = Application.dataPath + "/../BuildAssets/Mono/Windows/Mono.dll";
                string dest = dir + fileName.Replace(".exe", "_Data") + "/Mono/Mono.dll";
                File.Copy(src, dest, true);
            }
            else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                //step1, encrypt the lib
                string name = dir + fileName + "/" + PlayerSettings.productName +
                              "/assets/bin/Data/Managed/Assembly-CSharp.dll";
                Debug.Log("encrypt assymble file:" + name);
                var bytes = File.ReadAllBytes(name);
                bytes = Encrypt(bytes, DesKeysVector);
                File.WriteAllBytes(name, bytes);


                //step2, copy libmono into the lib dir
                if ((PlayerSettings.Android.targetDevice & AndroidTargetDevice.ARMv7) != 0)
                {
                    string src  = Application.dataPath + "/../BuildAssets/Mono/Android/armeabi-v7a";
                    string dest = dir + fileName + "/" + PlayerSettings.productName + "/libs/armeabi-v7a";
                    CFile.CopyDirectory(src, dest);
                }

                if ((PlayerSettings.Android.targetDevice & AndroidTargetDevice.x86) != 0)
                {
                    string src  = Application.dataPath + "/../BuildAssets/Mono/Android/x86";
                    string dest = dir + fileName + "/" + PlayerSettings.productName + "/libs/x86";
                    CFile.CopyDirectory(src, dest);
                }

                //写key
                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
                {
                    if (!UpdateAndroidProject(dir, fileName))
                    {
                        Debug.LogError("update android project failed");
                        return(false);
                    }
                }

                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
                {
                    if (!BuildAndroidProject(dir, fileName))
                    {
                        Debug.LogError("build android project failed");
                        return(false);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
            return(false);
        }

        return(true);
    }