Exemplo n.º 1
0
    public static void BuildSceneSpecify(PackagePlatform.PlatformType rBuildPlatform)
    {
        if (!Directory.Exists(PackagePlatform.sceneDirectoryPath))
        {
            Debug.Log("没有需要打包的场景文件");
            return;
        }

        PackagePlatform.platformCurrent = rBuildPlatform;

        string rOutPath = PackagePlatform.GetSceneBundlePath();
        if (Directory.Exists(rOutPath) == false)
            Directory.CreateDirectory(rOutPath);
        //修改PackagePlatform.Instance.sceneDirectoryPath
        var guids = AssetDatabase.FindAssets("t:scene", new string[] { PackagePlatform.sceneDirectoryPath });
        var rInPaths = new string[guids.Length];
        var rCount = 0;

        foreach(var guid in guids)
        {
            var rPath = rInPaths[rCount] = AssetDatabase.GUIDToAssetPath(guid);

            var rName = rPath.Substring(rPath.LastIndexOf('/') + 1, rPath.LastIndexOf('.') - rPath.LastIndexOf('/') - 1);

            var rfullPath = rOutPath + "/" + rName.ToLower() + "." + Global.BundleExtName;

            BuildPipeline.BuildPlayer(new string[] { rPath }, rfullPath, PackagePlatform.GetBuildTarget(), BuildOptions.BuildAdditionalStreamedScenes);

            Debug.Log("build scene:>" + rPath);
            rCount++;
        }
    }
Exemplo n.º 2
0
 public BundleSlice(string name, int capacity, bool streamingAssets, PackagePlatform platform)
 {
     this.name            = name;
     this.capacity        = capacity;
     this.streamingAssets = streamingAssets;
     this.platform        = platform;
 }
Exemplo n.º 3
0
    public static void GeneratorChecklist()
    {
        string newFilePath = PackagePlatform.GetPackagePath() + Global.PackageManifestFileName;

        if (File.Exists(newFilePath))
        {
            File.Delete(newFilePath);
        }

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

        Util.RecursiveDir(PackagePlatform.GetPackagePath(), ref files);

        FileStream   fs = new FileStream(newFilePath, FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(fs);

        for (int i = 0; i < files.Count; i++)
        {
            string file = files[i];
            if (file.EndsWith(".meta") || file.Contains(".DS_Store"))
            {
                continue;
            }

            string md5   = Util.MD5File(file);
            string value = file.Replace(PackagePlatform.GetPackagePath(), string.Empty);
            sw.WriteLine(value + "|" + md5);
        }
        sw.Close(); fs.Close();
        AssetDatabase.Refresh();
    }
Exemplo n.º 4
0
 public static void BuildPackages(BundleBuilderData data, string outputPath, PackagePlatform platform)
 {
     BuildSinglePlatformPackages(new PackageSharedBuildInfo()
     {
         data = data, outputPath = outputPath
     }, platform);
 }
Exemplo n.º 5
0
        protected override void OnEnable()
        {
            base.OnEnable();
            Selection.selectionChanged += OnSelectionChanged;
            _data = BundleBuilder.GetData();
            BundleBuilder.Scan(_data);
            titleContent             = new GUIContent("Bundle Builder");
            _searchKeyword           = EditorPrefs.GetString(KeyForSearchKey);
            _searchSliceKeyword      = EditorPrefs.GetString(KeyForSearchSliceKey);
            _showDefinedOnly         = EditorPrefs.GetInt(KeyForShowDefinedOnly) == 1;
            _showSelectionOnly       = EditorPrefs.GetInt(KeyForShowSelectionOnly) == 1;
            _showStreamingAssetsOnly = EditorPrefs.GetInt(KeyForShowStreamingAssetsOnly) == 1;
            UpdateSearchResults();
            _tabIndex = EditorPrefs.GetInt(KeyForTabIndex);
            _platform = (PackagePlatform)EditorPrefs.GetInt(KeyForPackagePlatforms, (int)PackagePlatform.Any);
            // bool firstInit = _headerState == null;
            var headerState = BundleBuilderTreeView.CreateDefaultMultiColumnHeaderState(this.position.width);

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(_headerState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(_headerState, headerState);
            }

            var header = new BundleBuilderTreeViewHeader(headerState);

            _headerState = headerState;

            _treeView = new BundleBuilderTreeView(_treeViewState, header);
            _treeView.SetData(_data);
        }
Exemplo n.º 6
0
    public static void BuildSceneSpecify(PackagePlatform.PlatformType rBuildPlatform)
    {
        if (!Directory.Exists(PackagePlatform.sceneDirectoryPath))
        {
            Debug.Log("没有需要打包的场景文件");
            return;
        }

        PackagePlatform.platformCurrent = rBuildPlatform;

        string rOutPath = PackagePlatform.GetSceneBundlePath();

        if (Directory.Exists(rOutPath) == false)
        {
            Directory.CreateDirectory(rOutPath);
        }
        //修改PackagePlatform.Instance.sceneDirectoryPath
        var guids    = AssetDatabase.FindAssets("t:scene", new string[] { PackagePlatform.sceneDirectoryPath });
        var rInPaths = new string[guids.Length];
        var rCount   = 0;

        foreach (var guid in guids)
        {
            var rPath = rInPaths[rCount] = AssetDatabase.GUIDToAssetPath(guid);

            var rName = rPath.Substring(rPath.LastIndexOf('/') + 1, rPath.LastIndexOf('.') - rPath.LastIndexOf('/') - 1);

            var rfullPath = rOutPath + "/" + rName.ToLower() + "." + Global.BundleExtName;

            BuildPipeline.BuildPlayer(new string[] { rPath }, rfullPath, PackagePlatform.GetBuildTarget(), BuildOptions.BuildAdditionalStreamedScenes);

            Debug.Log("build scene:>" + rPath);
            rCount++;
        }
    }
Exemplo n.º 7
0
        // 最终资源
        private static bool CollectAsset(BundleBuilderData data, BundleBuilderData.BundleInfo bundle, Object asset,
                                         string assetPath, PackagePlatform platform)
        {
            if (asset == null)
            {
                return(false);
            }

            var listData = asset as AssetListData;

            if (listData != null)
            {
                return(CollectAssetList(data, bundle, listData, platform));
            }

            for (var splitIndex = 0; splitIndex < bundle.splits.Count; splitIndex++)
            {
                var split     = bundle.splits[splitIndex];
                var ruleMatch = false;
                if (split.rules.Count > 0)
                {
                    for (var ruleIndex = 0; ruleIndex < split.rules.Count; ruleIndex++)
                    {
                        var rule = split.rules[ruleIndex];
                        if (rule.exclude)
                        {
                            if (IsRuleMatched(rule, asset, assetPath))
                            {
                                break;
                            }
                        }
                        else
                        {
                            if (IsRuleMatched(rule, asset, assetPath))
                            {
                                ruleMatch = true;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    ruleMatch = true;
                }

                if (ruleMatch)
                {
                    if (!ContainsAsset(data, asset) && split.AddObject(asset, platform))
                    {
                        data.OnAssetCollect(asset, assetPath);
                    }

                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 8
0
    public static void ResetPackageDir()
    {
        string path = PackagePlatform.GetPackagePath();

        if (Directory.Exists(path))
        {
            Directory.Delete(path, true);
        }
        Directory.CreateDirectory(path);
    }
 public bool AddObject(string assetPath, PackagePlatform platform)
 {
     _assetPathHashSet.Add(assetPath);
     _assets.Add(new PackedObject()
     {
         assetPath = assetPath,
         platform  = platform,
     });
     return(true);
 }
Exemplo n.º 10
0
 public bool AddObject(Object asset, PackagePlatform platform)
 {
     _assetHashSet.Add(asset);
     _assets.Add(new PackedObject()
     {
         asset    = asset,
         platform = platform,
     });
     return(true);
 }
Exemplo n.º 11
0
        public Package(EndianIO io)
        {
            short           BaseVersion = io.ReadInt16();
            PackagePlatform Platform    = (PackagePlatform)io.ReadInt16();
            ushort          EntryCount  = io.ReadUInt16(); // max = 0xFFFF

#if DEBUG
            Verify(io);
#endif
        }
Exemplo n.º 12
0
        public static string PackagePlatformName(PackagePlatform platform)
        {
            switch (platform)
            {
            case PackagePlatform.WinX64: return("win-x64");

            case PackagePlatform.Osx: return("osx-x64");

            case PackagePlatform.LinuxX64: return("linux-x64");

            case PackagePlatform.Any: return("any");

            default: return("");
            }
        }
Exemplo n.º 13
0
        // outputPath: 输出的总目录 [可选]
        public PackageBuildInfo(PackageSharedBuildInfo sharedBuildInfo, PackagePlatform buildBuildPlatform, BuildTarget buildTarget)
        {
            _sharedBuildInfo     = sharedBuildInfo;
            _data                = sharedBuildInfo.data;
            _buildPlatform       = buildBuildPlatform;
            _buildTarget         = buildTarget;
            _assetBundlePath     = GetPlatformPath(Combine(sharedBuildInfo.outputPath, data.assetBundlePath), buildTarget);
            _zipArchivePath      = GetPlatformPath(Combine(sharedBuildInfo.outputPath, data.zipArchivePath), buildTarget);
            _packagePath         = GetPlatformPath(Combine(sharedBuildInfo.outputPath, data.packagePath), buildTarget);
            _streamingAssetsPath = Combine(BundleBuilderData.StreamingAssetsPath, Manifest.EmbeddedBundlesBasePath);

            EnsureDirectory(_assetBundlePath);
            EnsureDirectory(_zipArchivePath);
            EnsureDirectory(_packagePath);
            EnsureDirectory(_streamingAssetsPath);
        }
Exemplo n.º 14
0
    public static void GeneratorVersion(string mainVersion, string minorVersion)
    {
        string newFilePath = PackagePlatform.GetPackagePath() + Global.PackageVersionFileName;

        if (File.Exists(newFilePath))
        {
            File.Delete(newFilePath);
        }
        FileStream   fs = new FileStream(newFilePath, FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(fs);

        string version = mainVersion + '.' + minorVersion;

        sw.WriteLine(version);
        sw.Close(); fs.Close();
        AssetDatabase.Refresh();
    }
Exemplo n.º 15
0
        public static BuildTarget ToBuildTarget(PackagePlatform platform)
        {
            switch (platform)
            {
            case PackagePlatform.Any: return(EditorUserBuildSettings.activeBuildTarget);

            case PackagePlatform.Android: return(BuildTarget.Android);

            case PackagePlatform.IOS: return(BuildTarget.iOS);

            case PackagePlatform.Windows64: return(BuildTarget.StandaloneWindows64);

            case PackagePlatform.MacOS: return(BuildTarget.StandaloneOSX);
            }

            throw new NotSupportedException();
        }
Exemplo n.º 16
0
    public static void BuildAssetbundlesSpecify(PackagePlatform.PlatformType rBuildPlatform)
    {
        PackagePlatform.platformCurrent = rBuildPlatform;

        List<AssetBundleBuild> abbList = GeneratorAssetbundleEntry();
        if (abbList == null)
        {
            Debug.Log("没有找到需要打包的资源");
            return;
        }

        string rPath = PackagePlatform.GetAssetBundlesPath();
        if (Directory.Exists(rPath) == false)
            Directory.CreateDirectory(rPath);

        BuildPipeline.BuildAssetBundles(rPath, abbList.ToArray(), BuildAssetBundleOptions.None, PackagePlatform.GetBuildTarget());
    }
Exemplo n.º 17
0
        public void Commit(string productName, string author, PackagePlatform platform, int languageCode, Guid productCode)
        {
            IntPtr infoHandle;

            ThrowOnFailure(SafeNativeMethods.MsiGetSummaryInformation(_handle, null, 20, out infoHandle));

            SetProperty(infoHandle, 2, 30, 0, 0, "Installation Database");
            SetProperty(infoHandle, 3, 30, 0, 0, productName);
            SetProperty(infoHandle, 4, 30, 0, 0, author);
            SetProperty(infoHandle, 5, 30, 0, 0, "Installer");
            SetProperty(infoHandle, 7, 30, 0, 0, $"{(platform == PackagePlatform.X64 ? "x64" : "Intel")};{languageCode}");
            SetProperty(infoHandle, 9, 30, 0, 0, productCode.ToStringFormatted());
            SetProperty(infoHandle, 14, 3, MsiVersion, 0, string.Empty);
            SetProperty(infoHandle, 15, 3, Properties, 0, string.Empty);

            ThrowOnFailure(SafeNativeMethods.MsiSummaryInfoPersist(infoHandle));
            ThrowOnFailure(SafeNativeMethods.MsiCloseHandle(infoHandle));

            ThrowOnFailure(SafeNativeMethods.MsiDatabaseCommit(_handle));
        }
Exemplo n.º 18
0
        public void Commit(string productName, string author, PackagePlatform platform, int languageCode, Guid productCode)
        {
            IntPtr infoHandle;

            ThrowOnFailure(SafeNativeMethods.MsiGetSummaryInformation(_handle, null, 20, out infoHandle));

            SetProperty(infoHandle, 2, 30, 0, 0, "Installation Database");
            SetProperty(infoHandle, 3, 30, 0, 0, productName);
            SetProperty(infoHandle, 4, 30, 0, 0, author);
            SetProperty(infoHandle, 5, 30, 0, 0, "Installer");
            SetProperty(infoHandle, 7, 30, 0, 0, $"{(platform == PackagePlatform.X64 ? "x64" : "Intel")};{languageCode}");
            SetProperty(infoHandle, 9, 30, 0, 0, productCode.ToStringFormatted());
            SetProperty(infoHandle, 14, 3, MsiVersion, 0, string.Empty);
            SetProperty(infoHandle, 15, 3, Properties, 0, string.Empty);

            ThrowOnFailure(SafeNativeMethods.MsiSummaryInfoPersist(infoHandle));
            ThrowOnFailure(SafeNativeMethods.MsiCloseHandle(infoHandle));

            ThrowOnFailure(SafeNativeMethods.MsiDatabaseCommit(_handle));
        }
Exemplo n.º 19
0
 private static void CheckShaderVariants(BundleBuilderData data, BundleBuilderData.BundleInfo bundle, Object shaderVariants,
                                         string assetPath, PackagePlatform platform)
 {
     #if UNITY_2018_1_OR_NEWER
     var shaderVariantCollection = shaderVariants as ShaderVariantCollection;
     if (shaderVariantCollection != null)
     {
         var shaderInfos = ShaderUtil.GetAllShaderInfo();
         foreach (var shaderInfo in shaderInfos)
         {
             var shader     = Shader.Find(shaderInfo.name);
             var shaderPath = AssetDatabase.GetAssetPath(shader);
             if (shaderPath.StartsWith("Assets/"))
             {
                 CollectAsset(data, bundle, shader, shaderPath, platform);
             }
         }
     }
     #endif
 }
Exemplo n.º 20
0
    public static void BuildAssetbundlesSpecify(PackagePlatform.PlatformType rBuildPlatform)
    {
        PackagePlatform.platformCurrent = rBuildPlatform;

        List <AssetBundleBuild> abbList = GeneratorAssetbundleEntry();

        if (abbList == null)
        {
            Debug.Log("没有找到需要打包的资源");
            return;
        }

        string rPath = PackagePlatform.GetAssetBundlesPath();

        if (Directory.Exists(rPath) == false)
        {
            Directory.CreateDirectory(rPath);
        }

        BuildPipeline.BuildAssetBundles(rPath, abbList.ToArray(), BuildAssetBundleOptions.None, PackagePlatform.GetBuildTarget());
    }
            // 如果是历史资源, 将加入; 否则返回 false
            public bool AddHistory(string assetPath, bool streamingAssets, PackagePlatform platform)
            {
                if (assetPathHistroy.Contains(assetPath))
                {
                    if (this.streamingAssets == streamingAssets && this.IsBuild(platform))
                    {
                        _AddAssetPath(assetPath);
                        return(true);
                    }

                    // 此处的判定规则影响包的性质改变, 进而影响分包切分布局, 导致额外的包变更
                    if (GetAssetCount() == 0 && assetPathHistroy.Count == 1)
                    {
                        this.streamingAssets = streamingAssets;
                        this.platform        = platform;
                        _AddAssetPath(assetPath);
                        return(true);
                    }
                }

                return(false);
            }
Exemplo n.º 22
0
            // 如果是历史资源, 将加入; 否则返回 false
            public bool AddHistory(string guid, bool streamingAssets, PackagePlatform platform)
            {
                if (histroy.Contains(guid))
                {
                    if (this.streamingAssets == streamingAssets && this.platform == platform)
                    {
                        _AddAsset(guid);
                        return(true);
                    }

                    // 此处的判定规则影响包的性质改变, 进而影响分包切分布局, 导致额外的包变更
                    if (GetAssetCount() == 0 && histroy.Count == 1)
                    {
                        this.streamingAssets = streamingAssets;
                        this.platform        = platform;
                        _AddAsset(guid);
                        return(true);
                    }
                }

                return(false);
            }
Exemplo n.º 23
0
            // 返回最后一个符合 StreamingAssets 性质的 slice 包
            private BundleSlice GetLastSlice(bool streamingAssets, PackagePlatform platform)
            {
                var count = this.slices.Count;

                for (var i = count - 1; i >= 0; i--)
                {
                    var slice = slices[i];
                    if (slice.platform == platform && slice.streamingAssets == streamingAssets)
                    {
                        return(slice);
                    }

                    // 如果 slice 为空, 那么 StreamingAssets 可调整
                    if (slice.assetGuids.Count == 0 && slice.histroy.Count == 0)
                    {
                        slice.streamingAssets = streamingAssets;
                        slice.platform        = platform;
                        return(slice);
                    }
                }

                return(null);
            }
Exemplo n.º 24
0
        private static bool CollectAssetList(BundleBuilderData data, BundleBuilderData.BundleInfo bundle,
                                             AssetListData asset, PackagePlatform platform)
        {
            for (var index = 0; index < asset.timestamps.Count; index++)
            {
                var ts        = asset.timestamps[index];
                var assetPath = AssetDatabase.GUIDToAssetPath(ts.guid);

                // 剔除 filelist 对象
                if (!Directory.Exists(assetPath))
                {
                    //TODO: 场景需要单独拆包
                    if (assetPath.EndsWith(".unity"))
                    {
                        continue;
                    }

                    var mainAsset = AssetDatabase.LoadMainAssetAtPath(assetPath);
                    CollectAsset(data, bundle, mainAsset, assetPath, platform);
                }
            }

            return(true);
        }
Exemplo n.º 25
0
    void Package()
    {
        var temp = EditorUserBuildSettings.activeBuildTarget;

        EditorUserBuildSettings.SwitchActiveBuildTarget(PackagePlatform.GetBuildTarget());

        //切换贴图格式
        SwitchTextureFormat();

        //打包其他文件
        DefaultPackage.BuildDefaultSpecify(PackagePlatform.platformCurrent);


        //打包Assetbundle
        AssetBundlePackage.BuildAssetbundlesSpecify(PackagePlatform.platformCurrent);

        //打包场景
        if (needPackageScene)
        {
            PackagePlatform.sceneDirectoryPath = rawScenePath;
            SceneBundlePackage.BuildSceneSpecify(PackagePlatform.platformCurrent);
        }

        //生成版本号
        var minor = int.Parse(minorVersion);

        minor++;
        minorVersion = minor.ToString();
        PackageUtil.GeneratorVersion(mainVersion, minorVersion);

        //生成文件表
        PackageUtil.GeneratorChecklist();

        EditorUserBuildSettings.SwitchActiveBuildTarget(temp);
        SavePackageConfig();
    }
Exemplo n.º 26
0
        private void OnDrawPackages()
        {
            var margin       = 5f;
            var autoRect     = EditorGUILayout.GetControlRect(GUILayout.Height(1f));
            var treeViewTop  = autoRect.yMax;
            var bottomHeight = 21f;
            var treeViewRect = new Rect(5, treeViewTop + margin, position.width - 10,
                                        position.height - treeViewTop - bottomHeight - margin * 3f);
            var bottomRect = new Rect(5, treeViewRect.yMax + margin, treeViewRect.width, bottomHeight);

            _treeView.OnContextMenu(treeViewRect);
            _treeView.OnGUI(treeViewRect);
            GUILayout.BeginArea(bottomRect);
            using (new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Add Bundle"))
                {
                    _data.bundles.Add(new BundleBuilderData.BundleInfo()
                    {
                        id   = ++_data.id,
                        name = $"bundle_{_data.id}{BundleBuilderData.FileExt}",
                    });
                    _treeView.Reload();
                }

                if (GUILayout.Button("Add Asset List"))
                {
                    CreateAssetListData();
                }

                GUI.color = Color.red;
                if (GUILayout.Button("Delete"))
                {
                    _treeView.DeleteSelectedItems();
                }

                GUI.color = _GUIColor;

                GUILayout.FlexibleSpace();
                GUILayout.Space(20f);
                if (GUILayout.Button("Reload"))
                {
                    Reload();
                }

                GUILayout.Space(20f);
                EditorGUILayout.LabelField("Targets", GUILayout.Width(46f));
                var platforms = (PackagePlatform)EditorGUILayout.EnumPopup(_platform, GUILayout.Width(90f));
                if (platforms != _platform)
                {
                    _platform = platforms;
                    EditorPrefs.SetInt(KeyForPackagePlatforms, (int)_platform);
                }

                if (GUILayout.Button("Build Packages"))
                {
                    BundleBuilder.BuildPackages(_data, "", _platform);
                }
            }

            GUILayout.EndArea();
        }
Exemplo n.º 27
0
        public static void Scan(BundleBuilderData data, BundleBuilderData.BundleInfo bundle, Object asset, PackagePlatform platform)
        {
            if (asset == null)
            {
                return;
            }

            var targetPath = AssetDatabase.GetAssetPath(asset);

            if (Directory.Exists(targetPath))
            {
                // 是一个目录
                foreach (var directory in Directory.GetDirectories(targetPath))
                {
                    Scan(data, bundle, AssetDatabase.LoadMainAssetAtPath(directory), platform);
                }

                foreach (var file in Directory.GetFiles(targetPath))
                {
                    if (file.EndsWith(".meta"))
                    {
                        continue;
                    }

                    if (bundle.type == Manifest.BundleType.AssetBundle)
                    {
                        var fi = new FileInfo(file);
                        if (data.skipExts.Contains(fi.Extension.ToLower()))
                        {
                            continue;
                        }
                    }

                    var normFileName = file.Replace('\\', '/');
                    var fileAsset    = AssetDatabase.LoadMainAssetAtPath(normFileName);
                    CollectAsset(data, bundle, fileAsset, normFileName, platform);
                }
            }
            else
            {
                CollectAsset(data, bundle, asset, targetPath, platform);
            }
        }
Exemplo n.º 28
0
 private static bool PlatformMatches(PackagePlatform platform)
 {
     return(platform == PackagePlatform.Any || GetSystemPackagePlatform() == platform);
 }
Exemplo n.º 29
0
 public static void BuildSinglePlatformPackages(PackageSharedBuildInfo sharedBuildInfo, PackagePlatform platform)
 {
     _BuildPackages(new PackageBuildInfo(sharedBuildInfo, platform, ToBuildTarget(platform)));
 }
Exemplo n.º 30
0
    public static void BuildDefaultSpecify(PackagePlatform.PlatformType rBuildPlatform)
    {
        //打包DataTable
        if (Directory.Exists("Assets/RawResources/DataTable"))
        {
            Debug.Log("打包 DataTable");

            string outPath = PackagePlatform.GetPackagePath() + "DataTable";
            if (Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }
            Directory.CreateDirectory(outPath);

            string inPath = "Assets/RawResources/DataTable";
            string[] files = Directory.GetFiles(inPath);

            float doneCount = 0f;
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                if (file.Contains(".meta")) continue;
                Debug.Log(file);

                string outfile = file.Replace("Assets/RawResources", PackagePlatform.GetPackagePath());

                if (File.Exists(outfile)) File.Delete(outfile);

                File.Copy(file, outfile, true);

                doneCount++;
                float p = (doneCount / (float)files.Length);
                EditorUtility.DisplayProgressBar("Package", "Package Default Resources", p);
            }
            EditorUtility.ClearProgressBar();
        }

        //打包Code
        if (Directory.Exists("Assets/RawResources/Code"))
        {
            Debug.Log("打包 Code");

            string outPath = PackagePlatform.GetPackagePath() + "Code";
            if (Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }
            Directory.CreateDirectory(outPath);

            string inPath = "Assets/RawResources/Code";
            string[] files = Directory.GetFiles(inPath);

            float doneCount = 0f;
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                if (file.Contains(".meta")) continue;
                Debug.Log(file);

                string outfile = file.Replace("Assets/RawResources", PackagePlatform.GetPackagePath());

                if (File.Exists(outfile)) File.Delete(outfile);

                File.Copy(file, outfile, true);

                doneCount++;
                float p = (doneCount / (float)files.Length);
                EditorUtility.DisplayProgressBar("Package", "Package Default Resources", p);
            }
            EditorUtility.ClearProgressBar();
        }
    }
Exemplo n.º 31
0
            public PackagePlatform platform; // 在特定平台中生效
            // public BundleAssetTypes types = (BundleAssetTypes)~0; // (仅搜索目录时) 仅包含指定资源类型
            // public List<string> extensions = new List<string>();  // (仅搜索目录时) 额外包含指定后缀的文件

            public bool IsBuildPlatform(PackagePlatform buildPlatform)
            {
                return(platform == PackagePlatform.Any || platform == buildPlatform);
            }
Exemplo n.º 32
0
    public static void BuildDefaultSpecify(PackagePlatform.PlatformType rBuildPlatform)
    {
        //打包DataTable
        if (Directory.Exists("Assets/RawResources/DataTable"))
        {
            Debug.Log("打包 DataTable");

            string outPath = PackagePlatform.GetPackagePath() + "DataTable";
            if (Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }
            Directory.CreateDirectory(outPath);

            string   inPath = "Assets/RawResources/DataTable";
            string[] files  = Directory.GetFiles(inPath);

            float doneCount = 0f;
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                if (file.Contains(".meta"))
                {
                    continue;
                }
                Debug.Log(file);

                string outfile = file.Replace("Assets/RawResources", PackagePlatform.GetPackagePath());

                if (File.Exists(outfile))
                {
                    File.Delete(outfile);
                }

                File.Copy(file, outfile, true);


                doneCount++;
                float p = (doneCount / (float)files.Length);
                EditorUtility.DisplayProgressBar("Package", "Package Default Resources", p);
            }
            EditorUtility.ClearProgressBar();
        }

        //打包Code
        if (Directory.Exists("Assets/RawResources/Code"))
        {
            Debug.Log("打包 Code");

            string outPath = PackagePlatform.GetPackagePath() + "Code";
            if (Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }
            Directory.CreateDirectory(outPath);

            string   inPath = "Assets/RawResources/Code";
            string[] files  = Directory.GetFiles(inPath);

            float doneCount = 0f;
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                if (file.Contains(".meta"))
                {
                    continue;
                }
                Debug.Log(file);

                string outfile = file.Replace("Assets/RawResources", PackagePlatform.GetPackagePath());

                if (File.Exists(outfile))
                {
                    File.Delete(outfile);
                }

                File.Copy(file, outfile, true);


                doneCount++;
                float p = (doneCount / (float)files.Length);
                EditorUtility.DisplayProgressBar("Package", "Package Default Resources", p);
            }
            EditorUtility.ClearProgressBar();
        }
    }
Exemplo n.º 33
0
 // 是否为指定平台打包
 public bool IsBuild(PackagePlatform buildPlatform)
 {
     return(this.platform == PackagePlatform.Any || this.platform == buildPlatform);
 }
Exemplo n.º 34
0
 public static void BuildSinglePlatformPackages(PackageSharedBuildInfo sharedBuildInfo, PackagePlatform platform)
 {
     //NOTE: 命令行模式下, ScriptableObject 会被编辑器主动 Destroy, 这里利用一个临时的 GameObject 强制保持引用
     //NOTE: 之后考虑将 data 改为普通对象使用 json 序列化
     using (var hold = ReferenceHolder.Create(sharedBuildInfo.data))
     {
         _BuildPackages(new PackageBuildInfo(sharedBuildInfo, platform, ToBuildTarget(platform)));
     }
 }
Exemplo n.º 35
0
 /// <summary>
 /// Sets the target platform for the package.
 /// </summary>
 /// <remarks>
 /// MSI installation packages can be targeted at either 32 or 64-bit platforms. Based on this setting, the package
 /// will install to either Program Files (x86) or Program Files on a 64-bit system.
 /// </remarks>
 /// <param name="platform">The target platform for the package.</param>
 /// <returns>The package builder.</returns>
 public PackageBuilder Platform(PackagePlatform platform)
 {
     _platform = platform;
     return this;
 }