{"record":{"id":"e52c71dcb0617d7f","repo":"Unity-Technologies/UnityCsReference","slug":"persistentlocalstoragesize-must-be-between-256-and","errorCode":null,"errorMessage":"PersistentLocalStorageSize must be between 256 and 4096, but was {0}","messagePattern":"PersistentLocalStorageSize must be between 256 and 4096, but was (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayerSettingsXboxOne.bindings.cs","lineNumber":288,"sourceCode":"\n            // *undocumented*\n            [Obsolete(\"Starting May 11th 2020 any new base game submission releasing digital only, \" +\n                \"digital and disc, or disc only, should not include a ratings element in the \" +\n                \"AppxManifest. This ratings policy update applies to all Xbox supported ratings. \" +\n                \"New base submissions that come in on or after this date will be \" +\n                \"rejected by your Microsoft Representative if a ratings element is present.\", false)]\n            [NativeMethod(\"GetXboxOneGameRating\")]\n            [StaticAccessor(\"GetPlayerSettings().GetEditorOnly()\", StaticAccessorType.Dot)]\n            extern public static int GetGameRating(string name);\n\n            // The presence of any other value than 0 for this property will result in a PLS reservation in your app manifest.\n            public static uint PersistentLocalStorageSize\n            {\n                get { return persistentLocalStorageSizeInternal; }\n                set\n                {\n                    if (value < 256 || value >= 4096)\n                        throw new ArgumentException(string.Format(\"PersistentLocalStorageSize must be between 256 and 4096, but was {0}\", value));\n\n                    persistentLocalStorageSizeInternal = value;\n                }\n            }\n\n            [NativeProperty(\"XboxOnePersistentLocalStorageSize\", TargetType.Field)]\n            extern private static uint persistentLocalStorageSizeInternal\n            {\n                [StaticAccessor(\"GetPlayerSettings().GetEditorOnly()\", StaticAccessorType.Dot)]\n                get;\n                [StaticAccessor(\"GetPlayerSettings().GetEditorOnlyForUpdate()\", StaticAccessorType.Dot)]\n                set;\n            }\n\n            // Enable/Disable Type Optimization in C++ Compiler 'Master' build, applies to LTCG.\n            [NativeProperty(\"XboxOneEnableTypeOptimization\")]\n            [StaticAccessor(\"GetPlayerSettings()\", StaticAccessorType.Dot)]\n            extern public static bool EnableTypeOptimization { get; set; }","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayerSettingsXboxOne.bindings.cs#L270-L306","documentation":"PlayerSettings.XboxOne.PersistentLocalStorageSize is a uint property that reserves Persistent Local Storage (PLS) space in the Xbox One app manifest. The Xbox One platform requires the value to be between 256 and 4096 (MB). Setting a value outside this range throws ArgumentException with the attempted value. A value of 0 means no PLS reservation.","triggerScenarios":"Setting PlayerSettings.XboxOne.PersistentLocalStorageSize to a value less than 256 (e.g., 100) or greater than/equal to 4096 (e.g., 5000). Passing a value read from a config file or computed at runtime without range validation.","commonSituations":"Build scripts that read PLS size from a JSON/YAML config file and pass it directly without clamping. Porting a project from another platform where storage limits differ. Editor automation that sets PLS based on dynamic calculations.","solutions":["Clamp the value to the valid range before assignment: value = Math.Max(256u, Math.Min(4095u, value))","If no PLS reservation is needed, set the value to 0 (which is allowed and means no reservation)","Validate config file values against the 256-4095 range during project load","Use Math.Clamp(value, 256u, 4095u) (available in .NET Core 2.0+ / Unity 2019.4+)"],"exampleFix":"// before\nPlayerSettings.XboxOne.PersistentLocalStorageSize = configuredPlsSize; // could be 100 or 5000\n\n// after\nuint plsSize = Math.Clamp(configuredPlsSize, 256u, 4095u);\nif (configuredPlsSize == 0)\n    plsSize = 0; // no reservation\nPlayerSettings.XboxOne.PersistentLocalStorageSize = plsSize;","handlingStrategy":"validation","validationCode":"uint plsSize = configuredValue;\nif (plsSize != 0 && (plsSize < 256 || plsSize >= 4096))\n    Debug.LogError($\"PersistentLocalStorageSize {plsSize} is out of range [256, 4095] or 0 for none.\");\nelse\n    PlayerSettings.XboxOne.PersistentLocalStorageSize = plsSize;","typeGuard":null,"tryCatchPattern":"try { PlayerSettings.XboxOne.PersistentLocalStorageSize = plsSize; }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"PersistentLocalStorageSize\"))\n{ Debug.LogError($\"Invalid PLS size. Must be 256-4095 or 0 for none. {ex.Message}\"); }","preventionTips":["Clamp config-driven values with Math.Clamp(value, 256u, 4095u) before assignment","Document the valid range (256-4095 MB, or 0 for no reservation) in config file comments","Add a validation step in build scripts that checks PLS size before the build"],"tags":["unity","xboxone","editor-scripting","playersettings","storage","validation","argumentexception"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}