Example #1
0
        public static T CreateAsset <T>(string path, Action <T> onCreateCallback = null) where T : ScriptableObject
        {
            var asset = ScriptableObject.CreateInstance <T>();

            path = path.WithoutRootPath(FilePathConst.ProjectPath);
            var dir = path.DirPath();

            if (!dir.IsNullOrEmpty())
            {
                StdioUtil.CreateDirectoryIfNotExist(dir);
            }
            var fileExtensionName = Path.GetExtension(path);

            if (!StringConst.String_Asset_Extension.Equals(fileExtensionName))
            {
                path = path.Replace(fileExtensionName, StringConst.String_Asset_Extension);
            }
            onCreateCallback?.Invoke(asset);

            EditorUtility.SetDirty(asset);
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            return(asset);
        }
Example #2
0
        public static void AssetBundleBuild()
        {
            LogCat.ClearLogs();
            //AssetBuildInfoManagerTest.Test();//需要自动设置依赖的,请在AssetBuildInfoManagerTest中添加Root文件,然后取消注释
            StdioUtil.CreateDirectoryIfNotExist(BuildConst.Output_Path);
            LuaBuildUtil.PreBuild();
            AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(BuildConst.Output_Path,
                                                                           BuildAssetBundleOptions.None,
                                                                           BuildTarget.Android);

            AssetPathMapBuildUtil.Build(manifest);
            AssetBundleMapBuildUtil.Build(manifest);
            ResVersionBuildUtil.Build();
            AssetPathRefBuildUtil.Build();
            var netBoxPath = (BuildConst.Output_Root_Path + "/NetBox.exe").Replace("/", "\\");

            Process.Start(netBoxPath);
            EditorUtilityCat.DisplayDialog(
                string.Format("AssetBundle Build Finished,output:\n  {0}", BuildConst.Output_Path),
                BuildConst.Output_Path);
        }