カメラサイズの調整機能を追加
This commit is contained in:
		
							parent
							
								
									7b5005d674
								
							
						
					
					
						commit
						4bfb03fcff
					
				|  | @ -1823,6 +1823,7 @@ GameObject: | |||
|   - component: {fileID: 536970159} | ||||
|   - component: {fileID: 536970158} | ||||
|   - component: {fileID: 536970161} | ||||
|   - component: {fileID: 536970162} | ||||
|   m_Layer: 0 | ||||
|   m_Name: Main Camera | ||||
|   m_TagString: MainCamera | ||||
|  | @ -1911,6 +1912,18 @@ MonoBehaviour: | |||
|     serializedVersion: 2 | ||||
|     m_Bits: 23 | ||||
|   m_MaxRayIntersections: 0 | ||||
| --- !u!114 &536970162 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 536970157} | ||||
|   m_Enabled: 1 | ||||
|   m_EditorHideFlags: 0 | ||||
|   m_Script: {fileID: 11500000, guid: c11194ed6fd84a1f812fa2cfae75f873, type: 3} | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
| --- !u!114 &556316131 stripped | ||||
| MonoBehaviour: | ||||
|   m_CorrespondingSourceObject: {fileID: 3767471200807653374, guid: 0949d70c1a73342ca8955c7f59c04fe0, | ||||
|  |  | |||
|  | @ -3591,6 +3591,7 @@ MonoBehaviour: | |||
|   m_Script: {fileID: 11500000, guid: 9b3b578c8a46648248e58adb3ee9caba, type: 3} | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
|   refreshRewardCoin: 100 | ||||
|   cookingButton: {fileID: 414580708} | ||||
|   adButton: {fileID: 445566315} | ||||
|   kitchenView: {fileID: 1870432536} | ||||
|  | @ -4011,6 +4012,7 @@ GameObject: | |||
|   - component: {fileID: 2055584754} | ||||
|   - component: {fileID: 2055584753} | ||||
|   - component: {fileID: 2055584756} | ||||
|   - component: {fileID: 2055584757} | ||||
|   m_Layer: 0 | ||||
|   m_Name: Main Camera | ||||
|   m_TagString: MainCamera | ||||
|  | @ -4099,6 +4101,18 @@ MonoBehaviour: | |||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_MaxRayIntersections: 0 | ||||
| --- !u!114 &2055584757 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 2055584752} | ||||
|   m_Enabled: 1 | ||||
|   m_EditorHideFlags: 0 | ||||
|   m_Script: {fileID: 11500000, guid: c11194ed6fd84a1f812fa2cfae75f873, type: 3} | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
| --- !u!1 &2082561917 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|  | @ -4657,6 +4671,11 @@ PrefabInstance: | |||
|       propertyPath: m_IsActive | ||||
|       value: 1 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8103176713869808018, guid: caaa748dbeed576499e8cae74d33f689, | ||||
|         type: 3} | ||||
|       propertyPath: m_RootOrder | ||||
|       value: 9 | ||||
|       objectReference: {fileID: 0} | ||||
|     m_RemovedComponents: [] | ||||
|   m_SourcePrefab: {fileID: 100100000, guid: caaa748dbeed576499e8cae74d33f689, type: 3} | ||||
| --- !u!224 &3664916832445709978 stripped | ||||
|  |  | |||
|  | @ -0,0 +1,39 @@ | |||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
| using UnityEngine.SceneManagement; | ||||
| 
 | ||||
| namespace MyGame.Scripts | ||||
| { | ||||
|     [RequireComponent(typeof(Camera))] | ||||
|     public class CameraSizeChanger : MonoBehaviour | ||||
|     { | ||||
|         private float originalAspect = 1334f / 750; | ||||
| 
 | ||||
|         private void Start() | ||||
|         { | ||||
|             if ((float)Screen.height / Screen.width <= originalAspect) | ||||
|             { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|             if (!Enum.TryParse<GameScenes>(SceneManager.GetActiveScene().name, out var scene)) | ||||
|             { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             var camera = GetComponent<Camera>(); | ||||
|             switch (scene) | ||||
|             { | ||||
|                 case GameScenes.CornField: | ||||
|                     camera.orthographicSize = 13.6f; | ||||
|                     break; | ||||
|                 case GameScenes.Main: | ||||
|                     camera.orthographicSize = 14f; | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,3 @@ | |||
| fileFormatVersion: 2 | ||||
| guid: c11194ed6fd84a1f812fa2cfae75f873 | ||||
| timeCreated: 1634826188 | ||||
		Loading…
	
		Reference in New Issue