- Home /
Question by
MylesLambert · Jul 08, 2021 at 06:48 PM ·
editorserializationserializedobject
SerializedObject IntValue Multi Editing only applies to first object.
I'm trying to to set multiple renderers shadow casting using SerializedObject/ Property and when using EditorGUILayout.PropertyField it works correctly, when using EditorGUILayout.IntField it sets only the first renderer.
SerializedObject serializedRenderers;
SerializedProperty serializedRendererShadowCasting;
serializedRenderers = new SerializedObject(targets.Cast<MyScript>().SelectMany(x => x.GetComponentsInChildren<Renderer>(false)).ToArray());
serializedRendererShadowCasting = serializedRenderers.FindProperty("m_CastShadows");
serializedRenderers.Update();
//EditorGUILayout.PropertyField(serializedRendererShadowCasting); // - This Works
serializedRendererShadowCasting.intValue = EditorGUILayout.IntField(serializedRendererShadowCasting.intValue); // - This only sets the first renderer.
serializedRenderers.ApplyModifiedProperties();
Any idea what would be different between PropertyField/ IntField in this case?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613040034im_/https://answers.unity.com/themes/thub/images/avi.jpg)