예제 #1
0
 void OnPlatformChange()
 {
     if (buildPlatform == BuildPlatform.IOS && xcodeSetting == null)
     {
         AppInfoConfig appInfoConfig = AssetDatabasex.LoadAssetOfType <AppInfoConfig>("AppInfoConfig");
         xcodeSetting = new AFXcodeSetting(AssetDatabase.GetAssetPath(appInfoConfig));
         TextAsset textAsset = AssetDatabasex.LoadAssetOfType <TextAsset>("XcodeSetting");
         if (textAsset != null)
         {
             xcodeSetting.InitWithExit(SerializeHelper.FromJson <XcodeSetting>(textAsset.text));
         }
     }
 }
예제 #2
0
        protected override OdinMenuTree BuildMenuTree()
        {
            OdinMenuTree tree = new OdinMenuTree();

            this.titleContent                  = new GUIContent("AFramework设置");
            tree.Config.DrawSearchToolbar      = true;
            tree.DefaultMenuStyle.Height       = 30;
            tree.Selection.SupportsMultiSelect = false;

            AppInfoConfig   appInfoConfig   = AssetDatabasex.LoadAssetOfType <AppInfoConfig>("AppInfoConfig");
            ABAndPathConfig aBAndPathConfig = new ABAndPathConfig();
            AFXcodeSetting  aFXcodeSetting  = new AFXcodeSetting(AssetDatabase.GetAssetPath(appInfoConfig));
            TextAsset       textAsset       = AssetDatabasex.LoadAssetOfType <TextAsset>("XcodeSetting");

            if (textAsset != null)
            {
                aFXcodeSetting.InitWithExit(SerializeHelper.FromJson <XcodeSetting>(textAsset.text));
            }
            APPBuildWindows buildAppWindows = AssetDatabasex.LoadAssetOfType <APPBuildWindows>("APPBuildWindows");

            buildAppWindows.xcodeSetting = aFXcodeSetting;
            buildAppWindows.SyncSceneWithBuildSetting();

            tree.Add("App基本信息配置", appInfoConfig);
            tree.Add("AB打包配置", aBAndPathConfig);
            tree.Add("APP打包配置", buildAppWindows);
            tree.Add("AR SDK配置", new ARSDKConfig());
            tree.Add("Unity配置", AssetDatabasex.LoadAssetOfType <AFUnitySettingWindows>("AFUnitySetting"));
            tree.Add("UI配置", AssetDatabasex.LoadAssetOfType <AFUIConfig>("AFUIConfig"));
            tree.Add("多语言配置", AssetDatabasex.LoadAssetOfType <LanuageInfo>("LanuageInfo"));
            tree.Add("查找重复文件", new SearchDuplicateFiles());
            tree.Add("批量更改Raycast Target选项", new ChangeRaycastTarget());
            tree.Add("批量更换字体", new ChangeFont());

            tree.Selection.SupportsMultiSelect = false;
            List <OdinMenuItem>   menuItems     = tree.MenuItems;
            OdinMenuTreeSelection odinMenuItems = tree.Selection;

            odinMenuItems.Add(menuItems[selectIndex]);
            return(tree);
        }
예제 #3
0
        /// <summary>
        /// 版本文件下载回调
        /// </summary>
        /// <param name="data"></param>
        /// <param name="downResult"></param>
        /// <param name="downError"></param>
        public void AppVersionCall(byte[] data, DownStatus downResult = DownStatus.Sucess, string downError = "")
        {
            if (downResult != DownStatus.Sucess)
            {
                AFLogger.e("下载Version文件未成功,请检查!");
                return;
            }
            AppInfoConfig appInfoConfig = SerializeHelper.FromJson <AppInfoConfig>(System.Text.Encoding.UTF8.GetString(data));
            double        appV          = 0;

            if (ABConfig.isDevelopOrOnlineAB)
            {
                appV = ABConfig.ABDevelopmentVersion;
            }
            else
            {
                appV = ABConfig.ABOnlineVersion;
            }
            if (appInfoConfig.AvailableABVersions.Contains(appV))
            {
                if (appInfoConfig.NewABVersion.Contains(appV))
                {
                    versionStatus = APPVersionStatus.Newest;
                }
                else
                {
                    versionStatus = APPVersionStatus.Update;
                }
                if (CheckABConfig())
                {
                    ABInit(default(byte[]));
                }
            }
            else
            {
                versionStatus = APPVersionStatus.Abandon;
                ABCheckInitFinish.InvokeGracefully(versionStatus);
                IsABCheckFinish = true;
            }
        }
예제 #4
0
        public static void Build()
        {
            m_BundleTargetPath = EditorAssetPath.ProjectPath + "AssetBundle/" + buildTarget.ToString() + "/";
            AppInfoConfig appInfoConfig = AssetDatabasex.LoadAssetOfType <AppInfoConfig>("AppInfoConfig");
            AF_ABConfig   abConfig      = AssetDatabasex.LoadAssetOfType <AF_ABConfig>("AF_ABConfig");

            EditorAssetPath.InitABBuildPath(abConfig);
            //清空
            m_ConfigFile.Clear();
            m_AllFileAB.Clear();
            m_AllFileDir.Clear();
            m_AllPrefabDir.Clear();
            string mTargetPath = EditorAssetPath.ABTargetPath;
            string mInfoPath   = EditorAssetPath.ABInfoPath;

            if (abConfig.packageABType != PackageABType.PhoneAB)
            {
                mTargetPath = EditorAssetPath.ABTargetPath + buildTarget.ToString() + "/";
                mInfoPath   = EditorAssetPath.ABInfoPath + buildTarget.ToString() + "/";
            }

            if (Directory.Exists(mTargetPath))
            {
                FileUtil.DeleteFileOrDirectory(mTargetPath);
            }
            if (Directory.Exists(mInfoPath))
            {
                FileUtil.DeleteFileOrDirectory(mInfoPath);
            }
            Directory.CreateDirectory(mInfoPath);
            Directory.CreateDirectory(mTargetPath);
            Directory.CreateDirectory(m_BundleTargetPath);
            //创建APP版本文件
            FileHelper.CreatFile(EditorAssetPath.AppInfoPath, SerializeHelper.ToByteArray(appInfoConfig), true);
            Dictionary <string, bool> ClassToNeedPackageAB = new Dictionary <string, bool>();

            for (int i = 0; i < abConfig.m_AllClass.Count; i++)
            {
                if (abConfig.m_AllClass[i].isSameAppType(abConfig.CurrentAppType))
                {
                    ClassToNeedPackageAB.Add(abConfig.m_AllClass[i].ABClassType, abConfig.m_AllClass[i].isNeedPackageAB);
                }
            }
            //剔除重复路径,将单个文件及文件夹的路径保存下来
            //先处理文件夹再处理单个文件,因为有可能prefab依赖某个文件中的东西,所以要进行过滤
            foreach (AF_OneAB oneAB in abConfig.m_AllFileAB)
            {
                bool isNeedPackageAB = false;
                for (int k = 0; k < oneAB.CategoryOfOwnership.Count; k++)
                {
                    if (ClassToNeedPackageAB.ContainsKey(oneAB.CategoryOfOwnership[k]) &&
                        ClassToNeedPackageAB[oneAB.CategoryOfOwnership[k]])
                    {
                        isNeedPackageAB = true;
                        break;
                    }
                }
                if (!isNeedPackageAB)
                {
                    continue;
                }
                if (m_AllFileDir.ContainsKey(oneAB.mABIdentifier))
                {
                    AFLogger.EditorErrorLog("AB包配置名字重复,请检查!");
                    EditorUtility.ClearProgressBar();
                }
                else
                {
                    m_AllFileDir.Add(oneAB.mABIdentifier, oneAB.Path);
                    //保存已打包的AB包路径
                    m_AllFileAB.Add(oneAB.Path);
                    m_ConfigFile.Add(oneAB.Path);
                }
            }
            string[] AllPrefabsPath = abConfig.GetAllPrefabsPath();
            if (AllPrefabsPath.Length > 0)
            {
                //获取路径下的所有prefab
                string[] allStr = AssetDatabase.FindAssets("t:Prefab", AllPrefabsPath);
                AFLogger.EditorInfoLog("获取的路径长度:" + allStr.Length);
                for (int i = 0; i < allStr.Length; i++)
                {
                    bool isNeedPackageAB = false;
                    for (int k = 0; k < abConfig.m_AllPrefabAB[i].CategoryOfOwnership.Count; k++)
                    {
                        if (ClassToNeedPackageAB.ContainsKey(abConfig.m_AllPrefabAB[i].CategoryOfOwnership[k]) &&
                            ClassToNeedPackageAB[abConfig.m_AllPrefabAB[i].CategoryOfOwnership[k]])
                        {
                            isNeedPackageAB = true;
                            break;
                        }
                    }
                    if (!isNeedPackageAB)
                    {
                        continue;
                    }
                    //GUID转asset路径
                    string path = AssetDatabase.GUIDToAssetPath(allStr[i]);
                    EditorUtility.DisplayProgressBar("查找Prefab", "Prefab:" + path, i * 1.0f / allStr.Length);
                    m_ConfigFile.Add(path);
                    if (!ContainAllFileAB(path))
                    {
                        //获取资源的所有依赖
                        string[]      allDepend     = AssetDatabase.GetDependencies(path);
                        List <string> allDependPath = new List <string>();
                        //遍历依赖文件
                        for (int j = 0; j < allDepend.Length; j++)
                        {
                            if (!ContainAllFileAB(allDepend[j]) && !allDepend[j].EndsWith(".cs", System.StringComparison.Ordinal))
                            {
                                m_AllFileAB.Add(allDepend[j]);
                                allDependPath.Add(allDepend[j]);
                            }
                        }
                        if (m_AllPrefabDir.ContainsKey(abConfig.m_AllPrefabAB[i].mABIdentifier))
                        {
                            AFLogger.EditorErrorLog("存在相同名字的Prefab!名字:" + abConfig.m_AllPrefabAB[i].mABIdentifier);
                            EditorUtility.ClearProgressBar();
                        }
                        else
                        {
                            m_AllPrefabDir.Add(abConfig.m_AllPrefabAB[i].mABIdentifier, allDependPath);
                        }
                    }
                }
            }
            //点击打包之后可以看见更改的文件的.meta文件改变
            //文件夹设置ABName
            foreach (string name in m_AllFileDir.Keys)
            {
                SetABName(name, m_AllFileDir[name]);
            }
            //单个文件设置包名
            foreach (string name in m_AllPrefabDir.Keys)
            {
                SetABName(name, m_AllPrefabDir[name]);
            }

            //打包
            BunildAssetBundle(abConfig);

            //清除AB包名,因为上面更改了.meta文件,我们很多时候会使用svn或者git,有可能会导致一不小心上传特别乱
            string[] oldABNames = AssetDatabase.GetAllAssetBundleNames();
            for (int i = 0; i < oldABNames.Length; i++)
            {
                AssetDatabase.RemoveAssetBundleName(oldABNames[i], true);
                EditorUtility.DisplayProgressBar("清除AB包名", "名字:" + oldABNames[i], i * 1.0f / oldABNames.Length);
            }

            EditorUtility.ClearProgressBar();
            //根据设置生成文件
            ABBuildFinishEvent.BundleFinish(mTargetPath, m_BundleTargetPath, abConfig, mInfoPath, appInfoConfig);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();
        }
예제 #5
0
        /// <summary>
        /// AB包打包完成后执行的函数,这里是将AB包移到指定的路径并生成对应的info文件
        /// </summary>
        /// <param name="mTargetPath">AB包目标路径,可以在ABCommonPath脚本中设置</param>
        /// <param name="m_BunleTargetPath">AB包初步路径</param>
        /// <param name="abConfig"></param>
        /// <param name="mInfoPath">info信息文件路径</param>
        /// <param name="AppInfoConfig"></param>
        public static void BundleFinish(string mTargetPath, string m_BunleTargetPath, AF_ABConfig abConfig, string mInfoPath, AppInfoConfig AppInfoConfig)
        {
            //一个类别对应的info
            Dictionary <string, OneABClassInfo> ClassToInfo    = new Dictionary <string, OneABClassInfo>();
            Dictionary <string, bool>           ClassToAppType = new Dictionary <string, bool>();
            Dictionary <string, string>         ABNameToPath   = new Dictionary <string, string>();

            for (int i = 0; i < abConfig.m_AllClass.Count; i++)
            {
                string classStr = abConfig.m_AllClass[i].ABClassType;
                ClassToAppType.Add(classStr, abConfig.m_AllClass[i].isSameAppType(abConfig.CurrentAppType));
                OneABClassInfo oneClassInfo = new OneABClassInfo();
                oneClassInfo.RecogType = abConfig.m_AllClass[i].ARrecogType;
                switch (oneClassInfo.RecogType)
                {
                case ARRecogType.DataSet:
                    List <OneDataSetInfo> dataSetInfos = new List <OneDataSetInfo>();
                    foreach (OneDataSet oneDataSet in abConfig.m_AllClass[i].dataSetList)
                    {
                        OneDataSetInfo oneDataSetInfo = new OneDataSetInfo();
                        oneDataSetInfo.TargetDataSet = oneDataSet.TargetDataSetName;
                        //记录识别图资料
                        oneDataSetInfo.TargetInfo = new Dictionary <string, OneTargetInfo>();
                        char[] t           = abConfig.defaultDataSetPath.ToCharArray();
                        string dataSetPath = abConfig.defaultDataSetPath;
                        if (t[t.Length - 1] != '/')
                        {
                            dataSetPath += "/";
                        }
                        string targetDataSetName = oneDataSet.TargetDataSetName;
                        string xmlMD5            = "";
                        string datMD5            = "";
                        if (abConfig.packageABType == PackageABType.StreamingAssetAB)
                        {
                            string vuforiaPath = Application.streamingAssetsPath + "/Vuforia/";
                            Directory.CreateDirectory(vuforiaPath);
                            //拷贝识别资源
                            if (!FileHelper.CopyFile(dataSetPath +
                                                     targetDataSetName
                                                     + ".xml", vuforiaPath + targetDataSetName + ".xml"))
                            {
                                break;
                            }
                            xmlMD5 = FileHelper.getFileHash(vuforiaPath + targetDataSetName + ".dat");
                            if (!FileHelper.CopyFile(dataSetPath +
                                                     targetDataSetName
                                                     + ".dat", vuforiaPath + targetDataSetName + ".dat"))
                            {
                                break;
                            }
                            datMD5 = FileHelper.getFileHash(vuforiaPath + targetDataSetName + ".xml");

                            if (!oneClassInfo.ABName.ContainsKey(targetDataSetName + ".xml") &&
                                !oneClassInfo.ABName.ContainsKey(targetDataSetName + ".dat"))
                            {
                                //将识别资源添加到ABName中,因为也是要下载的,同时记录其大小
                                oneClassInfo.ABName.Add(targetDataSetName + ".xml",
                                                        FileHelper.GetFileSize(vuforiaPath + targetDataSetName + ".xml"));
                                oneClassInfo.ABName.Add(targetDataSetName + ".dat",
                                                        FileHelper.GetFileSize(vuforiaPath + targetDataSetName + ".dat"));
                            }
                        }
                        else
                        {
                            //拷贝识别资源
                            if (!FileHelper.CopyFile(dataSetPath +
                                                     targetDataSetName
                                                     + ".xml", mTargetPath + targetDataSetName + ".xml"))
                            {
                                break;
                            }
                            xmlMD5 = FileHelper.getFileHash(dataSetPath +
                                                            targetDataSetName
                                                            + ".xml");

                            if (!FileHelper.CopyFile(dataSetPath
                                                     + targetDataSetName + ".dat",
                                                     mTargetPath + targetDataSetName + ".dat"))
                            {
                                break;
                            }
                            datMD5 = FileHelper.getFileHash(dataSetPath +
                                                            targetDataSetName + ".dat");

                            if (!oneClassInfo.ABName.ContainsKey(targetDataSetName + ".xml") &&
                                !oneClassInfo.ABName.ContainsKey(targetDataSetName + ".dat"))
                            {
                                //将识别资源添加到ABName中,因为也是要下载的,同时记录其大小
                                oneClassInfo.ABName.Add(targetDataSetName + ".xml",
                                                        FileHelper.GetFileSize(mTargetPath + targetDataSetName + ".xml"));
                                oneClassInfo.ABName.Add(targetDataSetName + ".dat",
                                                        FileHelper.GetFileSize(mTargetPath + targetDataSetName + ".dat"));
                            }
                        }

                        //添加识别资源的MD5码,
                        if (!oneClassInfo.FileMD5.ContainsKey(targetDataSetName + ".xml") &&
                            !oneClassInfo.FileMD5.ContainsKey(targetDataSetName + ".dat"))
                        {
                            // Debug.Log("第一次添加xml MD5:" + CategoryOfOwnershipS + " " + targetDataSetName);
                            oneClassInfo.FileMD5.Add(targetDataSetName + ".xml", xmlMD5);
                            oneClassInfo.FileMD5.Add(targetDataSetName + ".dat", datMD5);
                        }
                        else
                        {
                            //是已经打包过的类别
                            // Debug.Log("重复添加xml MD5:" + CategoryOfOwnershipS + " " + targetDataSetName);
                        }
                        if (!ABNameToPath.ContainsKey(targetDataSetName + ".xml") &&
                            !ABNameToPath.ContainsKey(targetDataSetName + ".dat"))
                        {
                            ABNameToPath.Add(targetDataSetName + ".xml", classStr + "/" + targetDataSetName + ".xml");
                            ABNameToPath.Add(targetDataSetName + ".dat", classStr + "/" + targetDataSetName + ".dat");
                        }


                        for (int j = 0; j < oneDataSet.mImagetTargetInfo.Count; j++)
                        {
                            oneDataSetInfo.TargetInfo.Add(oneDataSet.mImagetTargetInfo[j].ImageTargetName, oneDataSet.mImagetTargetInfo[j]);
                        }
                        dataSetInfos.Add(oneDataSetInfo);
                    }
                    oneClassInfo.dataSetInfos = dataSetInfos;
                    break;

                case ARRecogType.Plane:
                    oneClassInfo.ResInfoForPlane = abConfig.m_AllClass[i].ResInfoForPlane;
                    break;
                }
                oneClassInfo.isNeedPackageAB = abConfig.m_AllClass[i].isNeedPackageAB;
                ClassToInfo.Add(classStr, oneClassInfo);
            }
            List <AF_OneAB> allAB = new List <AF_OneAB>();

            foreach (AF_OneAB oneAB in abConfig.m_AllFileAB)
            {
                allAB.Add(oneAB);
            }
            foreach (AF_OneAB oneAB in abConfig.m_AllPrefabAB)
            {
                allAB.Add(oneAB);
            }
            //遍历
            for (int i = 0; i < allAB.Count; i++)
            {
                EditorUtility.DisplayProgressBar("整理AB包资源", "名字TargetDataSet:" + allAB[i].mABIdentifier, i * 1.0f / (allAB.Count + abConfig.m_AllPrefabAB.Count));
                //分别拷贝到对应的类别中
                for (int k = 0; k < allAB[i].CategoryOfOwnership.Count; k++)
                {
                    string CategoryOfOwnershipS = allAB[i].CategoryOfOwnership[k];
                    if (!ClassToInfo.ContainsKey(CategoryOfOwnershipS))
                    {
                        AFLogger.EditorErrorLog(allAB[i].mABIdentifier + "所属类型错误,不在m_AllClass内,请检查");
                        EditorUtility.ClearProgressBar();
                        return;
                    }
                    //不是当前APP Type的类型,跳过
                    if (!ClassToAppType[CategoryOfOwnershipS])
                    {
                        continue;
                    }
                    if (!ClassToInfo[CategoryOfOwnershipS].isNeedPackageAB)
                    {
                        continue;
                    }
                    string ABIdentifier = allAB[i].mABIdentifier.ToLower();

                    //拷贝AB包
                    if (!FileHelper.CopyFile(m_BunleTargetPath + "/" + ABIdentifier,
                                             mTargetPath + ABIdentifier))
                    {
                        break;
                    }
                    //添加AB包的MD5码
                    string ABMD5 = FileHelper.getFileHash(m_BunleTargetPath + "/" + ABIdentifier);
                    if (!ClassToInfo[CategoryOfOwnershipS].FileMD5.ContainsKey(ABIdentifier))
                    {
                        ClassToInfo[CategoryOfOwnershipS].FileMD5.Add(ABIdentifier, ABMD5);
                    }
                    //是已经打包过的类别
                    if (ABNameToPath.ContainsKey(ABIdentifier))
                    {
                        ABNameToPath.Add(ABIdentifier, CategoryOfOwnershipS + "/" + ABIdentifier);
                    }
                    //保存文件的大小
                    ClassToInfo[CategoryOfOwnershipS].ABName.Add(ABIdentifier,
                                                                 FileHelper.GetFileSize(mTargetPath + ABIdentifier));
                }
            }
            //保存info文件
            for (int i = 0; i < abConfig.m_AllClass.Count; i++)
            {
                if (abConfig.m_AllClass[i].isNeedPackageAB)
                {
                    SerializeHelper.SaveJson <OneABClassInfo>(ClassToInfo[abConfig.m_AllClass[i].ABClassType.ToString()],
                                                              mInfoPath + abConfig.m_AllClass[i].ABClassType + "Info.txt");
                }
            }
            if (abConfig.configWritingMode == ConfigWritingMode.Binary)
            {
                FileHelper.DeleteFile(PathTool.ProjectPath + "Assets/AssetbundleConfig.bytes");
                FileHelper.CopyFile(m_BunleTargetPath + "assetbundleconfig", mTargetPath + "AssetbundleConfig");
            }
            AssetDatabase.Refresh();
            Debug.Log("资源拷贝完毕,保存路径为 : " + mTargetPath);
            EditorUtility.RevealInFinder(mTargetPath);
        }
예제 #6
0
 public void ABSysInit(AppInfoConfig appInfo, AF_ABConfig ABConfig)
 {
     this.appInfo  = appInfo;
     this.ABConfig = ABConfig;
     AFLogger.d("ABSysInit");
 }