Give Page Feedback | API

Secondary Non Components - World Shift Event

Represents a World Shift event. The intent of this class is solely to add the ability to subscribe to an event in the Unity inspector when the World is shifted. This event is not found on the World class, but is instead found in custom World Shifter classes.

The idea is to allow other scripts to receive notification exactly at the time of shifting. When a World Shifter class is setup correctly, a PreWorldShift and PostWorldShift event is fired before and after the world is shifted as a whole. If you need more fine grained control over logic that is dependent on individual transforms of the World being shifted, take a look at the TransformShiftEvent instead.

To subscribe to this event, in a separate MonoBehaviour class, create a public method with System.Object and WorldShiftEventArgs parameters. The name of the method or parameters does not matter. After saving the class, add it to a Game Object in your scene, and then in your World Shifter's inspector, add a new listener by pressing the + button on the event you care about (or both). Drag the MonoBehaviour that will be the listerner to the field that appears, and then select the method you created in the drop down list.

Alternatively, the WorldShifter has Subscribe and Unsubscribe events for hooking up listeners during runtime via code (make sure to Unsubscribe!). Usually this is done in the OnEnable and OnDisable methods of your MonoBehaviour.