neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.01k stars 895 forks source link

ObservableDestroyTrigger instances are saved to prefabs #497

Open lostlont opened 3 years ago

lostlont commented 3 years ago

Using .AddTo() in a MonoBehaviour adds an ObservableDestroyTrigger to the specified game object. If a component has the [ExecuteInEditMode] attribute then the destroy trigger is added to the game object when it is being edited on a prefab. As this component holds data only used in the current "session", and not needed to be saved, shouldn't it receive something like hideFlags |= HideFlags.DontSaveInEditor; in the constructor or at Awake? Having an additional ObservableDestroyTrigger in the prefab is probably not harmful, but it's kind of a noise, as if the other subscribing components are removed then it is not even needed on the prefab.