Exemple #1
0
    public static void SetVersionDirAssetName(UnityAction endcall)
    {
        BundleSetting bundleSetting = BundleSetting.Instance;

        foreach (var bi in bundleSetting.bundleInfos)
        {
            SetVersionDirAssetName(bi);
        }
        if (endcall != null)
        {
            endcall();
        }
    }
    private static void SaveAsset(BundleSetting BundleSetting)
    {
        var directoryName = Path.GetDirectoryName(assetPath);

        if (!Directory.Exists(directoryName))
        {
            Directory.CreateDirectory(directoryName);
        }
        var uniqueAssetPath = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(assetPath);

        AssetDatabase.CreateAsset(BundleSetting, uniqueAssetPath);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        Debug.Log(AssetName + " has been created: " + assetPath);
    }
Exemple #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        BundleSetting bundleSetting = ((BundleSetting)target);

        bundleSetting.assetExtensions = EditorGUILayout.TextField("待打包资源扩展名: ", bundleSetting.assetExtensions);
        if (GUILayout.Button("移除重复路径"))
        {
            var bundleInfos             = bundleSetting.bundleInfos;
            HashSet <BundleInfo> unique = new HashSet <BundleInfo>(bundleInfos);
            bundleInfos.Clear();
            bundleInfos.AddRange(unique);
        }
        reorderableList.DoLayoutList();
        serializedObject.ApplyModifiedProperties();
    }
Exemple #4
0
        public static BuildAssetBundleSetting Parse(string content)
        {
            BuildAssetBundleSetting ret = new BuildAssetBundleSetting();
            XmlDocument             doc = new XmlDocument();

            doc.LoadXml(content);
            XmlNodeList xmlBundles = doc.DocumentElement.SelectNodes("/xml/bundles/bundle");

            foreach (XmlNode xmlBundle in xmlBundles)
            {
                BundleSetting bs = new BundleSetting();
                bs.name      = xmlBundle.Attributes.GetNamedItem("name").Value;
                bs.src       = xmlBundle.Attributes.GetNamedItem("src").Value;
                bs.subfixs   = ParseSubfixStr(xmlBundle.Attributes.GetNamedItem("subfix").Value);
                bs.platforms = ParsePlatformStr(xmlBundle.Attributes.GetNamedItem("platform").Value);
                {
                    var nodes = xmlBundle.SelectNodes("includes/elem");
                    foreach (XmlNode elem in nodes)
                    {
                        PathSetting ps = new PathSetting();
                        ps.val       = Path.Combine(bs.src, elem.InnerText).Replace("\\", "/");
                        ps.platforms = ParsePlatformStr(elem.Attributes.GetNamedItem("platform").Value);
                        bs.includes.Add(ps.val, ps);
                    }
                }
                {
                    var nodes = xmlBundle.SelectNodes("excludes/elem");
                    foreach (XmlNode elem in nodes)
                    {
                        PathSetting ps = new PathSetting();
                        ps.val       = Path.Combine(bs.src, elem.InnerText).Replace("\\", "/");
                        ps.platforms = ParsePlatformStr(elem.Attributes.GetNamedItem("platform").Value);
                        bs.excludes.Add(ps.val, ps);
                    }
                }


                Debug.Assert(!ret.bundleSettingMap.ContainsKey(bs.name));
                ret.bundleSettingMap.Add(bs.name, bs);
            }
            return(ret);
        }