/// <summary> /// Randomizes the material texture of tagged objects at the start of each scenario iteration /// </summary> protected override void OnIterationStart() { var tags = tagManager.Query <TextureRandomizerTag>(); foreach (var tag in tags) { var renderer = tag.GetComponent <Renderer>(); #if HDRP_PRESENT // Choose the appropriate shader texture property ID depending on whether the current material is // using the default HDRP/lit shader or the Perception tutorial's HueShiftOpaque shader var material = renderer.material; var propertyId = material.shader.name == k_TutorialHueShaderName ? k_BaseMap : k_BaseColorMap; material.SetTexture(propertyId, texture.Sample()); #else renderer.material.SetTexture(k_BaseMap, texture.Sample()); #endif } }
/// <summary> /// Randomizes the material texture of tagged objects at the start of each scenario iteration /// </summary> protected override void OnIterationStart() { var taggedObjects = tagManager.Query <TextureRandomizerTag>(); foreach (var taggedObject in taggedObjects) { var renderer = taggedObject.GetComponent <MeshRenderer>(); renderer.material.SetTexture(k_BaseTexture, texture.Sample()); } }