示例#1
0
        public static AssetPackerConfig GetAssetPackerConfig()
        {
            AssetPackerConfig packerConfig = new AssetPackerConfig();

            AssetAddressGroup[] groups = AssetDatabaseUtility.FindInstances <AssetAddressGroup>();
            if (groups != null && groups.Length > 0)
            {
                foreach (var group in groups)
                {
                    AssetPackerGroupData groupData = new AssetPackerGroupData();
                    groupData.groupName      = group.groupName;
                    groupData.isMain         = group.isMain;
                    groupData.isPreload      = group.isPreload;
                    groupData.isNeverDestroy = group.isNeverDestroy;

                    groupData.assetFiles = GetAssetsInGroup(group);

                    packerConfig.groupDatas.Add(groupData);
                }
            }
            packerConfig.Sort();

            AddAddressGroup(packerConfig);

            return(packerConfig);
        }
示例#2
0
 void Awake()
 {
     BitmapFontConfig[] datas = AssetDatabaseUtility.FindInstances <BitmapFontConfig>();
     if (datas != null && datas.Length > 0)
     {
         fontConfigs.AddRange(datas);
     }
 }
示例#3
0
        public static AllAssetDependencyData GetOrCreateAllAssetData()
        {
            if (allAssetData != null)
            {
                return(allAssetData);
            }
            AllAssetDependencyData[] datas = AssetDatabaseUtility.FindInstances <AllAssetDependencyData>();
            if (datas != null && datas.Length > 0)
            {
                allAssetData = datas[0];
            }
            if (allAssetData == null)
            {
                allAssetData = ScriptableObject.CreateInstance <AllAssetDependencyData>();
            }

            return(allAssetData);
        }
示例#4
0
        public static void BuildAssetAddressConfig()
        {
            AssetAddressGroup[] groups = AssetDatabaseUtility.FindInstances <AssetAddressGroup>();
            if (groups != null && groups.Length > 0)
            {
                AssetAddressConfig config = GetOrCreateConfig();
                config.Clear();

                foreach (var group in groups)
                {
                    UpdateConfigByGroup(group);
                }
                config.Reload();

                EditorUtility.SetDirty(config);

                AssetDatabase.SaveAssets();
            }
        }
        public static PackerData GetPackerData()
        {
            AssetGroupCreater[] groups  = AssetDatabaseUtility.FindInstances <AssetGroupCreater>();
            List <AssetResult>  results = new List <AssetResult>();

            foreach (var group in groups)
            {
                results.AddRange(group.GetResults());
            }

            PackerData packerData = new PackerData();

            var groupNames = results.GroupBy((result) => result.GroupName).ToList();

            foreach (var gn in groupNames)
            {
                PackerGroupData groupData = new PackerGroupData();
                groupData.Name = gn.Key;
                packerData.groupDatas.Add(groupData);

                var bundleNames = gn.GroupBy((result) => result.Bundle).ToList();
                foreach (var bn in bundleNames)
                {
                    PackerBundleData bundleData = new PackerBundleData();
                    bundleData.Path = bn.Key;
                    groupData.bundleDatas.Add(bundleData);

                    foreach (var ad in bn)
                    {
                        PackerAssetData assetData = new PackerAssetData();
                        assetData.Address     = ad.Address;
                        assetData.Path        = ad.Path;
                        assetData.IsMainAsset = ad.IsMainAsset;
                        assetData.IsScene     = ad.IsScene;
                        assetData.Labels      = ad.Labels;

                        bundleData.assetDatas.Add(assetData);
                    }
                }
            }

            return(packerData);
        }
示例#6
0
        public static AssetAddressConfig GetOrCreateConfig()
        {
            AssetAddressConfig[] configs = AssetDatabaseUtility.FindInstances <AssetAddressConfig>();

            AssetAddressConfig config;

            if (configs == null || configs.Length == 0)
            {
                string defaultAssetPath = $"Assets/{AssetConst.ASSET_ADDRESS_CONFIG_NAME}";

                config = ScriptableObject.CreateInstance <AssetAddressConfig>();

                AssetDatabase.CreateAsset(config, defaultAssetPath);
                AssetDatabase.ImportAsset(defaultAssetPath);
            }
            else
            {
                config = configs[0];
            }
            return(config);
        }