Hey all,
I am writing a script that runs in the editor using [ExecuteInEditMode]. During the execution of the script I create new components, and then try to set the values in those new components.
The new components are properly getting created, and the reference given back from AddComponent() seems correct, however when I use that reference to modify the fields on the newly created components, the values don’t get applied.
MyComponent newComponent = child.gameObject.addComponent<MyComponent>();
newComponent.customField = "Foo";
After this runs, looking at the object with the new component in the editor, the component is there, bu customField is blank rather than being “Foo”.