trophy 0
May 2025 21 posts
Sandbox.ISceneEventElement 't' not allowed
trophy 25
Jul 2024 4 posts
There is a pitfall with this function: If you accidentally use Scene as the go argument, your event will be posted to every listener in the scene.

For example:
	protected override void OnParentChanged( GameObject oldParent, GameObject newParent )
	{
		IParentAssignEvents.PostToGameObject( oldParent, x => x.OnUnassigned( this ) );
		IParentAssignEvents.PostToGameObject( newParent, x => x.OnAssigned( this ) );
	}
To fix this, just verify that either argument is not the Scene before you send the event:
	protected override void OnParentChanged( GameObject oldParent, GameObject newParent )
	{
		if (oldParent != Scene) IParentAssignEvents.PostToGameObject( oldParent, x => x.OnUnassigned( this ) );
		if (newParent != Scene) IParentAssignEvents.PostToGameObject( newParent, x => x.OnAssigned( this ) );
	}
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.