From 5dd33ba71c30304d76598bc5cb9a97923143bf11 Mon Sep 17 00:00:00 2001 From: GungHolo Date: Wed, 17 May 2023 08:20:16 +0200 Subject: [PATCH] Fading Platforms added and Sample Prefab added --- .../Prefabs/FadingPlatform.prefab | 151 +++++++++++++++ .../Prefabs/FadingPlatform.prefab.meta | 7 + ...latParent.prefab => MovingPlatform.prefab} | 2 +- ...prefab.meta => MovingPlatform.prefab.meta} | 0 Assets/AssetsFORELLE/Script/FadingPlatform.cs | 57 ++++++ .../Script/FadingPlatform.cs.meta | 11 ++ Assets/Scenes/SampleScene.unity | 175 +++++++----------- 7 files changed, 290 insertions(+), 113 deletions(-) create mode 100644 Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab create mode 100644 Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab.meta rename Assets/AssetsFORELLE/Prefabs/{MovPlatParent.prefab => MovingPlatform.prefab} (99%) rename Assets/AssetsFORELLE/Prefabs/{MovPlatParent.prefab.meta => MovingPlatform.prefab.meta} (100%) create mode 100644 Assets/AssetsFORELLE/Script/FadingPlatform.cs create mode 100644 Assets/AssetsFORELLE/Script/FadingPlatform.cs.meta diff --git a/Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab b/Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab new file mode 100644 index 0000000..4589faa --- /dev/null +++ b/Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab @@ -0,0 +1,151 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1690754592808301335 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1690754592808301329} + - component: {fileID: 1690754592808301328} + - component: {fileID: 1690754592808301330} + - component: {fileID: 1690754592808301331} + - component: {fileID: 1690754592808301340} + m_Layer: 0 + m_Name: FadingPlatform + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1690754592808301329 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1690754592808301335} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.3932476, y: -1.2323916, z: 0.087166585} + m_LocalScale: {x: 3.1765, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &1690754592808301328 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1690754592808301335} + 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: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + 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: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 507ed95ba551c4e4a87d9e447a976222, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &1690754592808301330 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1690754592808301335} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!68 &1690754592808301331 +EdgeCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1690754592808301335} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0.53} + m_EdgeRadius: 0 + m_Points: + - {x: -0.5, y: 0} + - {x: 0.5, y: 0} + m_AdjacentStartPoint: {x: 0, y: 0} + m_AdjacentEndPoint: {x: 0, y: 0} + m_UseAdjacentStartPoint: 0 + m_UseAdjacentEndPoint: 0 +--- !u!114 &1690754592808301340 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1690754592808301335} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 06a513c030dd05c408207938c16e432d, type: 3} + m_Name: + m_EditorClassIdentifier: + fadeTime: 2 + refractoryTime: 1.5 diff --git a/Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab.meta b/Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab.meta new file mode 100644 index 0000000..3d59592 --- /dev/null +++ b/Assets/AssetsFORELLE/Prefabs/FadingPlatform.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b689b743b78fab64ba927428b8f042ac +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/AssetsFORELLE/Prefabs/MovPlatParent.prefab b/Assets/AssetsFORELLE/Prefabs/MovingPlatform.prefab similarity index 99% rename from Assets/AssetsFORELLE/Prefabs/MovPlatParent.prefab rename to Assets/AssetsFORELLE/Prefabs/MovingPlatform.prefab index 046b7c8..fb739ad 100644 --- a/Assets/AssetsFORELLE/Prefabs/MovPlatParent.prefab +++ b/Assets/AssetsFORELLE/Prefabs/MovingPlatform.prefab @@ -224,7 +224,7 @@ GameObject: m_Component: - component: {fileID: 6215011085779547658} m_Layer: 0 - m_Name: MovPlatParent + m_Name: MovingPlatform m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/AssetsFORELLE/Prefabs/MovPlatParent.prefab.meta b/Assets/AssetsFORELLE/Prefabs/MovingPlatform.prefab.meta similarity index 100% rename from Assets/AssetsFORELLE/Prefabs/MovPlatParent.prefab.meta rename to Assets/AssetsFORELLE/Prefabs/MovingPlatform.prefab.meta diff --git a/Assets/AssetsFORELLE/Script/FadingPlatform.cs b/Assets/AssetsFORELLE/Script/FadingPlatform.cs new file mode 100644 index 0000000..2b1cb77 --- /dev/null +++ b/Assets/AssetsFORELLE/Script/FadingPlatform.cs @@ -0,0 +1,57 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FadingPlatform : MonoBehaviour +{ + +private SpriteRenderer spriteRenderer; +private BoxCollider2D col; +private EdgeCollider2D edge; +public float fadeTime; +public float refractoryTime; +private bool gone; + + + void Start() + { + spriteRenderer = GetComponent(); + col = GetComponent(); + edge = GetComponent(); + gone = false; + } + + void Update() + { + if(gone) + { + StartCoroutine(Switch()); + } + } + + void OnTriggerEnter2D(Collider2D edge) { + if(!gone){ + StartCoroutine(Switch()); + } + } + + // Muss IEnumerator sein weil ich ansonsten den Timer nicht implementieren kann + IEnumerator Switch(){ + + if(gone) + { + yield return new WaitForSeconds (refractoryTime); + spriteRenderer.enabled = true; + col.enabled = true; + edge.enabled = true; + gone = false; + } else { + yield return new WaitForSeconds (fadeTime); + spriteRenderer.enabled = false; + col.enabled = false; + edge.enabled = false; + gone = true; + } + } + +} diff --git a/Assets/AssetsFORELLE/Script/FadingPlatform.cs.meta b/Assets/AssetsFORELLE/Script/FadingPlatform.cs.meta new file mode 100644 index 0000000..5bf9987 --- /dev/null +++ b/Assets/AssetsFORELLE/Script/FadingPlatform.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 06a513c030dd05c408207938c16e432d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 3f974b6..57f6613 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -596,7 +596,7 @@ CapsuleCollider2D: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 792973161} - m_Enabled: 0 + m_Enabled: 1 m_Density: 1 m_Material: {fileID: 6200000, guid: 9a162dcdc92b4194ba53630f8785bed1, type: 2} m_IsTrigger: 0 @@ -635,117 +635,11 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: inFirstDim: 1 ---- !u!1 &921148899 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 921148901} - - component: {fileID: 921148900} - - component: {fileID: 921148902} - m_Layer: 0 - m_Name: Platform - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!212 &921148900 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 921148899} - 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: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} - 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: 0 - m_Sprite: {fileID: 7482667652216324306, guid: 507ed95ba551c4e4a87d9e447a976222, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!4 &921148901 +--- !u!4 &921148901 stripped Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + m_PrefabInstance: {fileID: 1690754593104162548} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 921148899} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.3932476, y: -1.2323916, z: 0.087166585} - m_LocalScale: {x: 3.1765, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1561360181} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!61 &921148902 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 921148899} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 1, y: 1} - newSize: {x: 1, y: 1} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 1, y: 1} - m_EdgeRadius: 0 --- !u!1 &942496083 GameObject: m_ObjectHideFlags: 0 @@ -868,7 +762,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1609963722} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.62, y: 0.71, z: 0} + m_LocalPosition: {x: -3.71, y: 0.76, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -935,7 +829,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1802940291} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -5.63, y: 0.7699999, z: 0.087166585} + m_LocalPosition: {x: -7.13, y: 0.82, z: 0.087166585} m_LocalScale: {x: 3.1764998, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1170,3 +1064,60 @@ BoxCollider2D: serializedVersion: 2 m_Size: {x: 1, y: 1} m_EdgeRadius: 0 +--- !u!1001 &1690754593104162548 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1561360181} + m_Modifications: + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalPosition.x + value: -0.3932476 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalPosition.y + value: -1.2323916 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalPosition.z + value: 0.087166585 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301329, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1690754592808301335, guid: b689b743b78fab64ba927428b8f042ac, type: 3} + propertyPath: m_Name + value: FadingPlatform + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: b689b743b78fab64ba927428b8f042ac, type: 3}