tile scrolling

This commit is contained in:
Rapandrasmus 2023-10-06 18:39:28 +02:00
parent 11e41dc898
commit 3175fc96ef
3 changed files with 195 additions and 13 deletions

View file

@ -1,5 +1,54 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &835447071488136506
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7140657802111334959}
- component: {fileID: 1279630183371755503}
m_Layer: 0
m_Name: BgManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7140657802111334959
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 835447071488136506}
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:
- {fileID: 4037202497222682790}
- {fileID: 6168213607495312789}
m_Father: {fileID: 6038557817912069913}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1279630183371755503
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 835447071488136506}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6db92201e288b8142874d3ff10f666ae, type: 3}
m_Name:
m_EditorClassIdentifier:
_bgTileFirst: {fileID: 4037202497222682790}
_bgTileSecond: {fileID: 6168213607495312789}
_scroll: {fileID: 6038557817912069913}
--- !u!1 &3172294255664916258 --- !u!1 &3172294255664916258
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -109,12 +158,12 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5426698312935073753} m_GameObject: {fileID: 5426698312935073753}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -1.81, y: 2.57, z: 0} m_LocalPosition: {x: -2.3766, y: 2.57, z: 0}
m_LocalScale: {x: 0.621746, y: 0.621746, z: 0.621746} m_LocalScale: {x: 0.621746, y: 0.621746, z: 0.621746}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5840730152797502065} m_Father: {fileID: 7140657802111334959}
m_RootOrder: 1 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &5383238869548644250 --- !u!212 &5383238869548644250
SpriteRenderer: SpriteRenderer:
@ -162,7 +211,91 @@ SpriteRenderer:
m_FlipX: 0 m_FlipX: 0
m_FlipY: 0 m_FlipY: 0
m_DrawMode: 2 m_DrawMode: 2
m_Size: {x: 100, y: 100} m_Size: {x: 98.1775, y: 100}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &5730620054423198957
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6168213607495312789}
- component: {fileID: 1732605413645593641}
m_Layer: 0
m_Name: BgTiles (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6168213607495312789
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5730620054423198957}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 55.77, y: 2.57, z: 0}
m_LocalScale: {x: 0.621746, y: 0.621746, z: 0.621746}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7140657802111334959}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1732605413645593641
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5730620054423198957}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -100
m_Sprite: {fileID: 200310620, guid: 0c4ebc59845a20a4286499a66f2e6c86, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 2
m_Size: {x: 98.1775, y: 100}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0 m_SpriteTileMode: 0
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
@ -198,7 +331,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 6038557817912069913} m_Father: {fileID: 6038557817912069913}
m_RootOrder: 0 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3210442149020197414 --- !u!212 &3210442149020197414
SpriteRenderer: SpriteRenderer:
@ -283,7 +416,7 @@ Transform:
m_Children: m_Children:
- {fileID: 8794133928851332470} - {fileID: 8794133928851332470}
m_Father: {fileID: 5840730152797502065} m_Father: {fileID: 5840730152797502065}
m_RootOrder: 3 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8577280407175396528 --- !u!212 &8577280407175396528
SpriteRenderer: SpriteRenderer:
@ -366,8 +499,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2661844662320053337}
- {fileID: 4037202497222682790}
- {fileID: 6038557817912069913} - {fileID: 6038557817912069913}
- {fileID: 4131922717252530528} - {fileID: 4131922717252530528}
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -425,16 +556,18 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2661844662320053337}
- {fileID: 4618914047223908314} - {fileID: 4618914047223908314}
- {fileID: 7140657802111334959}
m_Father: {fileID: 5840730152797502065} m_Father: {fileID: 5840730152797502065}
m_RootOrder: 2 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &8166682498639938566 --- !u!1001 &8166682498639938566
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 5840730152797502065} m_TransformParent: {fileID: 6038557817912069913}
m_Modifications: m_Modifications:
- target: {fileID: 4482739629151873282, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3} - target: {fileID: 4482739629151873282, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
propertyPath: m_Name propertyPath: m_Name
@ -462,15 +595,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3} - target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3} - target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3} - target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3} - target: {fileID: 6171382744519440479, guid: 8c681a700cd16784580f97e7f10a53e6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x

View file

@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Games.Scripts_AnimalAcrobat
{
public class BGTileManager : MonoBehaviour
{
[Header("Components")]
[SerializeField] private Transform _bgTileFirst;
[SerializeField] private Transform _bgTileSecond;
[SerializeField] private Transform _scroll;
private float _tileDistance;
private bool _putSecondInFront;
private float _reachTileDistance;
private void Awake()
{
_tileDistance = _bgTileSecond.transform.localPosition.x - _bgTileFirst.transform.localPosition.x;
_reachTileDistance = _tileDistance;
}
private void LateUpdate()
{
if (_scroll.localPosition.x <= -_reachTileDistance)
{
var bgTile = _putSecondInFront ? _bgTileSecond : _bgTileFirst;
bgTile.localPosition = new Vector3(bgTile.localPosition.x + (_tileDistance * 2), bgTile.localPosition.y);
_putSecondInFront = !_putSecondInFront;
_reachTileDistance += _tileDistance;
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6db92201e288b8142874d3ff10f666ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: