From 140cbd646f309c89b27fc5ed4e4e90eb6fac91b7 Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Wed, 2 Apr 2025 07:55:08 +0100 Subject: [PATCH] iT DONTY WORK KDJMGHDFSJHFG --- Assets/Prefabs/Portal.prefab | 74 ++++++++- Assets/Scenes/SampleScene.unity | 18 ++- Assets/Scripts/Portals/PortalCamera.cs | 9 +- Assets/Scripts/Portals/PortalManager.cs | 26 +++- ProjectSettings/ProjectSettings.asset | 191 +++++++++++++++++++++++- 5 files changed, 297 insertions(+), 21 deletions(-) diff --git a/Assets/Prefabs/Portal.prefab b/Assets/Prefabs/Portal.prefab index 22628ca..c3724a4 100644 --- a/Assets/Prefabs/Portal.prefab +++ b/Assets/Prefabs/Portal.prefab @@ -47,7 +47,9 @@ MonoBehaviour: m_OtherPortal: {fileID: 0} m_CameraPrefab: {fileID: 1179287573507601862, guid: 1a28b9e152b1d3d419d1881ea498fcbf, type: 3} m_PortalRenderer: {fileID: 4162196787169641245} - m_CapturePoint: {fileID: 7913558143758367436} + m_PlayerPoint: {fileID: 6158405577604730568} + m_Pos: {fileID: 8037706452414992202} + m_Rot: {fileID: 7913558143758367436} --- !u!1 &1109503274534853756 GameObject: m_ObjectHideFlags: 0 @@ -58,7 +60,7 @@ GameObject: m_Component: - component: {fileID: 7913558143758367436} m_Layer: 0 - m_Name: CapturePoint + m_Name: Rot m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -72,8 +74,40 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1109503274534853756} serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.20281735, y: 3.2786098, z: 13.835168} + 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: 8037706452414992202} + m_Father: {fileID: 3117384245817137028} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2957412639318883996 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6158405577604730568} + m_Layer: 0 + m_Name: PlayerPos + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6158405577604730568 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2957412639318883996} + serializedVersion: 2 + 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: [] @@ -162,6 +196,37 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &4970227605924577730 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8037706452414992202} + m_Layer: 0 + m_Name: Pos + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8037706452414992202 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4970227605924577730} + serializedVersion: 2 + 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: 7913558143758367436} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &5834152528747782185 GameObject: m_ObjectHideFlags: 0 @@ -194,5 +259,6 @@ Transform: - {fileID: 6525768614182165007} - {fileID: 2772991262862259612} - {fileID: 7913558143758367436} + - {fileID: 6158405577604730568} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 5fbaf7d..fe2adcf 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -348,7 +348,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalPosition.y - value: 10 + value: 10.000004 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalPosition.z @@ -356,7 +356,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.w - value: 1 + value: 0.7071068 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.x @@ -364,7 +364,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0.7071068 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.z @@ -376,7 +376,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalEulerAnglesHint.y - value: 0 + value: -90 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalEulerAnglesHint.z @@ -390,6 +390,10 @@ PrefabInstance: propertyPath: m_Name value: Portal objectReference: {fileID: 0} + - target: {fileID: 8672533918032425654, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} + propertyPath: m_LocalPosition.z + value: 10 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -6525,7 +6529,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.w - value: 0.7071068 + value: 1 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.x @@ -6533,7 +6537,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.y - value: 0.7071068 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalRotation.z @@ -6545,7 +6549,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalEulerAnglesHint.y - value: 90 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3117384245817137028, guid: c41b43046138ded45bddaab8e10d4cf0, type: 3} propertyPath: m_LocalEulerAnglesHint.z diff --git a/Assets/Scripts/Portals/PortalCamera.cs b/Assets/Scripts/Portals/PortalCamera.cs index 8b5aad2..846b237 100644 --- a/Assets/Scripts/Portals/PortalCamera.cs +++ b/Assets/Scripts/Portals/PortalCamera.cs @@ -8,7 +8,7 @@ public class PortalCamera : MonoBehaviour // Private members // - PortalManager m_DisplayPortal; + public PortalManager m_DisplayPortal; PortalManager m_CapturePortal; RenderTexture m_RenderTexture; @@ -43,8 +43,9 @@ public class PortalCamera : MonoBehaviour // Update is called every frame void Update() { - // Calculates the player distance from where the portal will be rendererd - Vector3 offset = CameraController.Instance().transform.position - m_DisplayPortal.pos; - transform.parent.position = m_CapturePortal.TranslateOffset(offset); + Vector3 offset = m_CapturePortal.PlayerOffset(); + transform.parent.position = offset; + + transform.parent.position = m_CapturePortal.TranslateOffsetToSpace(m_DisplayPortal.PlayerOffset(), Vector3.zero); } } diff --git a/Assets/Scripts/Portals/PortalManager.cs b/Assets/Scripts/Portals/PortalManager.cs index f7086ed..64ff987 100644 --- a/Assets/Scripts/Portals/PortalManager.cs +++ b/Assets/Scripts/Portals/PortalManager.cs @@ -1,4 +1,3 @@ -using System.ComponentModel; using UnityEngine; public class PortalManager : MonoBehaviour @@ -9,7 +8,11 @@ public class PortalManager : MonoBehaviour [Header("Set References")] [SerializeField] GameObject m_CameraPrefab; [SerializeField] MeshRenderer m_PortalRenderer; - [SerializeField] Transform m_CapturePoint; + + [Header("Points")] + [SerializeField] Transform m_PlayerPoint; + [SerializeField] Transform m_Pos; + [SerializeField] Transform m_Rot; PortalManager m_OtherManager; PortalCamera m_PortalCamera; @@ -19,6 +22,10 @@ public class PortalManager : MonoBehaviour public Vector3 pos => transform.parent.position; public Quaternion rot => transform.parent.rotation; + public void SetPos(Vector3 v) => transform.parent.position = v; + + public Vector3 PlayerOffset() => m_PlayerPoint.position; + // Start is called before the first frame update void Start() { @@ -37,9 +44,18 @@ public class PortalManager : MonoBehaviour // Initialises the camera so it renders to the portal and not the screen m_PortalCamera.InitCamera(m_PortalRenderer, this); } - public Vector3 TranslateOffset(Vector3 offset) + + // Updates is called every frame + void Update() { - m_CapturePoint.localPosition = offset; - return m_CapturePoint.position; + m_PlayerPoint.position = CameraController.Instance().transform.position; + } + + public Vector3 TranslateOffsetToSpace(Vector3 pos, Vector3 euler) + { + m_Rot.localEulerAngles = euler; + m_Pos.localPosition = pos; + + return m_Pos.position; } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 39aa7db..3e856ae 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -283,7 +283,196 @@ PlayerSettings: AndroidValidateAppBundleSize: 1 AndroidAppBundleSizeToValidate: 150 m_BuildTargetIcons: [] - m_BuildTargetPlatformIcons: [] + m_BuildTargetPlatformIcons: + - m_BuildTarget: iPhone + m_Icons: + - m_Textures: [] + m_Width: 180 + m_Height: 180 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 167 + m_Height: 167 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 152 + m_Height: 152 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 76 + m_Height: 76 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 87 + m_Height: 87 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 60 + m_Height: 60 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 20 + m_Height: 20 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 1024 + m_Height: 1024 + m_Kind: 4 + m_SubKind: App Store + - m_BuildTarget: Android + m_Icons: + - m_Textures: [] + m_Width: 432 + m_Height: 432 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 324 + m_Height: 324 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 216 + m_Height: 216 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 162 + m_Height: 162 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 108 + m_Height: 108 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 81 + m_Height: 81 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 0 + m_SubKind: m_BuildTargetBatching: - m_BuildTarget: Standalone m_StaticBatching: 1