Smooth wrapping of objects on a 2D Orthographic View. Use of 8 other cameras to overlay main camera. Script also handles introducing objects into the scene.
- Add ScreenWrapper.cs to your main camera.
- Create a new layer and enter it in the
Culling Mask
variable. - Add the ScreenWrappingObject.cs to any objects you want to be wrapped.
Called before an object is teleported (wrapped). The event outs a GameObject variable.
void Awake() {
ScreenWrapper.OnTeleport += DoSomething;
}
void OnDestroy() {
ScreenWrapper.OnTeleport -= DoSomething;
}
void DoSomething(GameObject gO) {
if(gO == this.gameObject) {
print("My Last Position before teleporting:" + gO.transform.position);
}
}
If the camera is not expected to move, the bool can be checked to increase performance