Trying to sync UI tabs to transition

This commit is contained in:
misabiko 2022-05-14 09:47:57 -04:00
parent f0348459b6
commit 3f5fbfe1e1
2 changed files with 468 additions and 15 deletions

View File

@ -123,6 +123,82 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &99834112
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 99834113}
- component: {fileID: 99834115}
- component: {fileID: 99834114}
m_Layer: 5
m_Name: WorldTab3
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &99834113
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 99834112}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1076402456}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 25, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &99834114
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 99834112}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &99834115
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 99834112}
m_CullTransparentMesh: 1
--- !u!1 &260114732 --- !u!1 &260114732
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -648,6 +724,337 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &903224217
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 903224218}
- component: {fileID: 903224220}
- component: {fileID: 903224219}
m_Layer: 5
m_Name: WorldTab1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &903224218
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 903224217}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1076402456}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 25, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &903224219
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 903224217}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &903224220
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 903224217}
m_CullTransparentMesh: 1
--- !u!1 &1006226459
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1006226460}
- component: {fileID: 1006226462}
- component: {fileID: 1006226461}
m_Layer: 5
m_Name: WorldTab2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1006226460
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1006226459}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1076402456}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -14, y: 0}
m_SizeDelta: {x: 29, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1006226461
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1006226459}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1006226462
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1006226459}
m_CullTransparentMesh: 1
--- !u!1 &1076402452
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1076402456}
- component: {fileID: 1076402455}
- component: {fileID: 1076402454}
- component: {fileID: 1076402453}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!114 &1076402453
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1076402452}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1076402454
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1076402452}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &1076402455
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1076402452}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1076402456
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1076402452}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 903224218}
- {fileID: 1006226460}
- {fileID: 99834113}
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1118408972
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1118408975}
- component: {fileID: 1118408974}
- component: {fileID: 1118408976}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1118408974
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118408972}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1118408975
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118408972}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1118408976
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118408972}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
--- !u!1 &1171096952 --- !u!1 &1171096952
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -972,7 +1379,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 02e217105518e1f418b52195b8b328d7, type: 3} m_Script: {fileID: 11500000, guid: 02e217105518e1f418b52195b8b328d7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
transitionDuration: 0.5 transitionDuration: 5
transitionCurve: transitionCurve:
serializedVersion: 2 serializedVersion: 2
m_Curve: m_Curve:
@ -997,11 +1404,18 @@ MonoBehaviour:
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
cameras: worldInfos:
- {fileID: 646706616} - camera: {fileID: 646706616}
- {fileID: 2087698543} worldTab: {fileID: 903224218}
indexFromSide: 0
side: 0
- camera: {fileID: 2087698543}
worldTab: {fileID: 1006226460}
indexFromSide: 0
side: 1
renderQuad: {fileID: 817274629} renderQuad: {fileID: 817274629}
quadOffset: 0.84 quadOffset: 0.84
tabWidth: 12.5
--- !u!1 &1566262316 --- !u!1 &1566262316
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -6,9 +6,10 @@ public class WorldSwitcher : MonoBehaviour {
[Range(0, 5)] [Range(0, 5)]
[SerializeField] float transitionDuration; [SerializeField] float transitionDuration;
[SerializeField] AnimationCurve transitionCurve; [SerializeField] AnimationCurve transitionCurve;
[SerializeField] Camera[] cameras; [SerializeField] WorldInfo[] worldInfos;
[SerializeField] Transform renderQuad; [SerializeField] Transform renderQuad;
[SerializeField] float quadOffset; [SerializeField] float quadOffset;
[SerializeField] float tabWidth;
int lastWorldIndex; int lastWorldIndex;
int currentWorldIndex; int currentWorldIndex;
Coroutine transition; Coroutine transition;
@ -16,7 +17,7 @@ public class WorldSwitcher : MonoBehaviour {
Material renderMaterial; Material renderMaterial;
void Awake() { void Awake() {
if (cameras.Length <= 1) if (worldInfos.Length <= 1)
Debug.LogWarning("WorldSwitcher should have multiple cameras"); Debug.LogWarning("WorldSwitcher should have multiple cameras");
currentWorldIndex = 0; currentWorldIndex = 0;
@ -24,19 +25,28 @@ public class WorldSwitcher : MonoBehaviour {
renderMaterial = renderQuad.GetComponent<Renderer>().material; renderMaterial = renderQuad.GetComponent<Renderer>().material;
GenerateRenderTexture(); GenerateRenderTexture();
for (int i = 0; i < worldInfos.Length; i++) {
WorldInfo worldInfo = worldInfos[i];
worldInfo.camera.enabled = i == 0;
Vector3 tabPos = worldInfo.worldTab.position;
float tabX = worldInfo.side == TabSide.Left ? 0 : ((RectTransform)worldInfo.worldTab.parent).rect.width;
worldInfo.worldTab.position = new Vector3(tabX, tabPos.y, tabPos.z);
}
} }
public void SwitchWorld(int index) { public void SwitchWorld(int index) {
if (index == currentWorldIndex) if (index == currentWorldIndex)
return; return;
if (index < 0 || index >= cameras.Length) if (index < 0 || index >= worldInfos.Length)
throw new IndexOutOfRangeException($"{index} is not an available world."); throw new IndexOutOfRangeException($"{index} is not an available world.");
lastWorldIndex = currentWorldIndex; lastWorldIndex = currentWorldIndex;
currentWorldIndex = index; currentWorldIndex = index;
Camera currCam = cameras[currentWorldIndex]; Camera currCam = worldInfos[currentWorldIndex].camera;
currCam.enabled = true; currCam.enabled = true;
//TODO Block window resize during transition? //TODO Block window resize during transition?
@ -45,13 +55,16 @@ public class WorldSwitcher : MonoBehaviour {
currCam.targetTexture = renderTexture; currCam.targetTexture = renderTexture;
renderQuad.localScale = new Vector3(cameras[lastWorldIndex].aspect, 1f, 1f); renderQuad.localScale = new Vector3(worldInfos[lastWorldIndex].camera.aspect, 1f, 1f);
Vector3 oldPos = worldInfos[lastWorldIndex].worldTab.position;
worldInfos[lastWorldIndex].worldTab.position = new Vector3(worldInfos[lastWorldIndex].TabBaseX, oldPos.y, oldPos.z);
transition = StartCoroutine(TransitionCamera()); transition = StartCoroutine(TransitionCamera());
} }
void OnGUI() { void OnGUI() {
for (int i = 0; i < cameras.Length; ++i) { for (int i = 0; i < worldInfos.Length; ++i) {
if (i == currentWorldIndex) if (i == currentWorldIndex)
continue; continue;
@ -61,19 +74,28 @@ public class WorldSwitcher : MonoBehaviour {
} }
IEnumerator TransitionCamera() { IEnumerator TransitionCamera() {
WorldInfo lastWorld = worldInfos[lastWorldIndex];
WorldInfo newWorld = worldInfos[currentWorldIndex];
float startTime = Time.time; float startTime = Time.time;
Transform lastCam = cameras[lastWorldIndex].transform; Transform lastCam = lastWorld.camera.transform;
Vector3 tabStartPosition = newWorld.worldTab.position;
float tabParentWidth = newWorld.TabParentWidth;
while (Time.time < startTime + transitionDuration) { while (Time.time < startTime + transitionDuration) {
float t = transitionCurve.Evaluate((Time.time - startTime) / transitionDuration); float t = transitionCurve.Evaluate((Time.time - startTime) / transitionDuration);
t *= (tabParentWidth + tabWidth) / tabParentWidth;
renderQuad.position = lastCam.position + Vector3.forward * quadOffset + Vector3.right * (2f * t - 2f); renderQuad.position = lastCam.position + Vector3.forward * quadOffset + Vector3.right * (2f * Mathf.Clamp01(t) - 2f);
//float tabX = newWorld.side == TabSide.Left ? t * (tabParentWidth + tabWidth) : t * -(tabParentWidth + tabWidth) + tabParentWidth;
newWorld.worldTab.position = new Vector3(tabParentWidth * t, tabStartPosition.y, tabStartPosition.z);
yield return null; yield return null;
} }
cameras[currentWorldIndex].targetTexture = null; newWorld.camera.targetTexture = null;
cameras[lastWorldIndex].enabled = false; lastWorld.camera.enabled = false;
transition = null; transition = null;
} }
@ -81,4 +103,21 @@ public class WorldSwitcher : MonoBehaviour {
renderTexture = new RenderTexture(Screen.width, Screen.height, 32); renderTexture = new RenderTexture(Screen.width, Screen.height, 32);
renderMaterial.mainTexture = renderTexture; renderMaterial.mainTexture = renderTexture;
} }
} }
[Serializable]
struct WorldInfo {
public Camera camera;
public RectTransform worldTab;
public ushort indexFromSide;
public TabSide side;
public float TabParentWidth => ((RectTransform)worldTab.parent).rect.width;
public float TabBaseX => side == TabSide.Left ?
indexFromSide * 6.25f :
TabParentWidth - indexFromSide * 6.25f;
}
[Serializable]
enum TabSide { Left, Right }