Exemple #1
0
    //-----------------------------------------------------------------------------
    public static string NtfPack(List <string> vPths, List <string> vfAry, string file, BuildTarget tgt, bool silence
                                 , GameBundleVersionControl version, PackageVersion.Version cfgVersion)
    {
        List <string> fAry = new List <string>();

        if (vfAry != null)
        {
            fAry.AddRange(vfAry);
        }
        foreach (string sPth in vPths)
        {
            List <string> vfs = ArchiveUtil.NtfGetFiles(sPth, true, ArchiveUtil.mSkips);
            fAry.AddRange(vfs);
        }

        BuildGameCMD.BuildGamePack(file, fAry, tgt, silence, version);
        string packageName = Path.GetFileName(file);

        packageName = packageName.ToLower();
        if (version.m_version.HavePackage(packageName))
        {
            PackageVersion.Version v = version.m_version.LookupPackageVersion(packageName);
            v.m_isExternPackage  = cfgVersion.m_isExternPackage;
            v.m_isAliveInRuntime = cfgVersion.m_isAliveInRuntime;
            version.m_version.AddPackage(packageName, v);
        }
        return(packageName);
    }
Exemple #2
0
    public void NtfSearchPackVers()
    {
        string verPth = "PackVers/";

        mVerList = ArchiveUtil.NtfGetFiles(verPth, false, "*.csv");
        PackVerCfg.NtfLoadVerCfg("PackVers/VerConfig.txt");
        NtfRefreshItemVer();
    }
Exemple #3
0
    //--------------------------------------------------------------------------------------------
    void NtfRefreshScene()
    {
        mScnCtrl.ResetCtrl();
        List <string> vAry = ArchiveUtil.NtfGetFiles(GetGamePath(), true, "*.unity");

        foreach (string sPth in vAry)
        {
            string sf = ArchiveUtil.NtfPathAfter(mPath, sPth);
            mScnCtrl.AddItem(new TglItem(true, sf));
        }
    }
Exemple #4
0
    //--------------------------------------------------------------------------------------------
    // 搜索打包用文件
    static public List <string> SearchPackFiles(List <string> pthLst)
    {
        List <string> files = new List <string>();

        foreach (string pth in pthLst)
        {
            List <string> fList = ArchiveUtil.NtfGetFiles(pth, true);
            files.AddRange(fList);
        }
        return(files);
    }
Exemple #5
0
    //--------------------------------------------------------------------------------------------
    // 临时版本, 资源拷贝 Resources/ 目录下, 完成之后删除
    public bool BuildTempGame(BuildTarget tgt)
    {
        // 保存路径
        string szTgtNm = BuildGameCMD.GetTargetName(tgt);
        string szPath  = BuildGameCMD.GetBuildFolder(tgt);
        string szEx    = BuildGameCMD.GetTargetExt(tgt);
        string szTitle = "Save " + szTgtNm + " App";
        string szApp   = szTgtNm + "_" + mGame;
        string file    = EditorUtility.SaveFilePanel(szTitle, szPath, szApp, szEx);

        if (file.Length > 0)
        {
            //string sPth = "Assets/" + mPath;   // 原始资源目录
            string dPth = "Assets/Resources/";
            //string dfil = "Assets/Resources.meta";

            // 若存在则删除
            //if (File.Exists(dfil)) FileUtil.DeleteFileOrDirectory(dfil);
            //if (Directory.Exists(dPth)) FileUtil.DeleteFileOrDirectory(dPth);
            //AssetDatabase.Refresh();
            //ArchiveUtil.NtfCopyFiles(sPth, dPth);   // 拷贝文件, 内部有过滤
            //AssetDatabase.Refresh();


            List <string> vAry = ArchiveUtil.NtfGetFiles(dPth, true, "*.unity"); // 搜索场景文件
            foreach (string sf in vAry)                                          // 找到启动用场景
            {
                string ft = sf.ToLower();
                //if (ft.Contains("launch"))
                if (ft.Contains("demo-summer-a-am"))
                {
                    vAry.Remove(sf);
                    vAry.Insert(0, sf);
                    break;
                }
            }
            BuildGameCMD.BuildGamePlayer(file, vAry, tgt, true);
            // 结束后删除这些文件
            //if (Directory.Exists(dPth)) FileUtil.DeleteFileOrDirectory(dPth);
            //if (File.Exists(dfil)) FileUtil.DeleteFileOrDirectory(dfil);
            //AssetDatabase.Refresh();
            return(true);
        }
        return(false);
    }
Exemple #6
0
    //-----------------------------------------------------------------------------
    // 找到当前游戏的启动场景  !!!! 这里要按游戏来搜索 !!!!
    string FindGameLaunch()
    {
        string        sLaunch = "";
        string        szPth   = Application.dataPath;//GetGamePath();// Application.dataPath;
        List <string> vAry    = ArchiveUtil.NtfGetFiles(szPth, true, "*.unity");

        foreach (string sPth in vAry)
        {
            string sf = sPth.ToLower();
            if (sf.Contains("launch"))
            {
                sLaunch = sPth;
                break;
            }
        }
        //sLaunch = ArchiveUtil.NtfPathAfter(szPth, sLaunch);
        sLaunch = ArchiveUtil.NtfPathAfterAssets(sLaunch);
        return(sLaunch);
    }
Exemple #7
0
    //[@MenuItem(@"打包版本/编译三国(简单测试用)")]
    //public static void BuildResourcesB()
    //{

    //}

    //[@MenuItem(@"Package/构建场景列表")]
    public static void BuildSettingsScene()
    {
        ArchiveUtil.NtfInitSkips();
        ArchiveUtil.AddSkip("NGUI");
        ArchiveUtil.AddSkip("Plugins");
        List <string> vScn = ArchiveUtil.NtfGetFiles(Application.dataPath, true, "*.unity");

        if (vScn.Count > 0)
        {
            EditorBuildSettingsScene [] scnAry = new EditorBuildSettingsScene[vScn.Count];
            for (int i = 0; i < vScn.Count; ++i)
            {
                scnAry[i] = new EditorBuildSettingsScene(vScn[i], true);
            }
            EditorBuildSettings.scenes = scnAry;
        }
        ArchiveUtil.NtfInitSkips();
        Debug.Log(@"场景列表构建结束, 共加入 [ " + vScn.Count.ToString() + @" ] 个场景");
    }
Exemple #8
0
    //-----------------------------------------------------------------------------
    public static void NtfPackEachFile(string srcFolder, string targetFolder, BuildTarget tgt, bool silence
                                       , GameBundleVersionControl version, PackageVersion.Version cfgVersion)
    {
        List <string> allNeedPackedFile = ArchiveUtil.NtfGetFiles(srcFolder, true, ArchiveUtil.mSkips);
        List <string> procFileList      = new List <string>();
        string        targetPackFile;

        foreach (string singleFile in allNeedPackedFile)
        {
            procFileList.Clear();
            procFileList.Add(singleFile);
            string[] pathsOfThisFile = singleFile.Split(new char[] { '/', '\\' }, System.StringSplitOptions.RemoveEmptyEntries);
            if (pathsOfThisFile.Length < 3)
            {
                targetPackFile = singleFile.Replace('/', '_');
                targetPackFile = targetPackFile.Replace('\\', '_');
                targetPackFile = targetFolder + "/" + targetPackFile + ".pack";
            }
            else
            {
                targetPackFile = targetFolder + "/";
                for (int i = 2; i < pathsOfThisFile.Length; i++)
                {
                    targetPackFile += "_" + pathsOfThisFile[i];
                }
                targetPackFile += ".pack";
            }
            targetPackFile = targetPackFile.Replace(" ", "");
            targetPackFile = targetPackFile.ToLower();
            string packageName = Path.GetFileName(targetPackFile);
            packageName = packageName.ToLower();
            BuildGameCMD.BuildGamePack(targetPackFile, procFileList, tgt, silence, version);
            if (version.m_version.HavePackage(packageName))
            {
                PackageVersion.Version v = version.m_version.LookupPackageVersion(packageName);
                v.m_isExternPackage  = cfgVersion.m_isExternPackage;
                v.m_isAliveInRuntime = cfgVersion.m_isAliveInRuntime;
                version.m_version.AddPackage(packageName, v);
            }
        }
    }
Exemple #9
0
    void NtfBuildResPack()
    {
        string sPth = GetGamePath();

        if (m_useConfig)
        {
            //sPth = Application.dataPath+"/";
        }
        List <string>  vPths         = mGmWind.GetPublicPath(false); // 选中的公共资源列表
        List <string>  vfs           = ArchiveUtil.NtfGetFiles(sPth, false, ArchiveUtil.mSkips);
        List <TglItem> vItms         = mPthCtrl.GetSelItems();
        string         szDefaultPath = BuildGameCMD.GetBuildFolder(mGmWind.GetTarget());
        string         saveFolder    = EditorUtility.SaveFolderPanel("Save Pack File", szDefaultPath, "");

        if (saveFolder == "")
        {
            return;
        }
        m_versionControl.LoadProject(saveFolder);
        foreach (TglItem itm in vItms)
        {
            string selPath = itm.mName;
            vPths.Clear();
            vPths.Add(sPth + selPath);
            string saveFileName = saveFolder + "/" + selPath.Replace('/', '_') + ".pack";
            PackageVersion.Version cfgPackage = new PackageVersion.Version();
            cfgPackage.Init();
            cfgPackage.m_isAliveInRuntime = itm.m_isPackedAlive;
            cfgPackage.m_isExternPackage  = itm.m_isPackedExtern;
            if (itm.mIsPackedEachFile)
            {
                NtfPackEachFile(sPth + selPath, saveFolder, mGmWind.GetTarget(), true, m_versionControl, cfgPackage);
            }
            else
            {
                NtfPack(vPths, vfs, saveFileName, mGmWind.GetTarget(), true, m_versionControl, cfgPackage);
            }
        }
        m_versionControl.SaveProject(saveFolder);
        EditorUtility.DisplayDialog(@"操作提示", @"打包完成", "Ok");
    }
Exemple #10
0
    //------------------------------------------------------------------------------
    // 版本制作
    Vector2 OnLyrMakeVerInfor(BuildPackWindow src, float fx, float fy)
    {
        if (GUI.Button(new Rect(fx, fy - 2, 70, 20), @"设置目录"))
        {
            string sel = EditorUtility.OpenFolderPanel("Search Files", Application.dataPath, "");
            if (sel.Length > 0)
            {
                mMD5List.Clear();
                mMD5List = null;
                mMD5List = ArchiveUtil.NtfGetFiles(sel, true, ArchiveUtil.mSkips);
            }
        }
        if (GUI.Button(new Rect(fx + 75, fy - 2, 40, 20), @"生成"))
        {
            OnClickBtnGenMD5(src);
        }
        if (GUI.Button(new Rect(fx + 115, fy - 2, 40, 20), @"比对"))
        {
            OnClickBtnCompare(src);
        }

        string szTxt = "";

        if (ArchiveUtil.mArMsg.Length > 0)
        {
            szTxt = ArchiveUtil.mArMsg;
        }
        else if (mMD5List != null)
        {
            szTxt = @"选中文件: " + mMD5List.Count;
        }
        GUI.Label(new Rect(fx + 220, fy + 2, 150, 20), szTxt);

        if (mMD5List != null)
        {
            mMD5View.OnDrawView(fx, fy + 20, mMD5List.ToArray());
        }
        return(new Vector2(340, 280));
    }
Exemple #11
0
    //--------------------------------------------------------------------------------------------
    void NtfRefreshPath()
    {
        if (m_useConfig)
        {
            NtfRefreshPathFromConfig();
            return;
        }
        mPthCtrl.ResetCtrl();
        List <string> pths = ArchiveUtil.NtfGetDirs(GetGamePath(), false, ArchiveUtil.mSkips);

        foreach (string sPth in pths)
        {
            string sf = ArchiveUtil.NtfPathAfter(mPath, sPth) + "/";
            mPthCtrl.AddItem(new TglItem(true, sf));
        }
        string        szPth = GetGamePath();
        List <string> vfs   = ArchiveUtil.NtfGetFiles(szPth, false, ArchiveUtil.mSkips);

        foreach (string sf in vfs)
        {
            string nf = ArchiveUtil.NtfPathAfter(mPath, sf);
            mPthCtrl.AddItem(new TglItem(true, nf));
        }
    }
Exemple #12
0
    //--------------------------------------------------------------------------------------------
    //
    // 创建对应 平台的 AssetBundle 文件
    //
    // 根据目录构建. 注意: 忽略 ArchiveUtil.mSkips 里相关的
    static public bool ExportToBundle(string szPath, string saveFile, BuildTarget tgt, BundleVersionControl version = null)
    {
        List <string> fList = ArchiveUtil.NtfGetFiles(szPath, true);

        return(ExportToBundle(fList, saveFile, tgt, version));
    }
    //转换所有animation
    void Convert()
    {
        GuardInitMyData();
        string dir = "assets/resources/prefabs/anim/";
        //攻击动作列表(动作中包含就是攻击动作)
        List <string> attackAnimList = new List <string>();

        attackAnimList.Add("attack-");
        attackAnimList.Add("skill");
        attackAnimList.Add("opentreasure");
        //忽略文件列表
        List <string> skipList = new List <string>();

        skipList.Add(".meta");
        List <string> fileList = ArchiveUtil.NtfGetFiles(dir, false, skipList);

        foreach (var item in fileList)
        {
            UnityEngine.Object loadedObj = AssetDatabase.LoadMainAssetAtPath(item);
            if (loadedObj == null)
            {
                Debug.LogError("LoadMainAssetAtPath obj is null, path:" + item);
                continue;
            }
            GameObject obj = GameObject.Instantiate(loadedObj) as GameObject;
            foreach (AnimationState state in obj.GetComponent <Animation>())
            {
                AnimationClip clip = state.clip;
                if (clip != null)
                {
                    //是否是攻击动作
                    bool isAttackAnimation = false;
                    foreach (var str in attackAnimList)
                    {
                        if (clip.name.Contains(str))
                        {
                            isAttackAnimation = true;
                            break;
                        }
                    }
                    if (!isAttackAnimation)
                    {
                        continue;
                    }
                    //保存曲线到skillanim下
                    //添加新的
                    AnimationClip newClip = new AnimationClip();
                    newClip.wrapMode  = clip.wrapMode;
                    newClip.frameRate = clip.frameRate;
                    AnimationClipCurveData[] array = AnimationUtility.GetAllCurves(clip);
                    foreach (var data in array)
                    {
                        if (!m_typeList.Contains(data.type.BaseType))
                        {
                            continue;
                        }
                        newClip.SetCurve(data.path, data.type, data.propertyName, data.curve);
                    }
                    AnimationUtility.SetAnimationEvents(newClip, AnimationUtility.GetAnimationEvents(clip));
                    string saveDir = "/resources/skillanim/";
                    if (!System.IO.Directory.Exists(Application.dataPath + saveDir))
                    {
                        System.IO.Directory.CreateDirectory(Application.dataPath + saveDir);
                    }
                    if (System.IO.File.Exists(Application.dataPath + saveDir + clip.name + ".anim"))
                    {
                        System.IO.File.Delete(Application.dataPath + saveDir + clip.name + ".anim");
                    }
                    AssetDatabase.CreateAsset(newClip, "assets" + saveDir + clip.name + ".anim");
                }
            }
            foreach (AnimationState state in obj.GetComponent <Animation>())
            {
                AnimationClip clip = state.clip;
                if (clip != null)
                {
                    //是否是攻击动作
                    bool isAttackAnimation = false;
                    foreach (var str in attackAnimList)
                    {
                        if (clip.name.Contains(str))
                        {
                            isAttackAnimation = true;
                            break;
                        }
                    }
                    if (!isAttackAnimation)
                    {
                        continue;
                    }
                    //删除曲线
                    AnimationClipCurveData[] array = AnimationUtility.GetAllCurves(clip);
                    clip.ClearCurves();
                    foreach (var data in array)
                    {
                        if (m_typeList.Contains(data.type.BaseType))
                        {
                            continue;
                        }
                        clip.SetCurve(data.path, data.type, data.propertyName, data.curve);
                    }
                    AnimationUtility.SetAnimationEvents(clip, null);
                }
            }
            GameObject.DestroyImmediate(obj);
        }
    }