Example #1
0
        private void InitAssetInfo()
        {
            var bytes = File.ReadAllBytes(
                $"{Application.streamingAssetsPath}/{ProjectInfoDati.GetActualInstance().DevelopProjectName}/Config/AssetInfo.byte");

            _infos = SerializeUtility.DeSerialize <Dictionary <char, Dictionary <string, AssetInfo> > >(bytes);
        }
        private static void CleanAllSonDir()
        {
            locAppId  = UnityEditorUtility.GetLocAppIdAtSelectDir();
            locU3DApp = ProjectInfoDati.GetActualInstance();
            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("所选择的目录不是一个应用下的有效目录!");
                return;
            }
            var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();

            if (assetbundleEditor == null)
            {
                UnityEditorUtility.DisplayError($"应用{locAppId}没有AssetBundle打包配置!");
                throw new Exception($"应用{locAppId}没有AssetBundle打包配置!");
            }
            foreach (var dir in AllSonDirs)
            {
                if (!dir.StartsWith(locU3DApp.ProjectAssetDatabaseDir))
                // dir.StartsWith(appHelper.StreamingAssetsDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    continue;
                }
                assetbundleEditor.CleanBuildSettingAtDir(dir);
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
Example #3
0
        private static void BuildAssetBundle(AssetBundleBuildSetting dirSetting)
        {
            var projectInfo = ProjectInfoDati.GetActualInstance();
            var startTime   = DateTime.Now;

            Debug.Log($"应用{projectInfo.DevelopProjectName}在{DateTime.Now}开始执行AssetBundle打包!");
            var assetBundleOutPutDir = projectInfo.AssetBundleBuildDir;

            IOUtility.EnsureDirExist(assetBundleOutPutDir);
            try
            {
                BuildPipeline.BuildAssetBundles(assetBundleOutPutDir,
                                                BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
            }
            catch (Exception e)
            {
                Debug.Log($"应用{projectInfo.DevelopProjectName}的AssetBundle打包操作发生异常," +
                          $"异常信息为{e.Message}!");
                throw;
            }

            var endTime       = DateTime.Now;
            var costTimeStamp = (endTime - startTime);
            var minutes       = costTimeStamp.Minutes;
            var seconds       = costTimeStamp.Seconds;

            buildTotalSecond += costTimeStamp.TotalSeconds;
            Debug.Log($"应用{projectInfo.DevelopProjectName}在{DateTime.Now}结束执行AssetBundle打包!");
            Debug.Log($"应用{projectInfo.DevelopProjectName}的AssetBundle打包操作已完成," +
                      $"耗时为{minutes}分{seconds}秒!");
            Debug.Log($"应用{projectInfo.DevelopProjectName}的AssetBundle打包操作已完成," +
                      $"当前总耗时为{buildTotalSecond}秒!");
        }
Example #4
0
        /// <summary>
        /// 清理应用的AssetBundle Id。
        /// </summary>
        public static void CleanAllAssetBundleId()
        {
            var assetPaths = new List <string>();

            var databasePaths = IOUtility.GetPathsContainSonDir(
                ProjectInfoDati.GetActualInstance().ProjectAssetDatabaseDir);

            assetPaths.AddRange(databasePaths);

            foreach (var assetPath in assetPaths)
            {
                if (!SelectPath(assetPath))
                {
                    continue;
                }

                var assetsPath = UnityIOUtility.GetAssetsPath(assetPath);
                var importer   = AssetImporter.GetAtPath(assetsPath);
                if (importer == null)
                {
                    continue;
                }

                importer.assetBundleName = null;
            }
            AssetDatabase.RemoveUnusedAssetBundleNames();
            Debug.Log("AssetBundle包Id已清空!");
        }
Example #5
0
        private LegoUIMeta GetUIMetaAtEditor(string uiId)
        {
            if (metaPathDict == null)
            {
                metaPathDict = new Dictionary <string, string>();
                var    app      = ProjectInfoDati.GetActualInstance();
                string metaDir  = string.Empty;
                var    pathDict = IOUtility.GetPathDictionary(metaDir, s => s.EndsWith(".txt"));
                foreach (var kv in pathDict)
                {
                    metaPathDict.Add(kv.Key.ToLower(), kv.Value);
                }
            }

            if (!metaPathDict.ContainsKey(uiId))
            {
                Debug.Log($"id为{uiId}的元数据不存在!");
                return(null);
            }

            var path    = metaPathDict[uiId];
            var content = File.ReadAllText(path);
            var uiMeta  = UnityEngine.JsonUtility.FromJson <LegoUIMeta>(content);

            uiMeta.Reset();
            var bytes   = SerializeUtility.Serialize(uiMeta);
            var newMeta = SerializeUtility.DeSerialize <LegoUIMeta>(bytes);

            uiMetaDict.Add(uiId, newMeta);
            return(uiMeta);
        }
        private void LoadCurrentAppMeta()
        {
            var appSetting = ProjectInfoDati.GetActualInstance();
            var appMeta    = new LegoAppViewMeta();

            appViewMetaDict.Add(appSetting.DevelopProjectName, appMeta);
        }
Example #7
0
        public YuAIBehaviorTree LoadCurrentHaviourTree(string behaviourId)
        {
            var writePath   = $"{Application.streamingAssetsPath}/{ProjectInfoDati.GetActualInstance().DevelopProjectName}/Config/BehaviourTreeData.byte";
            var newInstance = SerializeUtility.DeSerialize <BehaviorTreeVisualization>(writePath);

            instance = newInstance;
            return(CreateBehaviourTree());
        }
            public object CreateModel(string logicId)
            {
                string appId    = ProjectInfoDati.GetActualInstance().DevelopProjectName;
                var    type     = GetRxModelType(appId, logicId);
                var    newModel = Activator.CreateInstance(type);

                return(newModel);
            }
Example #9
0
        public string GetDeveloperScenePath(string develperId)
        {
            var path = ProjectInfoDati.GetActualInstance().ProjectRootDir +
                       ProjectInfoDati.GetActualInstance().DevelopProjectName
                       + $"_Develop_Bootstrap_{develperId}.unity";

            return(path);
        }
 public AssetModule()
 {
     LoadMax     = 3;
     projectInfo = ProjectInfoDati.GetActualInstance();
     //_appEntity = U3dGlobal.Get<IYuU3dAppEntity>();
     _isLoadBundle = false;//_appEntity.RunSetting.IsLoadFromAssetBundle;
     InitLoadActions();
 }
Example #11
0
        //[MenuItem("Yu/AssetBundle/更新当前应用的AssetBundle依赖数据")]
        /// <summary>
        /// Bundle To Bundle 依赖数据
        /// </summary>
        private static void CreateAppDependInfoMenu()
        {
            var currentApp    = ProjectInfoDati.GetActualInstance();
            var path          = BundlePathHelper.GetAppBundleDependInfoPath();
            var bundlePath    = currentApp.AssetBundleBuildDir + "AssetBundle";
            var appDependInfo = ProjectBundleDependInfo.Create(bundlePath);

            SerializeUtility.SerializeAndWriteTo(appDependInfo, path);
            Debug.Log($"应用{currentApp.DevelopProjectName}的AssetBundle依赖数据更新完成!");
        }
Example #12
0
        public void ExportExcelData()
        {
            var projectInfo        = ProjectInfoDati.GetActualInstance();
            var fullClassName      = projectInfo.ProjectRuntimeScriptDefines + "." + excelDataClass;
            var assemblyPath       = projectInfo.ProjectRuntimeAssemblyPath;
            var targetAssembly     = Assembly.LoadFile(assemblyPath);
            var excelDataClassType = targetAssembly.GetType(fullClassName);
            var excelFileToExport  = GlobalExcelPathMap.GetFilename(excelDataClass, projectInfo.DevelopProjectName);

            ExportExcelDatas(excelDataClassType, excelFileToExport);
        }
Example #13
0
        //[MenuItem("Yu/AssetBundle/打包当前应用的AssetBundle &b")]
        public static void BuildAllAssetBundle()
        {
            var currentApp           = ProjectInfoDati.GetActualInstance();
            var assetBundleOutPutDir = currentApp.AssetBundleBuildDir;

            IOUtility.EnsureDirExist(assetBundleOutPutDir);
            BuildPipeline.BuildAssetBundles(assetBundleOutPutDir,
                                            BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
            UnityEditorUtility.DisplayTooptx($"应用{currentApp.DevelopProjectName}的AssertBundle打包已完成!");
            AssetDatabase.Refresh();
        }
Example #14
0
        private void ExportScript()
        {
            Injector.Instance.Get <ExcelCsharpInterfaceScriptCreator>().
            CreateScript(this);
            var scriptFileName = Injector.Instance.Get <ExcelCSharpEntityScriptCreator>().
                                 CreateScript(this);

            GlobalExcelPathMap.Instance.AddAppPathMap(ProjectInfoDati.GetActualInstance(),
                                                      scriptFileName,
                                                      TaregetExcel);
            GlobalExcelPathMap.Instance.Save();
            AssetDatabaseUtility.Refresh();
        }
        private static void SaveTextStyleChange()
        {
            var appID = ProjectInfoDati.GetActualInstance().DevelopProjectName;

            currentAppTextStyle =
                AppTextStyleInfoDic[appID];
            string fullPath = GetAppTextStyleSettingTxtPath(
                appID);
            var jsContent = UnityEngine.JsonUtility.ToJson(currentAppTextStyle);

            ////jsContent = EditorAPIInvoker.PrettifyJsonString(jsContent);
            IOUtility.WriteAllText(fullPath, jsContent);
        }
        public BundlePathInfoHelepr()
        {
            string path = null;

            projectConfig = ProjectInfoDati.GetActualInstance();

            if (UnityModeUtility.IsEditorMode)
            {
                path = /*projectConfig.Helper.LocalHttpRootDir +*/ $"{projectConfig.DevelopProjectName}_AssetBundleInfo.bytes";
                var bytes = File.ReadAllBytes(path);
                projectAssetToBundleMap = SerializeUtility.DeSerialize <ProjectAssetsToBundleMapInfo>(bytes);
            }
        }
Example #17
0
        /// <summary>
        /// 尝试获取指定目录所在的应用配置。
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static ProjectInfo TryGetLocProjectInfoAtDir(string dir)
        {
            var fullDir    = UnityIOUtility.GetFullPath(dir);
            var appSetting = ProjectInfoDati.GetActualInstance();
            var appRootDir = appSetting.ProjectRootDir;

            if (fullDir.StartsWith(appRootDir))
            {
                return(appSetting);
            }

            return(null);
        }
Example #18
0
        public static void BuildAssetInfos()
        {
            //var currentApp = YuU3dAppSettingDati.CurrentActual;
            var assetInfos = new Dictionary <char, Dictionary <string, AssetInfo> >();
            var hotDir     = ProjectInfoDati.GetActualInstance().ProjectAssetDatabaseDir;
            var hotPaths   = IOUtility.GetPathsContainSonDir(hotDir, SelectAssetPath);

            foreach (var hotPath in hotPaths)
            {
                var assetId = Path.GetFileNameWithoutExtension(hotPath).ToLower();
                var suffix  = Path.GetExtension(hotPath);

                if (_sameIds.Contains(assetId))
                {
                    Debug.LogError($"发现命名重复的资源{assetId}!");
                    continue;
                }

                try
                {
                    _sameIds.Add(assetId);
                    var dirPath   = hotPath.Replace(hotDir, "");
                    var lastIndex = dirPath.LastIndexOf('/');
                    if (lastIndex != -1)
                    {
                        dirPath = dirPath.Substring(0, lastIndex).EnsureDirEnd();
                    }

                    var info = new AssetInfo(assetId, dirPath, AssetLocation.HotUpdate, suffix);

                    var cIndex = assetId[0];
                    if (!assetInfos.ContainsKey(cIndex))
                    {
                        assetInfos.Add(cIndex, new Dictionary <string, AssetInfo>());
                    }

                    assetInfos[cIndex].Add(assetId, info);
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                }
            }

            var writePath = $"{Application.streamingAssetsPath}/{ProjectInfoDati.GetActualInstance().DevelopProjectName}/Config/AssetInfo.byte";

            SerializeUtility.SerializeAndWriteTo(assetInfos, writePath);
            Debug.Log("资源数据创建完毕!");
            AssetDatabase.Refresh();
        }
Example #19
0
        /// <summary>
        /// 目录检测,资源需位于 Assetdatabase 目录
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static bool IsLegalAssetBundleDir(string dir)
        {
            var projectInfo = ProjectInfoDati.GetActualInstance();

            if (!dir.StartsWith(projectInfo.ProjectAssetDatabaseDir))
            {
                return(false);
            }

            if (dir == projectInfo.ProjectAssetDatabaseDir)
            {
                return(false);
            }
            return(true);
        }
Example #20
0
        public static string GetLocAppIdAtSelectDir()
        {
            var firstDir = GetSelectDirs().First();

            firstDir = Application.dataPath.Replace("Assets", "") + firstDir;

            var appSettings = ProjectInfoDati.GetActualInstance();
            var appRootDir  = appSettings.ProjectRootDir;

            if (firstDir.StartsWith(appRootDir))
            {
                return(appSettings.DevelopProjectName);
            }
            return(null);
        }
            private object LoadModelAtEditor(string logicId)
            {
                if (rxModels.ContainsKey(logicId))
                {
                    var targetModel = rxModels[logicId];
                    return(targetModel);
                }

                var app  = ProjectInfoDati.GetActualInstance();
                var type = GetRxModelType(app.DevelopProjectName, logicId);
                //反射构造数据模型类型
                var newModel = Activator.CreateInstance(type);

                rxModels.Add(logicId, newModel);
                return(newModel);
            }
Example #22
0
        public static void SaveCurrentAppAssetBundleInfo()
        {
            if (string.IsNullOrEmpty(currentAssetBundleInfo.LocAppId))
            {
                UnityEditorUtility.DisplayError("应用Id不能为空!");
                throw new Exception("应用Id不能为空!");
            }

            var projectInfo = ProjectInfoDati.GetActualInstance();
            var localPath   = projectInfo.AssetBundleBuildDir
                              + $"{projectInfo.DevelopProjectName}_AssetToBundleMapInfo.bytes";
            var bytes = SerializeUtility.Serialize(currentAssetBundleInfo);

            IOUtility.WriteAllBytes(localPath, bytes);
            AssetDatabase.Refresh();
            Debug.Log($"应用{currentAssetBundleInfo.LocAppId}的AssetBundle数据已更新!");
        }
        public LegoUIMeta GetMeta(string id)
        {
            var finalId = id.Contains("@")
                ? id.Split('@')[0]
                : id;
            var appId = ProjectInfoDati.GetActualInstance().DevelopProjectName;

            if (appId == null)
            {
                return(null);
            }

            var appUIMeta   = appViewMetaDict[appId];
            var lowerMetaId = /*YuBigAssetIdMap.GetLowerId*/ (finalId);
            var meta        = appUIMeta.GetUIMeta(lowerMetaId);

            return(meta);
        }
Example #24
0
        private static void MoveAssetBundleAtEveryBuild(List <string> paths,
                                                        AssetBundleBuildSetting dirSetting)
        {
            var bundleIds = paths.Select(p => Path.GetFileNameWithoutExtension(p)?.ToLower())
                            .ToList();
            var locApp = ProjectInfoDati.GetActualInstance();
            var assetBundleOutPaths = IOUtility.GetPathDictionary(locApp.AssetBundleBuildDir, s => !s.EndsWith(".manifest"));
            var targetDirId         = IOUtility.GetLastDir(dirSetting.Dir);
            var moveDir             = locApp.AssetBundleBuildDir + targetDirId;

            moveDir = moveDir.EnsureDirEnd();
            foreach (var bundleId in bundleIds)
            {
                var sourcePath = assetBundleOutPaths[bundleId];
                var targetPath = moveDir + bundleId + ASSETBUNDLE_SHORT_SUFFIX;
                IOUtility.Move(sourcePath, targetPath);
            }
        }
Example #25
0
        public void ExportAllExcelData()
        {
            var projectInfo = ProjectInfoDati.GetActualInstance();

            var      assemblyPath       = projectInfo.ProjectRuntimeAssemblyPath;
            Assembly targetAssembly     = Assembly.LoadFile(assemblyPath);
            var      excelDataClassType = targetAssembly.GetTypes();
            var      types = targetAssembly.GetTypes();

            foreach (var type in types)
            {
                if ((typeof(IExcelEntity).IsAssignableFrom(type)))
                {
                    var excelFileToExport = GlobalExcelPathMap.GetFilename(type.Name, projectInfo.DevelopProjectName);
                    ExportExcelDatas(type, excelFileToExport);
                }
            }
        }
        /// <summary>
        /// 设置目标目录的打包类型
        /// </summary>
        /// <param name="buildType"></param>
        private static void SetTargetDirAtildType(AssetBundleBuildType buildType)
        {
            var projectInfo       = ProjectInfoDati.GetActualInstance();
            var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();

            locAppId = projectInfo.DevelopProjectName;

            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("未设置项目名称");
                return;
            }

            //appHelper = locU3DApp.Helper;

            if (assetbundleEditor == null)
            {
                Debug.LogError($"项目的 AssetBundleSetting 实例未创建 !");
                return;
            }

            var dirs = UnityEditorUtility.GetSelectDirs();

            foreach (var dir in dirs)
            {
                if (!dir.StartsWith(projectInfo.ProjectAssetDatabaseDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    return;
                }
                assetbundleEditor.SetBuildAtTargetBuildType(dir, buildType);
                if (buildType == AssetBundleBuildType.BuildAtDirTree) // 清理所有子目录的打包配置
                {
                    var sonDirs = IOUtility.GetAllDir(dir, null, true, false);
                    foreach (var sonDir in sonDirs)
                    {
                        assetbundleEditor.CleanBuildSettingAtDir(sonDir);
                    }
                    Debug.Log($"目录{dir}已设置为目录树打包,其所有子目录的打包配置都已被清空!");
                }
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
        protected override void BuildBeforeMenuItems(OdinMenuTree tree)
        {
            tree.Add("开发者信息", DeveloperInfoDati.GetSingleDati(), EditorIcons.SingleUser);
            tree.Add("项目信息", ProjectInfoDati.GetSingleDati(), EditorIcons.UnityLogo);
            tree.Add("脚本创建器", ScriptCreaterDati.GetSingleDati(), EditorIcons.Info);
            //tree.Add("数据表", DataTableEditorDati.GetSingleDati(),EditorIcons.Table);
            tree.Add("AssetBundle", AssetBundleEditorDati.GetSingleDati(), EditorIcons.File);
            //tree.Add("场景编辑", SceneEditorDati.GetSingleDati(), EditorIcons.LightBulb);
            tree.Add("测试面板", new MethedInvokeBorad(), EditorIcons.SingleUser);
            //tree.Add("行为树", BehaviorTreeVisualization.Instance,EditorIcons.Tree);

            //tree.Add("核心配置", YuU3dCoreSettingDati.GetSingleDati(),
            //    EditorIcons.SettingsCog, YuMenuItemSetting.CommonMenuItemSetting);

            //tree.Add("自定义程序集", YuU3dAssemblyDefineDati.GetSingleDati(),
            //    EditorIcons.CloudsThunder, YuMenuItemSetting.CommonMenuItemSetting);
            //tree.Add("Prefs工具", new YuU3dPrefsSpanner(),
            //    EditorIcons.DayCalendar, YuMenuItemSetting.CommonMenuItemSetting);
        }
        public static string GetSoundFileName(string soundId)
        {
            if (Instance == null)
            {
                var resId = "Setting/YuSoundSetting/" + ProjectInfoDati.GetActualInstance().DevelopProjectName +
                            "SoundInfo";
                var textAsset = Resources.Load <TextAsset>(resId);
                Instance =
                    JsonUtility.FromJson <LegoUISoundInfo>(textAsset.text);
            }
            string soundFileName = "";
            int    index         = Instance.UISoundNumIdList.IndexOf(soundId);

            if (index != -1)
            {
                soundFileName = Instance.UISoundNameIdList[index];
            }
            return(soundFileName);
        }
            private object LoadModelAtPlay(string logicId)
            {
                if (rxModels.ContainsKey(logicId))
                {
                    var targetModel = rxModels[logicId];
                    return(targetModel);
                }

                var app     = ProjectInfoDati.GetActualInstance();
                var type    = GetRxModelType(app.DevelopProjectName, logicId);
                var finalId = logicId ?? type.Name;

                finalId += "_RxModel";
                if (finalId.Contains("@"))
                {
                    finalId = finalId.Replace("@", "_")
                              .Replace("=", "_");
                }

                var assetId = app.DevelopProjectName + "_" + finalId;

                TextAsset textAsset = null;

                try
                {
                    textAsset = AssetModule.Load <TextAsset>(assetId);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debug.LogError(e.Message + e.StackTrace);
#endif
                }
                if (textAsset == null)
                {
                    var newModel = Activator.CreateInstance(type);
                    return(newModel);
                }

                var instance = UnityEngine.JsonUtility.FromJson(textAsset.text, type);
                return(instance);
            }
        public LegoUIMeta GetMeta(RectTransform uiRect)
        {
            var    appId     = ProjectInfoDati.GetActualInstance().DevelopProjectName;
            var    appUIMeta = appViewMetaDict[appId];
            string metaId;

            if (metaIdMap.ContainsKey(uiRect.name))
            {
                metaId = metaIdMap[uiRect.name];
            }
            else
            {
                metaId = uiRect.UITypeId().ToLower();
                metaIdMap.Add(uiRect.name, metaId);
            }

            var lowerMetaId = /*YuBigAssetIdMap.GetLowerId*/ (metaId);
            var meta        = appUIMeta.GetUIMeta(lowerMetaId);

            return(meta);
        }