{"record":{"id":"23ce4edf834ccc4a","repo":"Unity-Technologies/UnityCsReference","slug":"index-must-be-between-0-and-emissivetextureproper","errorCode":null,"errorMessage":"index must be between 0 and {emissiveTexturePropertiesCount - 1}, but was {index}","messagePattern":"index must be between 0 and (.+?), but was (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GI/LightBaker.bindings.cs","lineNumber":624,"sourceCode":"        extern TextureData Internal_GetEmissiveTextureData(uint index);\n        extern void Internal_SetEmissiveTextureData(uint index, TextureData textureData);\n        public TextureData GetEmissiveTextureData(uint index)\n        {\n            if (index >= emissiveTextureCount)\n                throw new ArgumentException($\"index must be between 0 and {emissiveTextureCount - 1}, but was {index}\");\n            return Internal_GetEmissiveTextureData(index);\n        }\n        public void SetEmissiveTextureData(uint index, TextureData textureData)\n        {\n            if (index >= emissiveTextureCount)\n                throw new ArgumentException($\"index must be between 0 and {emissiveTextureCount - 1}, but was {index}\");\n            Internal_SetEmissiveTextureData(index, textureData);\n        }\n        extern TextureProperties Internal_GetEmissiveTextureProperties(uint index);\n        public TextureProperties GetEmissiveTextureProperties(uint index)\n        {\n            if (index >= emissiveTexturePropertiesCount)\n                throw new ArgumentException($\"index must be between 0 and {emissiveTexturePropertiesCount - 1}, but was {index}\");\n            return Internal_GetEmissiveTextureProperties(index);\n        }\n        extern void Internal_SetEmissiveTextureProperties(uint index, TextureProperties textureProperties);\n        public void SetEmissiveTextureProperties(uint index, TextureProperties textureProperties)\n        {\n            if (index >= emissiveTexturePropertiesCount)\n                throw new ArgumentException($\"index must be between 0 and {emissiveTexturePropertiesCount - 1}, but was {index}\");\n            Internal_SetEmissiveTextureProperties(index, textureProperties);\n        }\n\n        extern TextureData Internal_GetTransmissiveTextureData(uint index);\n        extern void Internal_SetTransmissiveTextureData(uint index, TextureData textureData);\n        public TextureData GetTransmissiveTextureData(uint index)\n        {\n            if (index >= transmissiveTextureCount)\n                throw new ArgumentException($\"index must be between 0 and {transmissiveTextureCount - 1}, but was {index}\");\n            return Internal_GetTransmissiveTextureData(index);\n        }","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GI/LightBaker.bindings.cs#L606-L642","documentation":"Thrown by BakeInput.GetEmissiveTextureProperties when the uint index is >= emissiveTexturePropertiesCount. Emissive TextureProperties are a separate collection from emissive TextureData (emissiveTextureCount), so the two counts can differ and must not be used interchangeably.","triggerScenarios":"Reading emissive properties in a loop bounded by emissiveTextureCount or another channel's count; reading properties that InputExtraction never populated.","commonSituations":"Readback assuming data and properties are 1:1 per channel; scenes where emissive data exists but properties extraction was skipped.","solutions":["Bound iteration by emissiveTexturePropertiesCount.","Confirm InputExtraction populated emissive properties before reading them.","Guard: if (index < bakeInput.emissiveTexturePropertiesCount) { ... }"],"exampleFix":"// before\nfor (uint i = 0; i < bakeInput.emissiveTextureCount; i++)\n    p.Add(bakeInput.GetEmissiveTextureProperties(i));\n// after\nfor (uint i = 0; i < bakeInput.emissiveTexturePropertiesCount; i++)\n    p.Add(bakeInput.GetEmissiveTextureProperties(i));","handlingStrategy":"validation","validationCode":"if (index < bakeInput.emissiveTexturePropertiesCount)\n{\n    var p = bakeInput.GetEmissiveTextureProperties(index);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use emissiveTexturePropertiesCount for properties, emissiveTextureCount for data.","Confirm properties were populated before reading.","Keep data and properties aligned if 1:1 is assumed."],"tags":["lightmapping","gi","bake-input","index-bounds","emissive","properties","unity"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}