Merge pull request #25 from EliasFleckenstein03/main

Fix background parallax tiling (Set tiling mode to continuous)
This commit is contained in:
KG0104 2021-10-30 16:47:03 +02:00 committed by GitHub
commit e9b1f6fb50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 15 deletions

View File

@ -2978,9 +2978,9 @@ SpriteRenderer:
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 2
m_Size: {x: 180, y: 9.001612}
m_Size: {x: 180, y: 20.5}
m_AdaptiveModeThreshold: 0
m_SpriteTileMode: 1
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
@ -2993,7 +2993,7 @@ Transform:
m_GameObject: {fileID: 520214744}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.4, y: -17.8, z: 0}
m_LocalScale: {x: 2.000247, y: 4.559183, z: 1}
m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 38
@ -3188,7 +3188,7 @@ SpriteRenderer:
m_DrawMode: 2
m_Size: {x: 280, y: 64.8}
m_AdaptiveModeThreshold: 0
m_SpriteTileMode: 1
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
@ -10685,7 +10685,7 @@ SpriteRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107259358}
m_Enabled: 1
m_Enabled: 0
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
@ -10725,7 +10725,7 @@ SpriteRenderer:
m_DrawMode: 2
m_Size: {x: 180, y: 13.7300005}
m_AdaptiveModeThreshold: 0
m_SpriteTileMode: 1
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
@ -16038,7 +16038,7 @@ SpriteRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1851206811}
m_Enabled: 1
m_Enabled: 0
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
@ -16076,9 +16076,9 @@ SpriteRenderer:
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 2
m_Size: {x: 180, y: 9.03}
m_Size: {x: 180, y: 15.5}
m_AdaptiveModeThreshold: 0
m_SpriteTileMode: 1
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
@ -16091,7 +16091,7 @@ Transform:
m_GameObject: {fileID: 1851206811}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.4, y: -18.7, z: 0}
m_LocalScale: {x: 2.1661217, y: 3.4434092, z: 1}
m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 39
@ -16146,7 +16146,6 @@ MonoBehaviour:
SpeechBubble: {fileID: 678625800}
mouse: {fileID: 936765968}
dialogueText: {fileID: 30332658}
index: 0
typingSpeed: 0.04
dialogueTriggerer:
- {fileID: 1559449786}

View File

@ -7,7 +7,7 @@ public class Parallaxing : MonoBehaviour
[SerializeField] private Vector2 parallaxEffectMultiplier;
[SerializeField] private bool infiniteHorizontal;
[SerializeField] private bool infiniteVertical;
private Transform cameraTransform;
Vector3 lastCameraPosition;
private float textureUnitSizeX;
@ -29,7 +29,7 @@ public class Parallaxing : MonoBehaviour
transform.position += new Vector3(deltaMovement.x * parallaxEffectMultiplier.x, deltaMovement.y * parallaxEffectMultiplier.y);
lastCameraPosition = cameraTransform.position;
if(infiniteVertical)
if(infiniteHorizontal)
{
if (Mathf.Abs(cameraTransform.position.x - transform.position.x) >= textureUnitSizeX)
{
@ -38,7 +38,7 @@ public class Parallaxing : MonoBehaviour
}
}
if(infiniteHorizontal)
if(infiniteVertical)
{
if (Mathf.Abs(cameraTransform.position.y - transform.position.y) >= textureUnitSizeY)
{
@ -47,4 +47,4 @@ public class Parallaxing : MonoBehaviour
}
}
}
}
}