{"id":2272,"date":"2021-08-06T11:11:16","date_gmt":"2021-08-06T03:11:16","guid":{"rendered":"http:\/\/www.u3d8.com\/?p=2272"},"modified":"2021-08-06T12:19:05","modified_gmt":"2021-08-06T04:19:05","slug":"addressable%e4%b9%8b%e4%bb%a3%e7%a0%81%e8%ae%be%e7%bd%ae%e5%a4%a7%e5%b0%8f%e5%8c%85","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=2272","title":{"rendered":"Addressable\u4e4b\u4ee3\u7801\u8bbe\u7f6e\u5927\u5c0f\u5305"},"content":{"rendered":"\n<p>\u719f\u6089Addressable\u7684\u540c\u5b66\u5e94\u8be5\u6e05\u695a\uff0cAddressable\u8bbe\u7f6e\u5927\u5c0f\u5305\uff0c\u662f\u4fee\u6539AddressableAssetGroup\u7684BuildPath\u3001LoadPath\u3002\u5373Remote\u4e3a\u5c0f\u5305\u3001Local\u4e3a\u6253\u5305<\/p>\n\n\n\n<p>\u90a3\u4e48\u5982\u4f55\u4ee3\u7801\u91cc\u4fee\u6539\u5462\uff1f\u5982\u679c\u80fd\u4ee3\u7801\u4fee\u6539\u5c31\u53ef\u4ee5\u652f\u6301\u4e00\u952e\u6253\u5305\u4e86<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2021\/08\/QQ\u622a\u56fe20210806110706.jpg\" data-lightbox=\"image_lg\"><img title=\"Addressable\u4e4b\u4ee3\u7801\u8bbe\u7f6e\u5927\u5c0f\u5305 - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"Addressable\u4e4b\u4ee3\u7801\u8bbe\u7f6e\u5927\u5c0f\u5305 - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" width=\"510\" height=\"352\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2021\/08\/QQ\u622a\u56fe20210806110706.jpg\" alt=\"\" class=\"wp-image-2273\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2021\/08\/QQ\u622a\u56fe20210806110706.jpg 510w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2021\/08\/QQ\u622a\u56fe20210806110706-300x207.jpg 300w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/a><\/figure>\n\n\n\n<p>\u4e0b\u9762\u9644\u4e0a\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        \/\/\/ &lt;summary&gt;\n        \/\/\/ \u8bbe\u7f6e\u8d44\u6e90\u6253\u8fdb\u5305\u4f53\u91cc\uff08\u5927\u5305\uff09\n        \/\/\/ &lt;\/summary&gt;\n        public static void SetLargePacket()\n        {\n            foreach (var addressableAssetGroup in addressableAssetSettings.groups)\n            {\n                if (addressableAssetGroup.IsDefaultGroup() || addressableAssetGroup.ReadOnly)\n                    continue;\n                for (int i = 0; i &lt; addressableAssetGroup.Schemas.Count; i++)\n                {\n                    var schema = addressableAssetGroup.Schemas&#91;i];\n                    if (schema is UnityEditor.AddressableAssets.Settings.GroupSchemas.ContentUpdateGroupSchema)\n                    {\n                        (schema as UnityEditor.AddressableAssets.Settings.GroupSchemas.ContentUpdateGroupSchema)\n                            .StaticContent = true;\n                    }\n                    else if (schema is UnityEditor.AddressableAssets.Settings.GroupSchemas\n                        .BundledAssetGroupSchema)\n                    {\n                        var bundledAssetGroupSchema =\n                            (schema as UnityEditor.AddressableAssets.Settings.GroupSchemas.BundledAssetGroupSchema);\n                        bundledAssetGroupSchema.BuildPath.SetVariableByName(addressableAssetGroup.Settings,\n                            AddressableAssetSettings.kLocalBuildPath);\n                        bundledAssetGroupSchema.LoadPath.SetVariableByName(addressableAssetGroup.Settings,\n                            AddressableAssetSettings.kLocalLoadPath);\n                    }\n                }\n            }\n            AssetDatabase.SaveAssets();\n            AssetDatabase.Refresh();\n            Debuger.Log(\"\u8bbe\u7f6e\u6210\u5927\u5305\u8d44\u6e90\u5b8c\u6210\");\n        }\n\n        \/\/\/ &lt;summary&gt;\n        \/\/\/ \u8bbe\u7f6e\u8d44\u6e90\u4e0d\u6253\u8fdb\u5305\u4f53\u91cc\uff08\u5c0f\u5305\uff09\n        \/\/\/ &lt;\/summary&gt;\n        public static void SetSmallPacket()\n        {\n            foreach (var addressableAssetGroup in addressableAssetSettings.groups)\n            {\n                if (addressableAssetGroup.IsDefaultGroup() || addressableAssetGroup.ReadOnly)\n                    continue;\n                for (int i = 0; i &lt; addressableAssetGroup.Schemas.Count; i++)\n                {\n                    var schema = addressableAssetGroup.Schemas&#91;i];\n                    if (schema is UnityEditor.AddressableAssets.Settings.GroupSchemas.ContentUpdateGroupSchema)\n                    {\n                        (schema as UnityEditor.AddressableAssets.Settings.GroupSchemas.ContentUpdateGroupSchema)\n                            .StaticContent = true;\n                    }\n                    else if (schema is UnityEditor.AddressableAssets.Settings.GroupSchemas\n                        .BundledAssetGroupSchema)\n                    {\n                        var bundledAssetGroupSchema =\n                            (schema as UnityEditor.AddressableAssets.Settings.GroupSchemas.BundledAssetGroupSchema);\n                        bundledAssetGroupSchema.BuildPath.SetVariableByName(addressableAssetGroup.Settings,\n                            AddressableAssetSettings.kRemoteBuildPath);\n                        bundledAssetGroupSchema.LoadPath.SetVariableByName(addressableAssetGroup.Settings,\n                            AddressableAssetSettings.kRemoteLoadPath);\n                    }\n                }\n            }\n            AssetDatabase.SaveAssets();\n            AssetDatabase.Refresh();\n            Debuger.Log(\"\u8bbe\u7f6e\u6210\u5c0f\u5305\u8d44\u6e90\u5b8c\u6210\");\n        }\n        private static AddressableAssetSettings m_AddressableAssetSettings;\n        private static AddressableAssetSettings addressableAssetSettings\n        {\n            get\n            {\n                if (m_AddressableAssetSettings == null)\n                {\n                    m_AddressableAssetSettings = AddressableAssetSettingsDefaultObject.Settings;\n                    if (m_AddressableAssetSettings == null)\n                        m_AddressableAssetSettings = AssetDatabase.LoadAssetAtPath&lt;AddressableAssetSettings&gt;(\"Assets\/AddressableAssetsData\/AddressableAssetSettings.asset\");\n                }\n                return m_AddressableAssetSettings;\n            }\n        }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u719f\u6089Addressable\u7684\u540c\u5b66\u5e94\u8be5\u6e05\u695a\uff0cAddressable\u8bbe\u7f6e\u5927\u5c0f\u5305\uff0c\u662f\u4fee &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=2272\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,23],"tags":[],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/2272"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2272"}],"version-history":[{"count":4,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/2272\/revisions"}],"predecessor-version":[{"id":2280,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/2272\/revisions\/2280"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2272"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}