This World Shifter is designed to be used in conjunction with a Standard Hierarchy Organizer. With it, you can choose exactly which Transforms from the hierarchy are shifted in order to carry out the World Shift.
You can add this component by selecting a game object and then selecting from the Top Menu Bar:
Component -> Deep Space Labs -> -> SAM -> World Shifters -> Standard Hierarchy World Shifter
or by selecting a game object and using the Add Component menu via its inspector:
Component -> Deep Space Labs -> -> SAM -> World Shifters -> Standard Hierarchy World Shifter
This World Shifter targets specific Transforms within the Standard Hierarchy in order to perform the shifting. The most basic target possible is the Transform belonging to the Root Game Object. Shifting this root game object will shift all children (which should be everything loaded for the World) in a single operation.
Moving beyond the Root Transform, you can move down the hierarchy to target children of the Root Game Object, from Base Cell Transforms all the way to the Transforms of the Asset Chunks themselves.
Generally Speaking, each move downward in the Hierarchy will result in more Transforms needing to be moved, which will slow down the speed at which the World is shifted but potentially result in more performant shifting. You will need to experiment and try to balance the performance impact of the shift with the potential for the player to notice the World being shifted (which is more likely the slower the shift occurs).
For each target transform in the What To Shift option, you must ensure that transform will actually exist in the hierarchy. For instance, if targeting the Root Game Object, your Standard Hierarchy Organizer's Root Option setting cannot be set to No_Root. If targeting Base Cells, Group Objects From Same Base Cell must be enabled.
The only targets not affected by the Standard Hierarchy Organizer's setting is the Chunk Transforms, since Asset Chunk
Choosing When To Shift can be just as important of a decision as choosing What To Shift, as certain objects may need to be moved at specific points in the Unity Frame Lifecycle.
You basically have three options; shifting just after FixedUpdate, shifting just after Update, or shifting at the End Of Frame. Please note the following:
1) Fixed Update uses a yield return WaitForFixedUpdate statement, so the actual shift will occur not within the normal FixedUpdate method, but instead at the end of a Physics Cycle.
2) Similarly, Update does not use the normal Update method, but instead a yield return null statement. The result is that shift will occur after all normal Update methods on other scripts have run.
3) The End Of Frame option uses a yield return WaitForEndOfFrame statement, which executes very close to the end of the frame, just after Gizmo and GUI rendering.
For a complete breakdown of the frame lifecycle, please refer to the Unity Docs. This can give you a better idea of where in the life cycle the World Shift will occur.
You can control the maximum number of Transforms that are shifted each frame using the Max Transforms To Shift Per Frame option. If you want all transforms to be shifted at the same time (even when Perform Shift In Single Frame is disabled), you can set this value to 0.
A smaller value will usually be more performant but will result in slower shifting, which might be noticeable to the user of your game.
It can be beneficial to move Players using the World Shifter rather than with the Active Grid class. This is because the World Shifter can time the movement of the Players so that they occur closer to when the World is actually shifted.
With that said, Players are always moved just before the World is shifted, which may still be noticeable to the users of your Game. If that is the case, you will need to create a custom World Shifter with more precise timing between the Player movement and the World Shift.