├── .gitignore ├── Demo.meta ├── Demo ├── Materials.meta ├── Materials │ ├── AimingObject.mat │ ├── AimingObject.mat.meta │ ├── Character.mat │ ├── Character.mat.meta │ ├── Ground.mat │ └── Ground.mat.meta ├── Scenes.meta ├── Scenes │ ├── Demo.meta │ ├── Demo.unity │ ├── Demo.unity.meta │ └── Demo │ │ ├── LightingData.asset │ │ ├── LightingData.asset.meta │ │ ├── ReflectionProbe-0.exr │ │ └── ReflectionProbe-0.exr.meta ├── Scripts.meta ├── Scripts │ ├── CameraAndInputDemo.cs │ └── CameraAndInputDemo.cs.meta ├── Textures.meta └── Textures │ ├── flatDark00.png │ ├── flatDark00.png.meta │ ├── flatDark06.png │ ├── flatDark06.png.meta │ ├── flatDark10.png │ ├── flatDark10.png.meta │ ├── flatDark20.png │ ├── flatDark20.png.meta │ ├── flatDark21.png │ ├── flatDark21.png.meta │ ├── flatDark33.png │ ├── flatDark33.png.meta │ ├── flatDark34.png │ ├── flatDark34.png.meta │ ├── flatDark35.png │ ├── flatDark35.png.meta │ ├── flatDark36.png │ └── flatDark36.png.meta ├── LICENSE ├── README.md ├── Scripts.meta └── Scripts ├── Camera.meta ├── Camera ├── FollowCamera.cs ├── FollowCamera.cs.meta ├── FollowCameraControls.cs ├── FollowCameraControls.cs.meta ├── IAimAssistAvoidanceListener.cs ├── IAimAssistAvoidanceListener.cs.meta ├── ResponsiveCamera.cs └── ResponsiveCamera.cs.meta ├── CameraAndInput.asmdef ├── CameraAndInput.asmdef.meta ├── Input.meta └── Input ├── BaseMobileInputButton.cs ├── BaseMobileInputButton.cs.meta ├── BaseMobileInputToggle.cs ├── BaseMobileInputToggle.cs.meta ├── IMobileInputArea.cs ├── IMobileInputArea.cs.meta ├── InputManager.cs ├── InputManager.cs.meta ├── InputSettingManager.cs ├── InputSettingManager.cs.meta ├── KeyConvertUtils.cs ├── KeyConvertUtils.cs.meta ├── MobileInputArea.cs ├── MobileInputArea.cs.meta ├── MobileInputButton.cs ├── MobileInputButton.cs.meta ├── MobileInputButtonByKeyCode.cs ├── MobileInputButtonByKeyCode.cs.meta ├── MobileInputConfig.cs ├── MobileInputConfig.cs.meta ├── MobileInputConfigManager.cs ├── MobileInputConfigManager.cs.meta ├── MobileInputToggle.cs ├── MobileInputToggle.cs.meta ├── MobileInputToggleAxis.cs ├── MobileInputToggleAxis.cs.meta ├── MobileInputToggleByKeyCode.cs ├── MobileInputToggleByKeyCode.cs.meta ├── MobileMovementJoystick.cs ├── MobileMovementJoystick.cs.meta ├── MobilePinchArea.cs ├── MobilePinchArea.cs.meta ├── MobileSwipeAndPinchArea.cs ├── MobileSwipeAndPinchArea.cs.meta ├── MobileSwipeArea.cs └── MobileSwipeArea.cs.meta /.gitignore: -------------------------------------------------------------------------------- 1 | README.md.meta 2 | LICENSE.meta 3 | -------------------------------------------------------------------------------- /Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25d489557c4696547958955f45c6874b 3 | folderAsset: yes 4 | timeCreated: 1495893010 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Demo/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2991d0cccc515c944ade96215d13fc76 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Materials/AimingObject.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-2856433688656900517 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 7 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 8 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: AimingObject 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_Parent: {fileID: 0} 26 | m_ModifiedSerializedProperties: 0 27 | m_ValidKeywords: [] 28 | m_InvalidKeywords: [] 29 | m_LightmapFlags: 4 30 | m_EnableInstancingVariants: 0 31 | m_DoubleSidedGI: 0 32 | m_CustomRenderQueue: -1 33 | stringTagMap: 34 | RenderType: Opaque 35 | disabledShaderPasses: [] 36 | m_LockedProperties: 37 | m_SavedProperties: 38 | serializedVersion: 3 39 | m_TexEnvs: 40 | - _BaseMap: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _BumpMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _DetailAlbedoMap: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _DetailMask: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _DetailNormalMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | - _EmissionMap: 61 | m_Texture: {fileID: 0} 62 | m_Scale: {x: 1, y: 1} 63 | m_Offset: {x: 0, y: 0} 64 | - _MainTex: 65 | m_Texture: {fileID: 0} 66 | m_Scale: {x: 1, y: 1} 67 | m_Offset: {x: 0, y: 0} 68 | - _MetallicGlossMap: 69 | m_Texture: {fileID: 0} 70 | m_Scale: {x: 1, y: 1} 71 | m_Offset: {x: 0, y: 0} 72 | - _OcclusionMap: 73 | m_Texture: {fileID: 0} 74 | m_Scale: {x: 1, y: 1} 75 | m_Offset: {x: 0, y: 0} 76 | - _ParallaxMap: 77 | m_Texture: {fileID: 0} 78 | m_Scale: {x: 1, y: 1} 79 | m_Offset: {x: 0, y: 0} 80 | - _SpecGlossMap: 81 | m_Texture: {fileID: 0} 82 | m_Scale: {x: 1, y: 1} 83 | m_Offset: {x: 0, y: 0} 84 | - unity_Lightmaps: 85 | m_Texture: {fileID: 0} 86 | m_Scale: {x: 1, y: 1} 87 | m_Offset: {x: 0, y: 0} 88 | - unity_LightmapsInd: 89 | m_Texture: {fileID: 0} 90 | m_Scale: {x: 1, y: 1} 91 | m_Offset: {x: 0, y: 0} 92 | - unity_ShadowMasks: 93 | m_Texture: {fileID: 0} 94 | m_Scale: {x: 1, y: 1} 95 | m_Offset: {x: 0, y: 0} 96 | m_Ints: [] 97 | m_Floats: 98 | - _AlphaClip: 0 99 | - _AlphaToMask: 0 100 | - _Blend: 0 101 | - _BlendModePreserveSpecular: 1 102 | - _BumpScale: 1 103 | - _ClearCoatMask: 0 104 | - _ClearCoatSmoothness: 0 105 | - _Cull: 2 106 | - _Cutoff: 0.5 107 | - _DetailAlbedoMapScale: 1 108 | - _DetailNormalMapScale: 1 109 | - _DstBlend: 0 110 | - _DstBlendAlpha: 0 111 | - _EnvironmentReflections: 1 112 | - _GlossMapScale: 1 113 | - _Glossiness: 0.5 114 | - _GlossyReflections: 1 115 | - _Metallic: 0 116 | - _Mode: 0 117 | - _OcclusionStrength: 1 118 | - _Parallax: 0.02 119 | - _QueueOffset: 0 120 | - _ReceiveShadows: 1 121 | - _Smoothness: 0.5 122 | - _SmoothnessTextureChannel: 0 123 | - _SpecularHighlights: 1 124 | - _SrcBlend: 1 125 | - _SrcBlendAlpha: 1 126 | - _Surface: 0 127 | - _UVSec: 0 128 | - _WorkflowMode: 1 129 | - _ZWrite: 1 130 | m_Colors: 131 | - _BaseColor: {r: 0.5019608, g: 0, b: 0, a: 1} 132 | - _Color: {r: 1, g: 1, b: 1, a: 1} 133 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 134 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 135 | m_BuildTextureStacks: [] 136 | -------------------------------------------------------------------------------- /Demo/Materials/AimingObject.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8b75fc8933224449bc0b279ae50a50b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Materials/Character.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Character 11 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 12 | m_Parent: {fileID: 0} 13 | m_ModifiedSerializedProperties: 0 14 | m_ValidKeywords: [] 15 | m_InvalidKeywords: [] 16 | m_LightmapFlags: 4 17 | m_EnableInstancingVariants: 0 18 | m_DoubleSidedGI: 0 19 | m_CustomRenderQueue: -1 20 | stringTagMap: 21 | RenderType: Opaque 22 | disabledShaderPasses: [] 23 | m_LockedProperties: 24 | m_SavedProperties: 25 | serializedVersion: 3 26 | m_TexEnvs: 27 | - _BaseMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _BumpMap: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _DetailAlbedoMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _DetailMask: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _DetailNormalMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _EmissionMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _MainTex: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _MetallicGlossMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _OcclusionMap: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _ParallaxMap: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _SpecGlossMap: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - unity_Lightmaps: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - unity_LightmapsInd: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - unity_ShadowMasks: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | m_Ints: [] 84 | m_Floats: 85 | - _AlphaClip: 0 86 | - _AlphaToMask: 0 87 | - _Blend: 0 88 | - _BlendModePreserveSpecular: 1 89 | - _BumpScale: 1 90 | - _ClearCoatMask: 0 91 | - _ClearCoatSmoothness: 0 92 | - _Cull: 2 93 | - _Cutoff: 0.5 94 | - _DetailAlbedoMapScale: 1 95 | - _DetailNormalMapScale: 1 96 | - _DstBlend: 0 97 | - _DstBlendAlpha: 0 98 | - _EnvironmentReflections: 1 99 | - _GlossMapScale: 1 100 | - _Glossiness: 0.5 101 | - _GlossyReflections: 1 102 | - _Metallic: 0 103 | - _Mode: 0 104 | - _OcclusionStrength: 1 105 | - _Parallax: 0.02 106 | - _QueueOffset: 0 107 | - _ReceiveShadows: 1 108 | - _Smoothness: 0.5 109 | - _SmoothnessTextureChannel: 0 110 | - _SpecularHighlights: 1 111 | - _SrcBlend: 1 112 | - _SrcBlendAlpha: 1 113 | - _Surface: 0 114 | - _UVSec: 0 115 | - _WorkflowMode: 1 116 | - _ZWrite: 1 117 | m_Colors: 118 | - _BaseColor: {r: 0, g: 0, b: 0.5019608, a: 1} 119 | - _Color: {r: 1, g: 1, b: 1, a: 1} 120 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 121 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 122 | m_BuildTextureStacks: [] 123 | --- !u!114 &1544207067904897426 124 | MonoBehaviour: 125 | m_ObjectHideFlags: 11 126 | m_CorrespondingSourceObject: {fileID: 0} 127 | m_PrefabInstance: {fileID: 0} 128 | m_PrefabAsset: {fileID: 0} 129 | m_GameObject: {fileID: 0} 130 | m_Enabled: 1 131 | m_EditorHideFlags: 0 132 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 133 | m_Name: 134 | m_EditorClassIdentifier: 135 | version: 7 136 | -------------------------------------------------------------------------------- /Demo/Materials/Character.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65d89df57d98f3e4584f53f14df112e9 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Materials/Ground.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 8 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Ground 11 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 12 | m_Parent: {fileID: 0} 13 | m_ModifiedSerializedProperties: 0 14 | m_ValidKeywords: [] 15 | m_InvalidKeywords: [] 16 | m_LightmapFlags: 4 17 | m_EnableInstancingVariants: 0 18 | m_DoubleSidedGI: 0 19 | m_CustomRenderQueue: -1 20 | stringTagMap: 21 | RenderType: Opaque 22 | disabledShaderPasses: [] 23 | m_LockedProperties: 24 | m_SavedProperties: 25 | serializedVersion: 3 26 | m_TexEnvs: 27 | - _BaseMap: 28 | m_Texture: {fileID: 10309, guid: 0000000000000000f000000000000000, type: 0} 29 | m_Scale: {x: 10, y: 10} 30 | m_Offset: {x: 0, y: 0} 31 | - _BumpMap: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _DetailAlbedoMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 0.1, y: 0.1} 38 | m_Offset: {x: 0, y: 0} 39 | - _DetailMask: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _DetailNormalMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _EmissionMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 10, y: 10} 50 | m_Offset: {x: 0, y: 0} 51 | - _MainTex: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _MetallicGlossMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _OcclusionMap: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _ParallaxMap: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _SpecGlossMap: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - unity_Lightmaps: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - unity_LightmapsInd: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - unity_ShadowMasks: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | m_Ints: [] 84 | m_Floats: 85 | - _AlphaClip: 0 86 | - _AlphaToMask: 0 87 | - _Blend: 0 88 | - _BlendModePreserveSpecular: 1 89 | - _BumpScale: 1 90 | - _ClearCoatMask: 0 91 | - _ClearCoatSmoothness: 0 92 | - _Cull: 2 93 | - _Cutoff: 0.5 94 | - _DetailAlbedoMapScale: 1 95 | - _DetailNormalMapScale: 1 96 | - _DstBlend: 0 97 | - _DstBlendAlpha: 0 98 | - _EnvironmentReflections: 1 99 | - _GlossMapScale: 1 100 | - _Glossiness: 0.5 101 | - _GlossyReflections: 1 102 | - _Metallic: 0 103 | - _Mode: 0 104 | - _OcclusionStrength: 1 105 | - _Parallax: 0.02 106 | - _QueueOffset: 0 107 | - _ReceiveShadows: 1 108 | - _Smoothness: 0.5 109 | - _SmoothnessTextureChannel: 0 110 | - _SpecularHighlights: 1 111 | - _SrcBlend: 1 112 | - _SrcBlendAlpha: 1 113 | - _Surface: 0 114 | - _UVSec: 0 115 | - _WorkflowMode: 1 116 | - _ZWrite: 1 117 | m_Colors: 118 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 119 | - _Color: {r: 1, g: 1, b: 1, a: 1} 120 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 121 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 122 | m_BuildTextureStacks: [] 123 | --- !u!114 &8300723689069136311 124 | MonoBehaviour: 125 | m_ObjectHideFlags: 11 126 | m_CorrespondingSourceObject: {fileID: 0} 127 | m_PrefabInstance: {fileID: 0} 128 | m_PrefabAsset: {fileID: 0} 129 | m_GameObject: {fileID: 0} 130 | m_Enabled: 1 131 | m_EditorHideFlags: 0 132 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 133 | m_Name: 134 | m_EditorClassIdentifier: 135 | version: 7 136 | -------------------------------------------------------------------------------- /Demo/Materials/Ground.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb8d31cd5bed57548859acbe5046b9da 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a787159e1dec90c4085c34ba8033ccfc 3 | folderAsset: yes 4 | timeCreated: 1495893426 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Demo/Scenes/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6dd3b0340a41364780278d8c591f903 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Scenes/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7af9a17b170fdc4aa15e5fb384a04dd 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Demo/Scenes/Demo/LightingData.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Scenes/Demo/LightingData.asset -------------------------------------------------------------------------------- /Demo/Scenes/Demo/LightingData.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8def3c6b16ebeb94d8a2ca136c324cb7 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Scenes/Demo/ReflectionProbe-0.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Scenes/Demo/ReflectionProbe-0.exr -------------------------------------------------------------------------------- /Demo/Scenes/Demo/ReflectionProbe-0.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 706e1e3744d68ce46a2216790fbb50b3 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 1 29 | seamlessCubemap: 1 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 2 35 | aniso: 0 36 | mipBias: 0 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 2 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 100 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Demo/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44bf2a8c510c58748aff56136bb2c4e0 3 | folderAsset: yes 4 | timeCreated: 1495893336 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Demo/Scripts/CameraAndInputDemo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Insthync.CameraAndInput.Demo 4 | { 5 | public class CameraAndInputDemo : MonoBehaviour 6 | { 7 | public CharacterController character; 8 | public Camera controlleringCamera; 9 | public float moveSpeed = 5f; 10 | // Start is called before the first frame update 11 | void Start() 12 | { 13 | InputManager.UseMobileInputOnNonMobile = true; 14 | } 15 | 16 | // Update is called once per frame 17 | void Update() 18 | { 19 | var inputV = InputManager.GetAxis("Vertical", false); 20 | var inputH = InputManager.GetAxis("Horizontal", false); 21 | var moveDirection = Vector3.zero; 22 | moveDirection += controlleringCamera.transform.forward * inputV; 23 | moveDirection += controlleringCamera.transform.right * inputH; 24 | character.SimpleMove(moveDirection * moveSpeed * 1000f * Time.deltaTime); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Demo/Scripts/CameraAndInputDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5104f95cba9331c4887c0ac9871b962a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Demo/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e31f8ede7c6423e4c982247493973d21 3 | folderAsset: yes 4 | timeCreated: 1495893269 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark00.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark00.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb76f9f27cc97e54683f15358dcc7e72 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark06.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark06.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 721c9d6d41957f64bba25ec4425604cc 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark10.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark10.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e145a2671c8230a4592a2b33036eb8f1 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark20.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark20.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e9168ce73cd23c4da9cceeb0e7aaedb 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark21.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark21.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd6220c07c1b1ed43b9a6f505b8748e9 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark33.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark33.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4824c4eec2f38c642b45377ef898fb37 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark34.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark34.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8de5ee7104b8b4e4bb55881b179685e4 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark35.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark35.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 084e4401110ce1d489a3f63db2d3ec91 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /Demo/Textures/flatDark36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insthync/unity-camera-and-input/efb6bc82e4df16ebd98381eecad7eca7372a5c13/Demo/Textures/flatDark36.png -------------------------------------------------------------------------------- /Demo/Textures/flatDark36.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fab27ecbdaa2eca478a24875042d021b 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 0 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 2048 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: WebGL 100 | maxTextureSize: 2048 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | spriteSheet: 111 | serializedVersion: 2 112 | sprites: [] 113 | outline: [] 114 | physicsShape: [] 115 | bones: [] 116 | spriteID: 5e97eb03825dee720800000000000000 117 | internalID: 0 118 | vertices: [] 119 | indices: 120 | edges: [] 121 | weights: [] 122 | secondaryTextures: [] 123 | spritePackingTag: 124 | pSDRemoveMatte: 0 125 | pSDShowRemoveMatteOption: 0 126 | userData: 127 | assetBundleName: 128 | assetBundleVariant: 129 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ittipon Teerapruettikulchai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unity-camera-and-input 2 | 3 | A collection of camera controller and input wrapper scripts 4 | 5 | ## Camera controller 6 | - `FollowCamera` is a component which will move camera which set to `Camera` setting to follow target which set to `Target` setting. 7 | - `FollowCameraControls` is a component which extending from `FollowCamera` to manage rotating and zooming. 8 | 9 | * * * 10 | 11 | ## Input wrapper scripts 12 | 13 | ### How it work? 14 | 15 | It has `InputManager` which is wrapper for mobile's on-screen joysticks to make it able to write the same input codes for mobile games and PC (or Mac or Linux). 16 | 17 | You will have to change input codes: 18 | - `UnityEngine.Input.GetButton(name)` to `InputManager.GetButton(name)` 19 | - `UnityEngine.Input.GetButtonDown(name)` to `InputManager.GetButtonDown(name)` 20 | - `UnityEngine.Input.GetButtonUp(name)` to `InputManager.GetButtonUp(name)` 21 | - `UnityEngine.Input.GetAxisRaw(name)` to `InputManager.GetAxis(name, true)` 22 | - `UnityEngine.Input.GetAxis(name)` to `InputManager.GetAxis(name, false)` 23 | 24 | ### Change input settings in `InputSettingManager` component instead of Unity's input manager 25 | You can set input settings in `InputSettingManager` by add the component to empty game object, you should add it in init scene, then set input settings as you wish. 26 | I think it's a lot more convenient to set input settings in `InputSettingManager` component, if you don't want to use it, you still can use Unity's input manager. 27 | 28 | ### Wrapper prority 29 | Read on-screen input -> Read input setting from `InputSettingManager` -> Read input setting from Unity's input manager. 30 | 31 | ### How to test mobile on-screen joysticks in editor? 32 | To test mobile's on-screen joysticks while running in editor, you have to set `InputManager` -> `useMobileInputOnNonMobile` to `TRUE` 33 | 34 | ### Rewired wrapper 35 | This project is also has [Rewired](https://guavaman.com/projects/rewired/) integration, if you have it and also want to use it, you have to add `USE_REWIRED` to scripting define symbols setting. 36 | 37 | * * * 38 | -------------------------------------------------------------------------------- /Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da08b92c207155a46ab0cb1cf6fb6988 3 | folderAsset: yes 4 | timeCreated: 1506024866 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Camera.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 482b6980b0728824f8fc50edf3d5bd0f 3 | folderAsset: yes 4 | timeCreated: 1505779337 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Camera/FollowCamera.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace Insthync.CameraAndInput 5 | { 6 | [ExecuteInEditMode] 7 | [DefaultExecutionOrder(int.MinValue)] 8 | public class FollowCamera : MonoBehaviour 9 | { 10 | public Camera targetCamera; 11 | public Transform target; 12 | public Vector3 targetOffset; 13 | [Header("Follow smoothness")] 14 | public bool smoothFollow; 15 | public float followSmoothing = 10.0f; 16 | [Header("Rotation")] 17 | public float xRotation; 18 | public float yRotation; 19 | [Tooltip("If this is TRUE, will update Y-rotation follow target")] 20 | public bool useTargetYRotation; 21 | [Header("Zoom")] 22 | public float zoomDistance = 10.0f; 23 | [Header("Zoom by ratio")] 24 | public bool zoomByAspectRatio; 25 | public List zoomByAspectRatioSettings = new List() 26 | { 27 | new ZoomByAspectRatioSetting() { width = 16, height = 9, zoomDistance = 0.0001f }, 28 | new ZoomByAspectRatioSetting() { width = 16, height = 10, zoomDistance = 1.75f }, 29 | new ZoomByAspectRatioSetting() { width = 3, height = 2, zoomDistance = 3f }, 30 | new ZoomByAspectRatioSetting() { width = 4, height = 3, zoomDistance = 5.5f }, 31 | new ZoomByAspectRatioSetting() { width = 5, height = 4, zoomDistance = 7 }, 32 | }; 33 | [Header("Wall hit spring")] 34 | public bool enableWallHitSpring; 35 | public float minDistanceToPerformWallHitSpring = 1f; 36 | public float wallHitSpringPushForwardDistance = 0.5f; 37 | public float wallHitSpringRadius = 0.5f; 38 | public LayerMask wallHitLayerMask = -1; 39 | public QueryTriggerInteraction wallHitQueryTriggerInteraction = QueryTriggerInteraction.Ignore; 40 | 41 | // Properties 42 | public Transform CacheCameraTransform { get; private set; } 43 | 44 | public Camera CacheCamera 45 | { 46 | get { return targetCamera; } 47 | } 48 | 49 | private GameObject _targetFollower; 50 | public Vector3 _targetPosition; 51 | public Vector3 _targetUp; 52 | public float _targetYRotation = 0f; 53 | // Being used in Update and DrawGizmos functions 54 | private Ray _tempRay; 55 | private float _tempDistance; 56 | private Vector3 _debugFrom; 57 | private Vector3 _debugTo; 58 | 59 | protected virtual void OnDrawGizmos() 60 | { 61 | #if UNITY_EDITOR 62 | Gizmos.color = Color.red; 63 | Gizmos.DrawLine(_debugFrom, _debugTo); 64 | #endif 65 | } 66 | 67 | protected virtual void Awake() 68 | { 69 | PrepareComponents(); 70 | } 71 | 72 | private void PrepareComponents() 73 | { 74 | if (targetCamera == null) 75 | targetCamera = GetComponent(); 76 | CacheCameraTransform = CacheCamera.transform; 77 | if (_targetFollower == null && Application.isPlaying) 78 | _targetFollower = new GameObject("_CameraTargetFollower"); 79 | } 80 | 81 | private void OnDestroy() 82 | { 83 | if (_targetFollower != null) 84 | Destroy(_targetFollower); 85 | } 86 | 87 | protected virtual void LateUpdate() 88 | { 89 | if (Application.isPlaying) 90 | { 91 | if (target != null) 92 | { 93 | if (!smoothFollow) 94 | { 95 | _targetFollower.transform.position = target.transform.position; 96 | _targetFollower.transform.eulerAngles = target.transform.eulerAngles; 97 | } 98 | else 99 | { 100 | _targetFollower.transform.position = Vector3.Lerp(_targetFollower.transform.position, target.transform.position, followSmoothing * Time.deltaTime); 101 | _targetFollower.transform.eulerAngles = target.transform.eulerAngles; 102 | } 103 | _targetPosition = _targetFollower.transform.position; 104 | _targetUp = _targetFollower.transform.up; 105 | _targetYRotation = _targetFollower.transform.eulerAngles.y; 106 | } 107 | } 108 | else 109 | { 110 | #if UNITY_EDITOR 111 | PrepareComponents(); 112 | if (target == null) 113 | { 114 | _targetPosition = Vector3.zero; 115 | _targetUp = Vector3.up; 116 | _targetYRotation = 0f; 117 | } 118 | else 119 | { 120 | _targetPosition = target.position; 121 | _targetUp = target.up; 122 | _targetYRotation = target.eulerAngles.y; 123 | } 124 | #endif 125 | } 126 | 127 | // Update target position by offsets 128 | _targetPosition += (targetOffset.x * CacheCameraTransform.right) + (targetOffset.y * _targetUp) + (targetOffset.z * CacheCameraTransform.forward); 129 | 130 | if (zoomByAspectRatio) 131 | { 132 | float windowAspect = CacheCamera.aspect; 133 | zoomByAspectRatioSettings.Sort(); 134 | foreach (ZoomByAspectRatioSetting data in zoomByAspectRatioSettings) 135 | { 136 | if (windowAspect + windowAspect * 0.025f > data.Aspect() && 137 | windowAspect - windowAspect * 0.025f < data.Aspect()) 138 | { 139 | zoomDistance = data.zoomDistance; 140 | break; 141 | } 142 | } 143 | } 144 | 145 | if (zoomDistance == 0f) 146 | zoomDistance = 0.0001f; 147 | 148 | if (CacheCamera.orthographic) 149 | CacheCamera.orthographicSize = zoomDistance; 150 | 151 | float wantedYRotation = useTargetYRotation ? _targetYRotation : yRotation; 152 | 153 | // Convert the angle into a rotation 154 | Quaternion wantedRotation = Quaternion.Euler(xRotation, wantedYRotation, 0); 155 | 156 | // Set the position of the camera on the x-z plane to: 157 | // distance meters behind the target 158 | Vector3 wantedPosition = _targetPosition - (wantedRotation * Vector3.forward * zoomDistance); 159 | 160 | if (enableWallHitSpring) 161 | { 162 | float nearest = float.MaxValue; 163 | // Direction from the target to the camera 164 | Vector3 directionToCamera = wantedRotation * -Vector3.forward; 165 | _tempRay = new Ray(_targetPosition, directionToCamera); 166 | _tempDistance = Vector3.Distance(_targetPosition, wantedPosition); 167 | RaycastHit[] hits = Physics.SphereCastAll(_tempRay, wallHitSpringRadius, _tempDistance, wallHitLayerMask, wallHitQueryTriggerInteraction); 168 | foreach (var hit in hits) 169 | { 170 | if (hit.distance < minDistanceToPerformWallHitSpring || hit.distance >= nearest) 171 | continue; 172 | nearest = hit.distance; 173 | Vector3 collisionPointWithOffset = _tempRay.origin + (directionToCamera.normalized * (hit.distance - wallHitSpringPushForwardDistance)); 174 | if (Vector3.Distance(_targetPosition, collisionPointWithOffset) < _tempDistance) 175 | { 176 | wantedPosition = collisionPointWithOffset; 177 | } 178 | } 179 | } 180 | 181 | // Update position & rotation 182 | CacheCameraTransform.position = wantedPosition; 183 | CacheCameraTransform.rotation = wantedRotation; 184 | 185 | _debugFrom = _targetPosition; 186 | _debugTo = wantedPosition; 187 | } 188 | 189 | [System.Serializable] 190 | public struct ZoomByAspectRatioSetting : System.IComparable 191 | { 192 | public int width; 193 | public int height; 194 | public float zoomDistance; 195 | 196 | public float Aspect() 197 | { 198 | return (float)width / (float)height; 199 | } 200 | 201 | public int CompareTo(object obj) 202 | { 203 | if (!(obj is ZoomByAspectRatioSetting)) 204 | return 0; 205 | return Aspect().CompareTo(((ZoomByAspectRatioSetting)obj).Aspect()); 206 | } 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /Scripts/Camera/FollowCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f728177e7e400947abc4db638db136d 3 | timeCreated: 1495912274 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Camera/FollowCameraControls.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.Serialization; 4 | 5 | namespace Insthync.CameraAndInput 6 | { 7 | [ExecuteInEditMode] 8 | [DefaultExecutionOrder(int.MinValue)] 9 | public class FollowCameraControls : FollowCamera 10 | { 11 | [Header("Controls")] 12 | public string xRotationAxisName = "Mouse Y"; 13 | public string yRotationAxisName = "Mouse X"; 14 | public string zoomAxisName = "Mouse ScrollWheel"; 15 | public bool updateRotation = true; 16 | public bool updateRotationX = false; 17 | public bool updateRotationY = false; 18 | public bool updateZoom = true; 19 | 20 | [Header("X Rotation")] 21 | public bool limitXRotation; 22 | [Range(-360, 360)] 23 | public float minXRotation = 0; 24 | [Range(-360, 360)] 25 | public float maxXRotation = 0; 26 | public bool smoothRotateX; 27 | [FormerlySerializedAs("rotateXSmoothing")] 28 | public float rotateXDeacceleration = 10.0f; 29 | 30 | [Header("Y Rotation")] 31 | public bool limitYRotation; 32 | [Range(-360, 360)] 33 | public float minYRotation = 0; 34 | [Range(-360, 360)] 35 | public float maxYRotation = 0; 36 | public bool smoothRotateY; 37 | [FormerlySerializedAs("rotateYSmoothing")] 38 | public float rotateYDeacceleration = 10.0f; 39 | 40 | [Header("General Rotation Settings")] 41 | public float startXRotation; 42 | public float startYRotation; 43 | public float rotationSpeed = 5; 44 | [Range(0.1f, 1f)] 45 | public float rotationSpeedScale = 1; 46 | 47 | [Header("Zoom")] 48 | public bool limitZoomDistance; 49 | public float minZoomDistance; 50 | public float maxZoomDistance; 51 | public bool smoothZoom; 52 | [FormerlySerializedAs("zoomSmoothing")] 53 | public float zoomDeacceleration = 10.0f; 54 | 55 | [Header("General Zoom Settings")] 56 | public float startZoomDistance; 57 | public float zoomSpeed = 0.05f; 58 | [Range(0.1f, 1f)] 59 | public float zoomSpeedScale = 1; 60 | 61 | [Header("Aim Assist")] 62 | public bool enableAimAssist = false; 63 | public bool enableAimAssistX = true; 64 | public bool enableAimAssistY = true; 65 | public float aimAssistRadius = 0.5f; 66 | public float aimAssistMinDistanceFromFollowingTarget = 3f; 67 | public float aimAssistDistance = 10f; 68 | [Tooltip("Set both target layers and obstacle layers, it will be used in `SphereCastAll` function")] 69 | public LayerMask aimAssistLayerMask; 70 | [Tooltip("Set only obstacle layers, it will be used to check hitting object layer is an obstacle or not. If it is, it won't perform aim assisting")] 71 | public LayerMask aimAssistObstacleLayerMask = Physics.DefaultRaycastLayers; 72 | public float aimAssistXSpeed = 10f; 73 | public float aimAssistYSpeed = 10f; 74 | [Range(0f, 360f)] 75 | [FormerlySerializedAs("aimAssistAngleLessThan")] 76 | public float aimAssistMaxAngleFromFollowingTarget = 360f; 77 | 78 | [Header("Recoil")] 79 | public float recoilReturnSpeed = 2f; 80 | public float recoilSmoothing = 6f; 81 | 82 | [Header("Save Camera")] 83 | public bool isSaveCamera; 84 | public string savePrefsPrefix = "GAMEPLAY"; 85 | 86 | public IAimAssistAvoidanceListener AimAssistAvoidanceListener { get; set; } 87 | public float XRotationVelocity { get; set; } 88 | public float YRotationVelocity { get; set; } 89 | public float ZoomVelocity { get; set; } 90 | 91 | private Vector3 _targetRecoilRotation; 92 | private Vector3 _currentRecoilRotation; 93 | // Being used in Update and DrawGizmos functions 94 | private RaycastHit _aimAssistCastHit; 95 | 96 | private void Start() 97 | { 98 | xRotation = startXRotation; 99 | yRotation = startYRotation; 100 | zoomDistance = startZoomDistance; 101 | 102 | if (isSaveCamera) 103 | { 104 | xRotation = PlayerPrefs.GetFloat(savePrefsPrefix + "_XRotation", xRotation); 105 | yRotation = PlayerPrefs.GetFloat(savePrefsPrefix + "_YRotation", yRotation); 106 | zoomDistance = PlayerPrefs.GetFloat(savePrefsPrefix + "_ZoomDistance", zoomDistance); 107 | } 108 | } 109 | 110 | private void Update() 111 | { 112 | float deltaTime = Time.deltaTime; 113 | 114 | if (isSaveCamera) 115 | { 116 | PlayerPrefs.SetFloat(savePrefsPrefix + "_XRotation", xRotation); 117 | PlayerPrefs.SetFloat(savePrefsPrefix + "_YRotation", yRotation); 118 | PlayerPrefs.SetFloat(savePrefsPrefix + "_ZoomDistance", zoomDistance); 119 | PlayerPrefs.Save(); 120 | } 121 | 122 | // X rotation 123 | if (updateRotation || updateRotationX) 124 | XRotationVelocity += InputManager.GetAxis(xRotationAxisName, false) * rotationSpeed * rotationSpeedScale; 125 | xRotation -= XRotationVelocity; 126 | 127 | if (limitXRotation) 128 | xRotation = ClampAngleBetweenMinAndMax(xRotation, minXRotation, maxXRotation); 129 | else 130 | xRotation = ClampAngleBetweenMinAndMax(xRotation, -360, 360); 131 | 132 | // Y rotation 133 | if (updateRotation || updateRotationY) 134 | YRotationVelocity += InputManager.GetAxis(yRotationAxisName, false) * rotationSpeed * rotationSpeedScale; 135 | yRotation += YRotationVelocity; 136 | 137 | if (limitYRotation) 138 | yRotation = ClampAngleBetweenMinAndMax(yRotation, minYRotation, maxYRotation); 139 | else 140 | yRotation = ClampAngleBetweenMinAndMax(yRotation, -360, 360); 141 | 142 | // Zoom 143 | if (updateZoom) 144 | ZoomVelocity += InputManager.GetAxis(zoomAxisName, false) * zoomSpeed * zoomSpeedScale; 145 | zoomDistance += ZoomVelocity; 146 | if (limitZoomDistance) 147 | { 148 | if (zoomDistance < minZoomDistance) 149 | { 150 | ZoomVelocity = 0f; 151 | zoomDistance = minZoomDistance; 152 | } 153 | if (zoomDistance > maxZoomDistance) 154 | { 155 | ZoomVelocity = 0f; 156 | zoomDistance = maxZoomDistance; 157 | } 158 | } 159 | 160 | // X rotation smooth 161 | if (smoothRotateX) 162 | XRotationVelocity = Mathf.LerpAngle(XRotationVelocity, 0, deltaTime * rotateXDeacceleration); 163 | else 164 | XRotationVelocity = 0f; 165 | 166 | // Y rotation smooth 167 | if (smoothRotateY) 168 | YRotationVelocity = Mathf.LerpAngle(YRotationVelocity, 0, deltaTime * rotateYDeacceleration); 169 | else 170 | YRotationVelocity = 0f; 171 | 172 | // Zoom smooth 173 | if (smoothZoom) 174 | ZoomVelocity = Mathf.Lerp(ZoomVelocity, 0, deltaTime * zoomDeacceleration); 175 | else 176 | ZoomVelocity = 0f; 177 | } 178 | 179 | public void Recoil(float x, float y, float z) 180 | { 181 | _targetRecoilRotation += new Vector3(x, y, z); 182 | } 183 | 184 | protected override void LateUpdate() 185 | { 186 | float deltaTime = Time.deltaTime; 187 | UpdateAimAssist(deltaTime); 188 | base.LateUpdate(); 189 | 190 | // Update recoiling 191 | _targetRecoilRotation = Vector3.Lerp(_targetRecoilRotation, Vector3.zero, deltaTime * recoilReturnSpeed); 192 | _currentRecoilRotation = Vector3.Lerp(_currentRecoilRotation, _targetRecoilRotation, Time.fixedDeltaTime * recoilSmoothing); 193 | CacheCameraTransform.eulerAngles += _currentRecoilRotation; 194 | } 195 | 196 | protected void UpdateAimAssist(float deltaTime) 197 | { 198 | if (!enableAimAssist || !Application.isPlaying) 199 | return; 200 | RaycastHit[] hits = Physics.SphereCastAll(CacheCameraTransform.position, aimAssistRadius, CacheCameraTransform.forward, aimAssistDistance, aimAssistLayerMask); 201 | System.Array.Sort(hits, 0, hits.Length, new RaycastHitComparer()); 202 | RaycastHit tempHit; 203 | RaycastHit? hitTarget = null; 204 | Vector3 cameraDir = CacheCameraTransform.forward; 205 | Vector3 targetDir; 206 | for (int i = 0; i < hits.Length; ++i) 207 | { 208 | tempHit = hits[i]; 209 | if (aimAssistObstacleLayerMask.value == (aimAssistObstacleLayerMask.value | (1 << tempHit.transform.gameObject.layer))) 210 | return; 211 | if (AimAssistAvoidanceListener != null && AimAssistAvoidanceListener.AvoidAimAssist(tempHit)) 212 | continue; 213 | if (Vector3.Distance(target.position, tempHit.point) <= aimAssistMinDistanceFromFollowingTarget) 214 | continue; 215 | targetDir = (tempHit.point - target.position).normalized; 216 | if (Vector3.Angle(cameraDir, targetDir) > aimAssistMaxAngleFromFollowingTarget) 217 | continue; 218 | hitTarget = tempHit; 219 | break; 220 | } 221 | if (!hitTarget.HasValue) 222 | return; 223 | // Set `xRotation`, `yRotation` by hit object's position 224 | _aimAssistCastHit = hitTarget.Value; 225 | Vector3 targetCenter = _aimAssistCastHit.collider.bounds.center; 226 | Vector3 directionToTarget = (targetCenter - CacheCameraTransform.position).normalized; 227 | Quaternion lookRotation = Quaternion.LookRotation(directionToTarget); 228 | if (enableAimAssistX) 229 | xRotation = Mathf.MoveTowardsAngle(xRotation, lookRotation.eulerAngles.x, aimAssistXSpeed * deltaTime); 230 | if (enableAimAssistY) 231 | yRotation = Mathf.MoveTowardsAngle(yRotation, lookRotation.eulerAngles.y, aimAssistYSpeed * deltaTime); 232 | } 233 | 234 | protected override void OnDrawGizmos() 235 | { 236 | base.OnDrawGizmos(); 237 | #if UNITY_EDITOR 238 | Gizmos.color = Color.green; 239 | Gizmos.DrawLine(CacheCameraTransform.position, CacheCameraTransform.position + CacheCameraTransform.forward * _aimAssistCastHit.distance); 240 | Gizmos.DrawWireSphere(CacheCameraTransform.position + CacheCameraTransform.forward * _aimAssistCastHit.distance, aimAssistRadius); 241 | #endif 242 | } 243 | 244 | private float ClampAngleBetweenMinAndMax(float angle, float min, float max) 245 | { 246 | if (angle < -360) 247 | angle += 360; 248 | if (angle > 360) 249 | angle -= 360; 250 | return Mathf.Clamp(angle, min, max); 251 | } 252 | 253 | /// 254 | /// Sort ASC by distance from origin to impact point 255 | /// 256 | public struct RaycastHitComparer : IComparer 257 | { 258 | public int Compare(RaycastHit x, RaycastHit y) 259 | { 260 | return x.distance.CompareTo(y.distance); 261 | } 262 | } 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /Scripts/Camera/FollowCameraControls.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34e5f4512b7c9e94a80ec394fd3a8441 3 | timeCreated: 1495918771 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Camera/IAimAssistAvoidanceListener.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Insthync.CameraAndInput 4 | { 5 | public interface IAimAssistAvoidanceListener 6 | { 7 | bool AvoidAimAssist(RaycastHit hitInfo); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Scripts/Camera/IAimAssistAvoidanceListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19f72d32eb9c63e43acb18b4e745b405 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Camera/ResponsiveCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Insthync.CameraAndInput 4 | { 5 | [ExecuteInEditMode] 6 | [RequireComponent(typeof(Camera))] 7 | public class ResponsiveCamera : MonoBehaviour 8 | { 9 | private Camera tempCamera; 10 | public Camera TempCamera 11 | { 12 | get 13 | { 14 | if (tempCamera == null) 15 | tempCamera = GetComponent(); 16 | return tempCamera; 17 | } 18 | } 19 | 20 | public float targetWidth; 21 | public float targetHeight; 22 | 23 | private void LateUpdate() 24 | { 25 | // set the desired aspect ratio (the values in this example are 26 | // hard-coded for 16:9, but you could make them into public 27 | // variables instead so you can set them at design time) 28 | float targetaspect = targetWidth / targetHeight; 29 | 30 | // determine the game window's current aspect ratio 31 | float windowaspect = (float)Screen.width / (float)Screen.height; 32 | 33 | // current viewport height should be scaled by this amount 34 | float scaleheight = windowaspect / targetaspect; 35 | 36 | // if scaled height is less than current height, add letterbox 37 | if (scaleheight < 1.0f) 38 | { 39 | Rect rect = TempCamera.rect; 40 | 41 | rect.width = 1.0f; 42 | rect.height = scaleheight; 43 | 44 | rect.x = 0; 45 | rect.y = (1.0f - scaleheight) / 2.0f; 46 | 47 | TempCamera.rect = rect; 48 | } 49 | else // add pillarbox 50 | { 51 | float scalewidth = 1.0f / scaleheight; 52 | 53 | Rect rect = TempCamera.rect; 54 | 55 | rect.width = scalewidth; 56 | rect.height = 1.0f; 57 | 58 | rect.x = (1.0f - scalewidth) / 2.0f; 59 | rect.y = 0; 60 | 61 | TempCamera.rect = rect; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Scripts/Camera/ResponsiveCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bfa1777b6c08bf4998d5ba1e7d0624a 3 | timeCreated: 1511472923 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Scripts/CameraAndInput.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CameraAndInput", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:75469ad4d38634e559750d17036d5f7c" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Scripts/CameraAndInput.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b1bd08bb8a7f5a4a973f58725d04606 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/Input.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcb7d433f0b36ae4bb5dee8cb3856ed0 3 | folderAsset: yes 4 | timeCreated: 1505779337 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Input/BaseMobileInputButton.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | using UnityEngine.Events; 4 | using UnityEngine.EventSystems; 5 | 6 | namespace Insthync.CameraAndInput 7 | { 8 | public abstract class BaseMobileInputButton : MonoBehaviour, IMobileInputArea, IPointerDownHandler, IPointerUpHandler 9 | { 10 | [Range(0f, 1f)] 11 | public float alphaWhileIdling = 1f; 12 | [Range(0f, 1f)] 13 | public float alphaWhilePressing = 0.75f; 14 | public bool interactable = true; 15 | 16 | [Header("Events")] 17 | public UnityEvent onPointerDown = new UnityEvent(); 18 | public UnityEvent onPointerUp = new UnityEvent(); 19 | 20 | public bool Interactable 21 | { 22 | get { return interactable; } 23 | set { interactable = value; } 24 | } 25 | 26 | private CanvasGroup _canvasGroup; 27 | private MobileInputConfig _config; 28 | private float _alphaMultiplier = 1f; 29 | private PointerEventData _previousPointer; 30 | 31 | private void Start() 32 | { 33 | _canvasGroup = GetComponent(); 34 | if (_canvasGroup == null) 35 | { 36 | _canvasGroup = gameObject.AddComponent(); 37 | _canvasGroup.alpha = alphaWhileIdling * _alphaMultiplier; 38 | } 39 | _config = GetComponent(); 40 | if (_config != null) 41 | { 42 | // Updating default canvas group alpha when loading new config 43 | _config.onLoadAlpha += OnLoadAlpha; 44 | } 45 | } 46 | 47 | private void OnDestroy() 48 | { 49 | if (_config != null) 50 | _config.onLoadAlpha -= OnLoadAlpha; 51 | } 52 | 53 | private void OnDisable() 54 | { 55 | OnPointerUp(null); 56 | } 57 | 58 | public void OnPointerDown(PointerEventData eventData) 59 | { 60 | if (!Interactable) 61 | return; 62 | if (_previousPointer != null) 63 | return; 64 | _previousPointer = eventData; 65 | InputManager.touchedPointerIds[eventData.pointerId] = gameObject; 66 | OnButtonDown(); 67 | onPointerDown.Invoke(); 68 | SetPressedState(); 69 | } 70 | 71 | public void OnPointerUp(PointerEventData eventData) 72 | { 73 | if (_previousPointer != null && eventData != null && _previousPointer.pointerId != eventData.pointerId) 74 | return; 75 | if (_previousPointer != null) 76 | InputManager.touchedPointerIds.Remove(_previousPointer.pointerId); 77 | _previousPointer = null; 78 | if (eventData != null) 79 | { 80 | OnButtonUp(); 81 | onPointerUp.Invoke(); 82 | } 83 | SetIdleState(); 84 | } 85 | 86 | private void SetIdleState() 87 | { 88 | if (_canvasGroup) 89 | _canvasGroup.alpha = alphaWhileIdling * _alphaMultiplier; 90 | } 91 | 92 | private void SetPressedState() 93 | { 94 | if (_canvasGroup) 95 | _canvasGroup.alpha = alphaWhilePressing * _alphaMultiplier; 96 | } 97 | 98 | public void OnLoadAlpha(float alpha) 99 | { 100 | _alphaMultiplier = alpha; 101 | } 102 | 103 | public void SimulateClick() 104 | { 105 | StartCoroutine(SimulateClickRoutine()); 106 | } 107 | 108 | private IEnumerator SimulateClickRoutine() 109 | { 110 | OnPointerDown(default); 111 | yield return null; 112 | OnPointerUp(default); 113 | } 114 | 115 | protected abstract void OnButtonDown(); 116 | protected abstract void OnButtonUp(); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Scripts/Input/BaseMobileInputButton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ff70828ae40e734da1d29fbe04090fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Input/BaseMobileInputToggle.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using UnityEngine.EventSystems; 4 | using UnityEngine.UI; 5 | 6 | namespace Insthync.CameraAndInput 7 | { 8 | public abstract class BaseMobileInputToggle : MonoBehaviour, IMobileInputArea, IPointerDownHandler, IPointerUpHandler 9 | { 10 | [System.Serializable] 11 | public class BoolEvent : UnityEvent { } 12 | 13 | [System.Serializable] 14 | public class ToggleColorSetting 15 | { 16 | public Graphic targetGraphic; 17 | public Color colorWhileToggled = Color.white; 18 | public Color colorWhileUntoggled = Color.white; 19 | } 20 | 21 | [Range(0f, 1f)] 22 | public float alphaWhileOff = 0.75f; 23 | [Range(0f, 1f)] 24 | public float alphaWhileOn = 1f; 25 | public ToggleColorSetting[] toggleColorSettings = new ToggleColorSetting[0]; 26 | public BoolEvent onToggle = new BoolEvent(); 27 | [SerializeField] 28 | private bool isOn = false; 29 | 30 | private bool _dirtyIsOn = false; 31 | public bool IsOn 32 | { 33 | get { return isOn; } 34 | set 35 | { 36 | isOn = value; 37 | if (_dirtyIsOn != value) 38 | { 39 | _dirtyIsOn = value; 40 | UpdateGraphics(); 41 | OnToggle(value); 42 | if (onToggle != null) 43 | onToggle.Invoke(value); 44 | } 45 | } 46 | } 47 | 48 | private CanvasGroup _canvasGroup; 49 | private MobileInputConfig _config; 50 | private float _alphaMultiplier = 1f; 51 | 52 | protected virtual void Start() 53 | { 54 | _dirtyIsOn = IsOn; 55 | _canvasGroup = GetComponent(); 56 | if (_canvasGroup == null) 57 | _canvasGroup = gameObject.AddComponent(); 58 | UpdateGraphics(); 59 | _config = GetComponent(); 60 | if (_config != null) 61 | { 62 | // Updating default canvas group alpha when loading new config 63 | _config.onLoadAlpha += OnLoadAlpha; 64 | } 65 | } 66 | 67 | protected virtual void OnDestroy() 68 | { 69 | if (_config != null) 70 | _config.onLoadAlpha -= OnLoadAlpha; 71 | } 72 | 73 | public void SetIsOnWithoutNotify(bool value) 74 | { 75 | isOn = value; 76 | if (_dirtyIsOn != value) 77 | { 78 | _dirtyIsOn = value; 79 | UpdateGraphics(); 80 | } 81 | } 82 | 83 | private float GetAlphaByCurrentState() 84 | { 85 | return IsOn ? alphaWhileOn : alphaWhileOff; 86 | } 87 | 88 | private void UpdateGraphics() 89 | { 90 | if (_canvasGroup != null) 91 | _canvasGroup.alpha = GetAlphaByCurrentState() * _alphaMultiplier; 92 | for (int i = 0; i < toggleColorSettings.Length; ++i) 93 | { 94 | toggleColorSettings[i].targetGraphic.color = IsOn ? toggleColorSettings[i].colorWhileToggled : toggleColorSettings[i].colorWhileUntoggled; 95 | } 96 | } 97 | 98 | public void OnPointerDown(PointerEventData eventData) 99 | { 100 | IsOn = !IsOn; 101 | } 102 | 103 | public void OnPointerUp(PointerEventData eventData) 104 | { 105 | // TODO: May have setting to toggle when pointer up 106 | } 107 | 108 | public void OnLoadAlpha(float alpha) 109 | { 110 | _alphaMultiplier = alpha; 111 | } 112 | 113 | protected abstract void OnToggle(bool isOn); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Scripts/Input/BaseMobileInputToggle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d867b254df5899e40ac659a5c040d3c9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Input/IMobileInputArea.cs: -------------------------------------------------------------------------------- 1 | namespace Insthync.CameraAndInput 2 | { 3 | /// 4 | /// Just a empty interface for pointer over game object detection 5 | /// 6 | public interface IMobileInputArea 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Scripts/Input/IMobileInputArea.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f75b12f117ac004d9186e4897405756 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Input/InputManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | #if ENABLE_INPUT_SYSTEM 4 | using UnityEngine.InputSystem; 5 | using UnityEngine.InputSystem.Controls; 6 | #endif 7 | 8 | namespace Insthync.CameraAndInput 9 | { 10 | public static class InputManager 11 | { 12 | private static Dictionary simulateInputs = new Dictionary(); 13 | private static Dictionary simulateKeys = new Dictionary(); 14 | private static Dictionary simulateAxis = new Dictionary(); 15 | private static bool s_useMobileInputOnNonMobile = false; 16 | public static bool UseMobileInputOnNonMobile 17 | { 18 | get 19 | { 20 | return s_useMobileInputOnNonMobile; 21 | } 22 | set 23 | { 24 | s_useMobileInputOnNonMobile = value; 25 | } 26 | } 27 | private static bool s_useNonMobileInput = false; 28 | public static bool UseNonMobileInput 29 | { 30 | get 31 | { 32 | return s_useNonMobileInput; 33 | } 34 | set 35 | { 36 | s_useNonMobileInput = value; 37 | } 38 | } 39 | internal static readonly Dictionary touchedPointerIds = new Dictionary(); 40 | 41 | private static int mobileInputLastDragFrame = 0; 42 | public static bool IsDraggingMobileInput 43 | { 44 | get 45 | { 46 | return Time.frameCount - mobileInputLastDragFrame <= 1; 47 | } 48 | } 49 | 50 | #if ENABLE_INPUT_SYSTEM 51 | private static HashSet alreadyFindInputActionNames = new HashSet(); 52 | private static Dictionary foundInputActions = new Dictionary(); 53 | #endif 54 | 55 | 56 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] 57 | public static void Initialize() 58 | { 59 | simulateInputs.Clear(); 60 | simulateKeys.Clear(); 61 | simulateAxis.Clear(); 62 | s_useMobileInputOnNonMobile = false; 63 | s_useNonMobileInput = false; 64 | touchedPointerIds.Clear(); 65 | mobileInputLastDragFrame = 0; 66 | #if ENABLE_INPUT_SYSTEM 67 | alreadyFindInputActionNames.Clear(); 68 | foundInputActions.Clear(); 69 | #endif 70 | } 71 | 72 | public static void UpdateMobileInputDragging() 73 | { 74 | mobileInputLastDragFrame = Time.frameCount; 75 | } 76 | 77 | public static bool HasInputSetting(string keyName) 78 | { 79 | return !string.IsNullOrEmpty(keyName) && InputSettingManager.Singleton != null && InputSettingManager.Singleton.Settings.ContainsKey(keyName); 80 | } 81 | 82 | public static bool IsUseMobileInput() 83 | { 84 | #if VR_BUILD 85 | return false; 86 | #else 87 | return Application.isMobilePlatform || UseMobileInputOnNonMobile; 88 | #endif 89 | } 90 | 91 | public static bool IsUseNonMobileInput() 92 | { 93 | #if VR_BUILD 94 | return true; 95 | #else 96 | return !Application.isMobilePlatform && (!UseMobileInputOnNonMobile || UseNonMobileInput); 97 | #endif 98 | } 99 | 100 | #if ENABLE_INPUT_SYSTEM 101 | public static bool TryGetInputAction(string name, out InputAction inputAction) 102 | { 103 | if (!alreadyFindInputActionNames.Contains(name)) 104 | { 105 | alreadyFindInputActionNames.Add(name); 106 | if (InputSettingManager.Singleton != null && InputSettingManager.Singleton.inputActionAsset != null) 107 | { 108 | inputAction = InputSettingManager.Singleton.inputActionAsset.FindAction(name); 109 | if (inputAction != null) 110 | { 111 | inputAction.Enable(); 112 | foundInputActions.Add(name, inputAction); 113 | return true; 114 | } 115 | } 116 | } 117 | else if (foundInputActions.TryGetValue(name, out inputAction)) 118 | { 119 | return true; 120 | } 121 | inputAction = null; 122 | return false; 123 | } 124 | #endif 125 | 126 | #if USE_REWIRED 127 | public static float GetAxis(string name, bool raw, int playerId = 0) 128 | #else 129 | public static float GetAxis(string name, bool raw) 130 | #endif 131 | { 132 | // Try get input by rewired system 133 | if (IsUseNonMobileInput()) 134 | { 135 | #if USE_REWIRED 136 | try 137 | { 138 | Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerId); 139 | float axis = raw ? player.GetAxisRaw(name) : player.GetAxis(name); 140 | if (Mathf.Abs(axis) > 0.00001f) 141 | return axis; 142 | } 143 | catch { } 144 | #endif 145 | 146 | #if ENABLE_INPUT_SYSTEM 147 | if (TryGetInputAction(name, out InputAction inputAction)) 148 | { 149 | float axis = inputAction.ReadValue(); 150 | if (raw) 151 | { 152 | if (axis > 0f) 153 | axis = 1f; 154 | if (axis < 0f) 155 | axis = -1f; 156 | } 157 | if (Mathf.Abs(axis) > 0.00001f) 158 | return axis; 159 | } 160 | #endif 161 | 162 | #if ENABLE_LEGACY_INPUT_MANAGER 163 | try 164 | { 165 | float axis = raw ? Input.GetAxisRaw(name) : Input.GetAxis(name); 166 | if (Mathf.Abs(axis) > 0.00001f) 167 | return axis; 168 | } 169 | catch { } 170 | #endif 171 | } 172 | 173 | if (IsUseMobileInput()) 174 | { 175 | SimulateAxis foundSimulateAxis; 176 | float axis = 0f; 177 | if (simulateAxis.TryGetValue(name, out foundSimulateAxis)) 178 | axis = foundSimulateAxis.Value; 179 | if (raw) 180 | { 181 | if (axis > 0f) 182 | axis = 1f; 183 | if (axis < 0f) 184 | axis = -1f; 185 | } 186 | return axis; 187 | } 188 | return 0f; 189 | } 190 | 191 | public static bool GetKey(KeyCode key) 192 | { 193 | if (IsUseNonMobileInput()) 194 | { 195 | #if ENABLE_INPUT_SYSTEM 196 | if (key.TryGetMouseButtonControl(out ButtonControl buttonControl) && buttonControl.isPressed) 197 | return true; 198 | if (key.TryGetKeyboardKeyControl(out KeyControl keyControl) && keyControl.isPressed) 199 | return true; 200 | #endif 201 | 202 | #if ENABLE_LEGACY_INPUT_MANAGER 203 | try 204 | { 205 | if (Input.GetKey(key)) 206 | return true; 207 | } 208 | catch { } 209 | #endif 210 | } 211 | 212 | if (IsUseMobileInput()) 213 | { 214 | SimulateButton foundSimulateButton; 215 | if (simulateKeys.TryGetValue(key, out foundSimulateButton) && foundSimulateButton.Pressed) 216 | return true; 217 | } 218 | return false; 219 | } 220 | 221 | public static bool GetKeyDown(KeyCode key) 222 | { 223 | if (IsUseNonMobileInput()) 224 | { 225 | #if ENABLE_INPUT_SYSTEM 226 | if (key.TryGetMouseButtonControl(out ButtonControl buttonControl) && buttonControl.wasPressedThisFrame) 227 | return true; 228 | if (key.TryGetKeyboardKeyControl(out KeyControl keyControl) && keyControl.wasPressedThisFrame) 229 | return true; 230 | #endif 231 | 232 | #if ENABLE_LEGACY_INPUT_MANAGER 233 | try 234 | { 235 | if (Input.GetKeyDown(key)) 236 | return true; 237 | } 238 | catch { } 239 | #endif 240 | } 241 | 242 | if (IsUseMobileInput()) 243 | { 244 | SimulateButton foundSimulateButton; 245 | if (simulateKeys.TryGetValue(key, out foundSimulateButton) && foundSimulateButton.ButtonDown) 246 | return true; 247 | } 248 | return false; 249 | } 250 | 251 | public static bool GetKeyUp(KeyCode key) 252 | { 253 | if (IsUseNonMobileInput()) 254 | { 255 | #if ENABLE_INPUT_SYSTEM 256 | if (key.TryGetMouseButtonControl(out ButtonControl buttonControl) && buttonControl.wasReleasedThisFrame) 257 | return true; 258 | if (key.TryGetKeyboardKeyControl(out KeyControl keyControl) && keyControl.wasReleasedThisFrame) 259 | return true; 260 | #endif 261 | 262 | #if ENABLE_LEGACY_INPUT_MANAGER 263 | try 264 | { 265 | if (Input.GetKeyUp(key)) 266 | return true; 267 | } 268 | catch { } 269 | #endif 270 | } 271 | 272 | if (IsUseMobileInput()) 273 | { 274 | SimulateButton foundSimulateButton; 275 | if (simulateKeys.TryGetValue(key, out foundSimulateButton) && foundSimulateButton.ButtonUp) 276 | return true; 277 | } 278 | return false; 279 | } 280 | 281 | private static bool IsKeyFromSettingActivated(string name, System.Func func) 282 | { 283 | if (HasInputSetting(name)) 284 | { 285 | List keyCodes = InputSettingManager.Singleton.Settings[name]; 286 | foreach (KeyCode keyCode in keyCodes) 287 | { 288 | if (func.Invoke(keyCode)) 289 | return true; 290 | } 291 | } 292 | return false; 293 | } 294 | 295 | #if USE_REWIRED 296 | public static bool GetButton(string name, int playerId = 0) 297 | #else 298 | public static bool GetButton(string name) 299 | #endif 300 | { 301 | if (string.IsNullOrEmpty(name)) 302 | return false; 303 | 304 | if (IsUseNonMobileInput()) 305 | { 306 | // Try get input by rewired system 307 | #if USE_REWIRED 308 | try 309 | { 310 | Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerId); 311 | if (player.GetButton(name)) 312 | return true; 313 | } 314 | catch { } 315 | #endif 316 | 317 | #if ENABLE_INPUT_SYSTEM 318 | if (TryGetInputAction(name, out InputAction inputAction)) 319 | { 320 | if (inputAction.IsPressed()) 321 | return true; 322 | } 323 | #endif 324 | 325 | #if ENABLE_LEGACY_INPUT_MANAGER 326 | try 327 | { 328 | if (Input.GetButton(name)) 329 | return true; 330 | } 331 | catch { } 332 | if (IsKeyFromSettingActivated(name, GetKey)) 333 | return true; 334 | #endif 335 | } 336 | 337 | if (IsUseMobileInput()) 338 | { 339 | SimulateButton foundSimulateButton; 340 | if (simulateInputs.TryGetValue(name, out foundSimulateButton) && foundSimulateButton.Pressed) 341 | return true; 342 | if (!IsUseNonMobileInput()) 343 | { 344 | if (IsKeyFromSettingActivated(name, GetKey)) 345 | return true; 346 | } 347 | } 348 | return false; 349 | } 350 | 351 | #if USE_REWIRED 352 | public static bool GetButtonDown(string name, int playerId = 0) 353 | #else 354 | public static bool GetButtonDown(string name) 355 | #endif 356 | { 357 | if (string.IsNullOrEmpty(name)) 358 | return false; 359 | 360 | if (IsUseNonMobileInput()) 361 | { 362 | // Try get input by rewired system 363 | #if USE_REWIRED 364 | try 365 | { 366 | Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerId); 367 | if (player.GetButtonDown(name)) 368 | return true; 369 | } 370 | catch { } 371 | #endif 372 | 373 | #if ENABLE_INPUT_SYSTEM 374 | if (TryGetInputAction(name, out InputAction inputAction)) 375 | { 376 | if (inputAction.WasPressedThisFrame()) 377 | return true; 378 | } 379 | #endif 380 | 381 | #if ENABLE_LEGACY_INPUT_MANAGER 382 | try 383 | { 384 | if (Input.GetButtonDown(name)) 385 | return true; 386 | } 387 | catch { } 388 | if (IsKeyFromSettingActivated(name, GetKeyDown)) 389 | return true; 390 | #endif 391 | } 392 | 393 | if (IsUseMobileInput()) 394 | { 395 | SimulateButton foundSimulateButton; 396 | if (simulateInputs.TryGetValue(name, out foundSimulateButton) && foundSimulateButton.ButtonDown) 397 | return true; 398 | if (!IsUseNonMobileInput()) 399 | { 400 | if (IsKeyFromSettingActivated(name, GetKeyDown)) 401 | return true; 402 | } 403 | } 404 | return false; 405 | } 406 | 407 | #if USE_REWIRED 408 | public static bool GetButtonUp(string name, int playerId = 0) 409 | #else 410 | public static bool GetButtonUp(string name) 411 | #endif 412 | { 413 | if (string.IsNullOrEmpty(name)) 414 | return false; 415 | 416 | 417 | if (IsUseNonMobileInput()) 418 | { 419 | // Try get input by rewired system 420 | #if USE_REWIRED 421 | try 422 | { 423 | Rewired.Player player = Rewired.ReInput.players.GetPlayer(playerId); 424 | if (player.GetButtonUp(name)) 425 | return true; 426 | } 427 | catch { } 428 | #endif 429 | 430 | #if ENABLE_INPUT_SYSTEM 431 | if (TryGetInputAction(name, out InputAction inputAction)) 432 | { 433 | if (inputAction.WasReleasedThisFrame()) 434 | return true; 435 | } 436 | #endif 437 | 438 | #if ENABLE_LEGACY_INPUT_MANAGER 439 | try 440 | { 441 | if (Input.GetButtonUp(name)) 442 | return true; 443 | } 444 | catch { } 445 | if (IsKeyFromSettingActivated(name, GetKeyUp)) 446 | return true; 447 | #endif 448 | } 449 | 450 | if (IsUseMobileInput()) 451 | { 452 | SimulateButton foundSimulateButton; 453 | if (simulateInputs.TryGetValue(name, out foundSimulateButton) && foundSimulateButton.ButtonUp) 454 | return true; 455 | if (!IsUseNonMobileInput()) 456 | { 457 | if (IsKeyFromSettingActivated(name, GetKeyUp)) 458 | return true; 459 | } 460 | } 461 | return false; 462 | } 463 | 464 | public static void SetButtonDown(string name) 465 | { 466 | if (!simulateInputs.ContainsKey(name)) 467 | { 468 | simulateInputs.Add(name, new SimulateButton()); 469 | } 470 | simulateInputs[name].Press(); 471 | } 472 | 473 | public static void SetButtonUp(string name) 474 | { 475 | if (!simulateInputs.ContainsKey(name)) 476 | { 477 | simulateInputs.Add(name, new SimulateButton()); 478 | } 479 | simulateInputs[name].Release(); 480 | } 481 | 482 | public static void SetKeyDown(KeyCode key) 483 | { 484 | if (!simulateKeys.ContainsKey(key)) 485 | { 486 | simulateKeys.Add(key, new SimulateButton()); 487 | } 488 | simulateKeys[key].Press(); 489 | } 490 | 491 | public static void SetKeyUp(KeyCode key) 492 | { 493 | if (!simulateKeys.ContainsKey(key)) 494 | { 495 | simulateKeys.Add(key, new SimulateButton()); 496 | } 497 | simulateKeys[key].Release(); 498 | } 499 | 500 | public static void SetAxisPositive(string name) 501 | { 502 | if (!simulateAxis.ContainsKey(name)) 503 | { 504 | simulateAxis.Add(name, new SimulateAxis()); 505 | } 506 | simulateAxis[name].Update(1f); 507 | } 508 | 509 | public static void SetAxisNegative(string name) 510 | { 511 | if (!simulateAxis.ContainsKey(name)) 512 | { 513 | simulateAxis.Add(name, new SimulateAxis()); 514 | } 515 | simulateAxis[name].Update(-1f); 516 | } 517 | 518 | public static void SetAxisZero(string name) 519 | { 520 | if (!simulateAxis.ContainsKey(name)) 521 | { 522 | simulateAxis.Add(name, new SimulateAxis()); 523 | } 524 | simulateAxis[name].Update(0); 525 | } 526 | 527 | public static void SetAxis(string name, float value) 528 | { 529 | if (!simulateAxis.ContainsKey(name)) 530 | { 531 | simulateAxis.Add(name, new SimulateAxis()); 532 | } 533 | simulateAxis[name].Update(value); 534 | } 535 | 536 | public static Vector3 MousePosition() 537 | { 538 | #if ENABLE_INPUT_SYSTEM 539 | if (Application.isMobilePlatform) 540 | return Touchscreen.current.primaryTouch.position.value; 541 | return Mouse.current.position.value; 542 | #else 543 | return Input.mousePosition; 544 | #endif 545 | } 546 | 547 | public static bool GetMouseButtonDown(int button) 548 | { 549 | #if ENABLE_INPUT_SYSTEM 550 | if (Application.isMobilePlatform) 551 | return Touchscreen.current.primaryTouch.press.wasPressedThisFrame; 552 | switch (button) 553 | { 554 | case 0: 555 | return Mouse.current.leftButton.wasPressedThisFrame; 556 | case 1: 557 | return Mouse.current.rightButton.wasPressedThisFrame; 558 | case 2: 559 | return Mouse.current.middleButton.wasPressedThisFrame; 560 | } 561 | return false; 562 | #else 563 | return Input.GetMouseButtonDown(button); 564 | #endif 565 | } 566 | 567 | public static bool GetMouseButtonUp(int button) 568 | { 569 | #if ENABLE_INPUT_SYSTEM 570 | if (Application.isMobilePlatform) 571 | return Touchscreen.current.primaryTouch.press.wasReleasedThisFrame; 572 | switch (button) 573 | { 574 | case 0: 575 | return Mouse.current.leftButton.wasReleasedThisFrame; 576 | case 1: 577 | return Mouse.current.rightButton.wasReleasedThisFrame; 578 | case 2: 579 | return Mouse.current.middleButton.wasReleasedThisFrame; 580 | } 581 | return false; 582 | #else 583 | return Input.GetMouseButtonUp(button); 584 | #endif 585 | } 586 | 587 | public static bool GetMouseButton(int button) 588 | { 589 | #if ENABLE_INPUT_SYSTEM 590 | if (Application.isMobilePlatform) 591 | return Touchscreen.current.primaryTouch.press.isPressed; 592 | switch (button) 593 | { 594 | case 0: 595 | return Mouse.current.leftButton.isPressed; 596 | case 1: 597 | return Mouse.current.rightButton.isPressed; 598 | case 2: 599 | return Mouse.current.middleButton.isPressed; 600 | } 601 | return false; 602 | #else 603 | return Input.GetMouseButton(button); 604 | #endif 605 | } 606 | 607 | public class SimulateButton 608 | { 609 | private int lastPressedFrame = -5; 610 | private int releasedFrame = -5; 611 | 612 | public bool Pressed { get; private set; } 613 | 614 | public void Press() 615 | { 616 | if (Pressed) 617 | return; 618 | Pressed = true; 619 | lastPressedFrame = Time.frameCount; 620 | } 621 | 622 | public void Release() 623 | { 624 | Pressed = false; 625 | releasedFrame = Time.frameCount; 626 | } 627 | 628 | public bool ButtonDown 629 | { 630 | get { return lastPressedFrame - Time.frameCount == -1; } 631 | } 632 | 633 | public bool ButtonUp 634 | { 635 | get { return releasedFrame == Time.frameCount - 1; } 636 | } 637 | } 638 | 639 | public class SimulateAxis 640 | { 641 | public float Value { get; private set; } 642 | public void Update(float value) 643 | { 644 | Value = value; 645 | } 646 | } 647 | } 648 | } 649 | -------------------------------------------------------------------------------- /Scripts/Input/InputManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d55ee66f98777e498e586e77c248ebc 3 | timeCreated: 1495872998 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Input/InputSettingManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | #if ENABLE_INPUT_SYSTEM 4 | using UnityEngine.InputSystem; 5 | #endif 6 | 7 | namespace Insthync.CameraAndInput 8 | { 9 | public class InputSettingManager : MonoBehaviour 10 | { 11 | [System.Serializable] 12 | public struct InputSetting 13 | { 14 | public string keyName; 15 | public KeyCode keyCode; 16 | } 17 | 18 | public static InputSettingManager Singleton { get; protected set; } 19 | 20 | [Tooltip("These settings will override Unity's input manager axes settings")] 21 | public InputSetting[] settings; 22 | public string settingsSaveKeyPrefix = "SETTING_KEY_BIND"; 23 | #if ENABLE_INPUT_SYSTEM 24 | public InputActionAsset inputActionAsset; 25 | #endif 26 | 27 | internal readonly Dictionary> Settings = new Dictionary>(); 28 | 29 | private void Awake() 30 | { 31 | if (Singleton != null) 32 | { 33 | Destroy(gameObject); 34 | return; 35 | } 36 | Singleton = GetComponent(); 37 | DontDestroyOnLoad(gameObject); 38 | Setup(); 39 | } 40 | 41 | public void Setup() 42 | { 43 | if (settings != null && settings.Length > 0) 44 | { 45 | Settings.Clear(); 46 | foreach (InputSetting setting in settings) 47 | { 48 | if (!Settings.ContainsKey(setting.keyName)) 49 | Settings[setting.keyName] = new List(); 50 | if (!Settings[setting.keyName].Contains(setting.keyCode)) 51 | Settings[setting.keyName].Add(LoadKeyBinding(setting.keyName, Settings[setting.keyName].Count - 1, setting.keyCode)); 52 | } 53 | } 54 | } 55 | 56 | public void ResetSettings() 57 | { 58 | if (settings != null && settings.Length > 0) 59 | { 60 | Settings.Clear(); 61 | foreach (InputSetting setting in settings) 62 | { 63 | if (!Settings.ContainsKey(setting.keyName)) 64 | Settings[setting.keyName] = new List(); 65 | if (!Settings[setting.keyName].Contains(setting.keyCode)) 66 | Settings[setting.keyName].Add(SaveKeyBinding(setting.keyName, Settings[setting.keyName].Count - 1, setting.keyCode)); 67 | } 68 | } 69 | } 70 | 71 | public string GetSaveKey(string keyName, int index) 72 | { 73 | return $"{settingsSaveKeyPrefix}_{keyName}_{index}"; 74 | } 75 | 76 | public KeyCode LoadKeyBinding(string keyName, int index, KeyCode defaultKey) 77 | { 78 | return (KeyCode)PlayerPrefs.GetInt(GetSaveKey(keyName, index), (int)defaultKey); 79 | } 80 | 81 | public KeyCode SaveKeyBinding(string keyName, int index, KeyCode key) 82 | { 83 | PlayerPrefs.SetInt(GetSaveKey(keyName, index), (int)key); 84 | PlayerPrefs.Save(); 85 | return key; 86 | } 87 | 88 | public void SetKeySetting(string keyName, int index, KeyCode key) 89 | { 90 | if (!Settings.ContainsKey(keyName) || index >= Settings[keyName].Count) 91 | return; 92 | Settings[keyName][index] = SaveKeyBinding(keyName, index, key); 93 | } 94 | 95 | public KeyCode GetKeySetting(string keyName, int index) 96 | { 97 | if (!Settings.ContainsKey(keyName) || index >= Settings[keyName].Count) 98 | return KeyCode.None; 99 | return Settings[keyName][index]; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Scripts/Input/InputSettingManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed2cb86d2cba09b418e9204894872c72 3 | timeCreated: 1519297494 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Scripts/Input/KeyConvertUtils.cs: -------------------------------------------------------------------------------- 1 | #if ENABLE_INPUT_SYSTEM 2 | using UnityEngine.InputSystem; 3 | using UnityEngine; 4 | using UnityEngine.InputSystem.Controls; 5 | 6 | namespace Insthync.CameraAndInput 7 | { 8 | public static class KeyConvertUtils 9 | { 10 | public static Key KeyCodeToKey(this KeyCode keyCode) 11 | { 12 | switch (keyCode) 13 | { 14 | case KeyCode.None: return Key.None; 15 | case KeyCode.Backspace: return Key.Backspace; 16 | case KeyCode.Delete: return Key.Delete; 17 | case KeyCode.Tab: return Key.Tab; 18 | case KeyCode.Clear: return Key.None; // Unknow. 19 | case KeyCode.Return: return Key.Enter; 20 | case KeyCode.Pause: return Key.Pause; 21 | case KeyCode.Escape: return Key.Escape; 22 | case KeyCode.Space: return Key.Space; 23 | 24 | case KeyCode.Keypad0: return Key.Numpad0; 25 | case KeyCode.Keypad1: return Key.Numpad1; 26 | case KeyCode.Keypad2: return Key.Numpad2; 27 | case KeyCode.Keypad3: return Key.Numpad3; 28 | case KeyCode.Keypad4: return Key.Numpad4; 29 | case KeyCode.Keypad5: return Key.Numpad5; 30 | case KeyCode.Keypad6: return Key.Numpad6; 31 | case KeyCode.Keypad7: return Key.Numpad7; 32 | case KeyCode.Keypad8: return Key.Numpad8; 33 | case KeyCode.Keypad9: return Key.Numpad9; 34 | case KeyCode.KeypadPeriod: return Key.NumpadPeriod; 35 | case KeyCode.KeypadDivide: return Key.NumpadDivide; 36 | case KeyCode.KeypadMultiply: return Key.NumpadMultiply; 37 | case KeyCode.KeypadMinus: return Key.NumpadMinus; 38 | case KeyCode.KeypadPlus: return Key.NumpadPlus; 39 | case KeyCode.KeypadEnter: return Key.NumpadEnter; 40 | case KeyCode.KeypadEquals: return Key.NumpadEquals; 41 | 42 | case KeyCode.UpArrow: return Key.UpArrow; 43 | case KeyCode.DownArrow: return Key.DownArrow; 44 | case KeyCode.RightArrow: return Key.RightArrow; 45 | case KeyCode.LeftArrow: return Key.LeftArrow; 46 | 47 | case KeyCode.Insert: return Key.Insert; 48 | case KeyCode.Home: return Key.Home; 49 | case KeyCode.End: return Key.End; 50 | case KeyCode.PageUp: return Key.PageUp; 51 | case KeyCode.PageDown: return Key.PageDown; 52 | 53 | case KeyCode.F1: return Key.F1; 54 | case KeyCode.F2: return Key.F2; 55 | case KeyCode.F3: return Key.F3; 56 | case KeyCode.F4: return Key.F4; 57 | case KeyCode.F5: return Key.F5; 58 | case KeyCode.F6: return Key.F6; 59 | case KeyCode.F7: return Key.F7; 60 | case KeyCode.F8: return Key.F8; 61 | case KeyCode.F9: return Key.F9; 62 | case KeyCode.F10: return Key.F10; 63 | case KeyCode.F11: return Key.F11; 64 | case KeyCode.F12: return Key.F12; 65 | case KeyCode.F13: return Key.None; // Unknow. 66 | case KeyCode.F14: return Key.None; // Unknow. 67 | case KeyCode.F15: return Key.None; // Unknow. 68 | 69 | case KeyCode.Alpha1: return Key.Digit1; 70 | case KeyCode.Exclaim: return Key.Digit1; // Shift Key. 71 | case KeyCode.Alpha2: return Key.Digit2; 72 | case KeyCode.At: return Key.Digit2; // Shift Key. 73 | case KeyCode.Alpha3: return Key.Digit3; 74 | case KeyCode.Hash: return Key.Digit3; // Shift Key. 75 | case KeyCode.Alpha4: return Key.Digit4; 76 | case KeyCode.Dollar: return Key.Digit4; // Shift Key. 77 | case KeyCode.Alpha5: return Key.Digit5; 78 | case KeyCode.Percent: return Key.Digit5; // Shift Key. 79 | case KeyCode.Alpha6: return Key.Digit6; 80 | case KeyCode.Caret: return Key.Digit6; // Shift Key. 81 | case KeyCode.Alpha7: return Key.Digit7; 82 | case KeyCode.Ampersand: return Key.Digit7; // Shift Key. 83 | case KeyCode.Alpha8: return Key.Digit8; 84 | case KeyCode.Asterisk: return Key.Digit8; // Shift Key. 85 | case KeyCode.Alpha9: return Key.Digit9; 86 | case KeyCode.LeftParen: return Key.Digit9; // Shift Key. 87 | case KeyCode.Alpha0: return Key.Digit0; 88 | case KeyCode.RightParen: return Key.Digit0; // Shift Key. 89 | case KeyCode.Minus: return Key.Minus; 90 | case KeyCode.Underscore: return Key.Minus; // Shift Key. 91 | case KeyCode.Equals: return Key.Equals; 92 | case KeyCode.Plus: return Key.Equals; // Shift Key. 93 | 94 | case KeyCode.LeftBracket: return Key.LeftBracket; 95 | case KeyCode.LeftCurlyBracket: return Key.LeftBracket; // Shift Key. 96 | case KeyCode.RightBracket: return Key.RightBracket; 97 | case KeyCode.RightCurlyBracket: return Key.RightBracket; // Shift Key. 98 | case KeyCode.Backslash: return Key.Backslash; 99 | case KeyCode.Pipe: return Key.Backslash; // Shift Key. 100 | 101 | case KeyCode.Semicolon: return Key.Semicolon; 102 | case KeyCode.Colon: return Key.Semicolon; // Shift Key. 103 | case KeyCode.Quote: return Key.Quote; 104 | case KeyCode.DoubleQuote: return Key.Quote; // Shift Key. 105 | 106 | case KeyCode.Comma: return Key.Comma; 107 | case KeyCode.Less: return Key.Comma; // Shift Key. 108 | case KeyCode.Period: return Key.Period; 109 | case KeyCode.Greater: return Key.Period; // // Shift Key. 110 | case KeyCode.Slash: return Key.Slash; 111 | case KeyCode.Question: return Key.Slash; // Shift Key. 112 | 113 | case KeyCode.BackQuote: return Key.Backquote; 114 | case KeyCode.Tilde: return Key.Backquote; // Shift Key. 115 | 116 | case KeyCode.A: return Key.A; 117 | case KeyCode.B: return Key.B; 118 | case KeyCode.C: return Key.C; 119 | case KeyCode.D: return Key.D; 120 | case KeyCode.E: return Key.E; 121 | case KeyCode.F: return Key.F; 122 | case KeyCode.G: return Key.G; 123 | case KeyCode.H: return Key.H; 124 | case KeyCode.I: return Key.I; 125 | case KeyCode.J: return Key.J; 126 | case KeyCode.K: return Key.K; 127 | case KeyCode.L: return Key.L; 128 | case KeyCode.M: return Key.M; 129 | case KeyCode.N: return Key.N; 130 | case KeyCode.O: return Key.O; 131 | case KeyCode.P: return Key.P; 132 | case KeyCode.Q: return Key.Q; 133 | case KeyCode.R: return Key.R; 134 | case KeyCode.S: return Key.S; 135 | case KeyCode.T: return Key.T; 136 | case KeyCode.U: return Key.U; 137 | case KeyCode.V: return Key.V; 138 | case KeyCode.W: return Key.W; 139 | case KeyCode.X: return Key.X; 140 | case KeyCode.Y: return Key.Y; 141 | case KeyCode.Z: return Key.Z; 142 | 143 | case KeyCode.Numlock: return Key.NumLock; 144 | case KeyCode.CapsLock: return Key.CapsLock; 145 | case KeyCode.ScrollLock: return Key.ScrollLock; 146 | case KeyCode.RightShift: return Key.RightShift; 147 | case KeyCode.LeftShift: return Key.LeftShift; 148 | case KeyCode.RightControl: return Key.RightCtrl; 149 | case KeyCode.LeftControl: return Key.LeftCtrl; 150 | case KeyCode.RightAlt: return Key.RightAlt; 151 | case KeyCode.LeftAlt: return Key.LeftAlt; 152 | case KeyCode.LeftCommand: return Key.LeftCommand; 153 | // case KeyCode.LeftApple: (same as LeftCommand) 154 | case KeyCode.LeftWindows: return Key.LeftWindows; 155 | case KeyCode.RightCommand: return Key.RightCommand; 156 | // case KeyCode.RightApple: (same as RightCommand) 157 | case KeyCode.RightWindows: return Key.RightWindows; 158 | case KeyCode.AltGr: return Key.AltGr; 159 | case KeyCode.Help: return Key.None; // Unknow. 160 | case KeyCode.Print: return Key.PrintScreen; 161 | case KeyCode.SysReq: return Key.None; // Unknow. 162 | case KeyCode.Break: return Key.None; // Unknow. 163 | case KeyCode.Menu: return Key.ContextMenu; 164 | // Remains mouse and joystick keys 165 | default: 166 | return Key.None; // Can convert only keyboard keys. 167 | } 168 | } 169 | 170 | public static KeyCode KeyToKeyCode(this Key key) 171 | { 172 | switch (key) 173 | { 174 | case Key.None: return KeyCode.None; 175 | case Key.Space: return KeyCode.Space; 176 | case Key.Enter: return KeyCode.Return; 177 | case Key.Tab: return KeyCode.Tab; 178 | case Key.Backquote: return KeyCode.BackQuote; 179 | case Key.Quote: return KeyCode.Quote; 180 | case Key.Semicolon: return KeyCode.Semicolon; 181 | case Key.Comma: return KeyCode.Comma; 182 | case Key.Period: return KeyCode.Period; 183 | case Key.Slash: return KeyCode.Slash; 184 | case Key.Backslash: return KeyCode.Backslash; 185 | case Key.LeftBracket: return KeyCode.LeftBracket; 186 | case Key.RightBracket: return KeyCode.RightBracket; 187 | case Key.Minus: return KeyCode.Minus; 188 | case Key.Equals: return KeyCode.Equals; 189 | case Key.A: return KeyCode.A; 190 | case Key.B: return KeyCode.B; 191 | case Key.C: return KeyCode.C; 192 | case Key.D: return KeyCode.D; 193 | case Key.E: return KeyCode.E; 194 | case Key.F: return KeyCode.F; 195 | case Key.G: return KeyCode.G; 196 | case Key.H: return KeyCode.H; 197 | case Key.I: return KeyCode.I; 198 | case Key.J: return KeyCode.J; 199 | case Key.K: return KeyCode.K; 200 | case Key.L: return KeyCode.L; 201 | case Key.M: return KeyCode.M; 202 | case Key.N: return KeyCode.N; 203 | case Key.O: return KeyCode.O; 204 | case Key.P: return KeyCode.P; 205 | case Key.Q: return KeyCode.Q; 206 | case Key.R: return KeyCode.R; 207 | case Key.S: return KeyCode.S; 208 | case Key.T: return KeyCode.T; 209 | case Key.U: return KeyCode.U; 210 | case Key.V: return KeyCode.V; 211 | case Key.W: return KeyCode.W; 212 | case Key.X: return KeyCode.X; 213 | case Key.Y: return KeyCode.Y; 214 | case Key.Z: return KeyCode.Z; 215 | case Key.Digit1: return KeyCode.Alpha1; 216 | case Key.Digit2: return KeyCode.Alpha2; 217 | case Key.Digit3: return KeyCode.Alpha3; 218 | case Key.Digit4: return KeyCode.Alpha4; 219 | case Key.Digit5: return KeyCode.Alpha5; 220 | case Key.Digit6: return KeyCode.Alpha6; 221 | case Key.Digit7: return KeyCode.Alpha7; 222 | case Key.Digit8: return KeyCode.Alpha8; 223 | case Key.Digit9: return KeyCode.Alpha9; 224 | case Key.Digit0: return KeyCode.Alpha0; 225 | case Key.LeftShift: return KeyCode.LeftShift; 226 | case Key.RightShift: return KeyCode.RightShift; 227 | case Key.LeftAlt: return KeyCode.LeftAlt; 228 | case Key.RightAlt: return KeyCode.RightAlt; 229 | case Key.LeftCtrl: return KeyCode.LeftControl; 230 | case Key.RightCtrl: return KeyCode.RightControl; 231 | case Key.LeftCommand: return KeyCode.LeftCommand; 232 | case Key.RightCommand: return KeyCode.RightCommand; 233 | case Key.ContextMenu: return KeyCode.None; // Unknow. 234 | case Key.Escape: return KeyCode.Escape; 235 | case Key.LeftArrow: return KeyCode.LeftArrow; 236 | case Key.RightArrow: return KeyCode.RightArrow; 237 | case Key.UpArrow: return KeyCode.UpArrow; 238 | case Key.DownArrow: return KeyCode.DownArrow; 239 | case Key.Backspace: return KeyCode.Backspace; 240 | case Key.PageDown: return KeyCode.PageDown; 241 | case Key.PageUp: return KeyCode.PageUp; 242 | case Key.Home: return KeyCode.Home; 243 | case Key.End: return KeyCode.End; 244 | case Key.Insert: return KeyCode.Insert; 245 | case Key.Delete: return KeyCode.Delete; 246 | case Key.CapsLock: return KeyCode.CapsLock; 247 | case Key.NumLock: return KeyCode.Numlock; 248 | case Key.PrintScreen: return KeyCode.Print; 249 | case Key.ScrollLock: return KeyCode.ScrollLock; 250 | case Key.Pause: return KeyCode.Pause; 251 | case Key.NumpadEnter: return KeyCode.KeypadEnter; 252 | case Key.NumpadDivide: return KeyCode.KeypadDivide; 253 | case Key.NumpadMultiply: return KeyCode.KeypadMultiply; 254 | case Key.NumpadPlus: return KeyCode.KeypadPlus; 255 | case Key.NumpadMinus: return KeyCode.KeypadMinus; 256 | case Key.NumpadPeriod: return KeyCode.KeypadPeriod; 257 | case Key.NumpadEquals: return KeyCode.KeypadEquals; 258 | case Key.Numpad0: return KeyCode.Keypad0; 259 | case Key.Numpad1: return KeyCode.Keypad1; 260 | case Key.Numpad2: return KeyCode.Keypad2; 261 | case Key.Numpad3: return KeyCode.Keypad3; 262 | case Key.Numpad4: return KeyCode.Keypad4; 263 | case Key.Numpad5: return KeyCode.Keypad5; 264 | case Key.Numpad6: return KeyCode.Keypad6; 265 | case Key.Numpad7: return KeyCode.Keypad7; 266 | case Key.Numpad8: return KeyCode.Keypad8; 267 | case Key.Numpad9: return KeyCode.Keypad9; 268 | case Key.F1: return KeyCode.F1; 269 | case Key.F2: return KeyCode.F2; 270 | case Key.F3: return KeyCode.F3; 271 | case Key.F4: return KeyCode.F4; 272 | case Key.F5: return KeyCode.F5; 273 | case Key.F6: return KeyCode.F6; 274 | case Key.F7: return KeyCode.F7; 275 | case Key.F8: return KeyCode.F8; 276 | case Key.F9: return KeyCode.F9; 277 | case Key.F10: return KeyCode.F10; 278 | case Key.F11: return KeyCode.F11; 279 | case Key.F12: return KeyCode.F12; 280 | case Key.OEM1: return KeyCode.None; // Unknow. 281 | case Key.OEM2: return KeyCode.None; // Unknow. 282 | case Key.OEM3: return KeyCode.None; // Unknow. 283 | case Key.OEM4: return KeyCode.None; // Unknow. 284 | case Key.OEM5: return KeyCode.None; // Unknow. 285 | case Key.IMESelected: return KeyCode.None; // Unknow. 286 | default: return KeyCode.None; // Unknow. 287 | } 288 | } 289 | 290 | public static bool IsMouseButton(this KeyCode keyCode) 291 | { 292 | switch (keyCode) 293 | { 294 | case KeyCode.Mouse0: 295 | case KeyCode.Mouse1: 296 | case KeyCode.Mouse2: 297 | case KeyCode.Mouse3: 298 | case KeyCode.Mouse4: 299 | case KeyCode.Mouse5: 300 | case KeyCode.Mouse6: 301 | return true; 302 | default: 303 | return false; 304 | } 305 | } 306 | 307 | public static bool TryGetMouseButtonControl(this KeyCode keyCode, out ButtonControl buttonControl) 308 | { 309 | buttonControl = null; 310 | if (Mouse.current == null) 311 | return false; 312 | switch (keyCode) 313 | { 314 | case KeyCode.Mouse0: 315 | buttonControl = Mouse.current.leftButton; 316 | return true; 317 | case KeyCode.Mouse1: 318 | buttonControl = Mouse.current.rightButton; 319 | return true; 320 | case KeyCode.Mouse2: 321 | buttonControl = Mouse.current.middleButton; 322 | return true; 323 | } 324 | return false; 325 | } 326 | 327 | public static bool TryGetKeyboardKeyControl(this KeyCode keyCode, out KeyControl keyControl) 328 | { 329 | keyControl = null; 330 | if (Keyboard.current == null) 331 | return false; 332 | Key key = keyCode.KeyCodeToKey(); 333 | if (key == Key.None) 334 | return false; 335 | keyControl = Keyboard.current[key]; 336 | return true; 337 | } 338 | } 339 | } 340 | #endif -------------------------------------------------------------------------------- /Scripts/Input/KeyConvertUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c6c2cf645eda1742bce556c33fed421 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputArea.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Insthync.CameraAndInput 4 | { 5 | /// 6 | /// Empty component, use it as a tag for mobile input touching detecting 7 | /// 8 | public class MobileInputArea : MonoBehaviour, IMobileInputArea 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputArea.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a6e167d675f97848a8a7cf166019051 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputButton.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Insthync.CameraAndInput 4 | { 5 | public class MobileInputButton : BaseMobileInputButton 6 | { 7 | [Header("Key")] 8 | public string keyName = string.Empty; 9 | 10 | protected override void OnButtonDown() 11 | { 12 | InputManager.SetButtonDown(keyName); 13 | } 14 | 15 | protected override void OnButtonUp() 16 | { 17 | InputManager.SetButtonUp(keyName); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputButton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a12c854b3244bea43974ab60dca1059d 3 | timeCreated: 1495865050 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputButtonByKeyCode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Insthync.CameraAndInput 4 | { 5 | public class MobileInputButtonByKeyCode : BaseMobileInputButton 6 | { 7 | [Header("Key")] 8 | public KeyCode keyCode = KeyCode.None; 9 | 10 | protected override void OnButtonDown() 11 | { 12 | InputManager.SetKeyDown(keyCode); 13 | } 14 | 15 | protected override void OnButtonUp() 16 | { 17 | InputManager.SetKeyUp(keyCode); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputButtonByKeyCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 935a3acc76f6652419930322b1b36edf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Input/MobileInputConfig.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.EventSystems; 3 | using UnityEngine.UI; 4 | #if UNITY_EDITOR 5 | using UnityEditor; 6 | #endif 7 | 8 | namespace Insthync.CameraAndInput 9 | { 10 | [RequireComponent(typeof(CanvasGroup))] 11 | public class MobileInputConfig : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerDownHandler 12 | { 13 | public const string KEY_X = "_X"; 14 | public const string KEY_Y = "_Y"; 15 | public const string KEY_SCALE = "_SCALE"; 16 | public const string KEY_ALPHA = "_ALPHA"; 17 | [Tooltip("This is key prefix which will follows by _X,_Y")] 18 | public string saveKey = "_ANY_KEY_NAME_"; 19 | [Tooltip("Default position will be used when there is no saved position")] 20 | public Vector2 defaultPosition; 21 | [Tooltip("Default scale will be used when there is no saved scale")] 22 | public float defaultScale = 1f; 23 | [Tooltip("Min value for scale settings")] 24 | public float minScale = 0.1f; 25 | [Tooltip("Max value for scale settings")] 26 | public float maxScale = 2f; 27 | [Tooltip("Default alpha will be used when there is no saved alpha")] 28 | public float defaultAlpha = 1f; 29 | [Tooltip("Min value for alpha settings")] 30 | [Range(0f, 1f)] 31 | public float minAlpha = 0.1f; 32 | [Tooltip("Max value for alpha settings")] 33 | [Range(0f, 1f)] 34 | public float maxAlpha = 1f; 35 | [Tooltip("If this is `TRUE` it will be able to move and save position")] 36 | public bool isEditMode; 37 | [Tooltip("If this is `TRUE` it will save to player prefs when end drag")] 38 | public bool autoSave; 39 | 40 | #region Save keys 41 | public string SaveKeyX { get { return saveKey + KEY_X; } } 42 | public string SaveKeyY { get { return saveKey + KEY_Y; } } 43 | public string SaveKeyScale { get { return saveKey + KEY_SCALE; } } 44 | public string SaveKeyAlpha { get { return saveKey + KEY_ALPHA; } } 45 | #endregion 46 | 47 | #region Saved data 48 | public Vector2 SavedPosition 49 | { 50 | get 51 | { 52 | return new Vector2( 53 | PlayerPrefs.GetFloat(SaveKeyX, defaultPosition.x), 54 | PlayerPrefs.GetFloat(SaveKeyY, defaultPosition.y)); 55 | } 56 | set 57 | { 58 | PlayerPrefs.SetFloat(SaveKeyX, value.x); 59 | PlayerPrefs.SetFloat(SaveKeyY, value.y); 60 | PlayerPrefs.Save(); 61 | } 62 | } 63 | 64 | public Vector2 CurrentPosition 65 | { 66 | get { return RectTransform.anchoredPosition; } 67 | set { RectTransform.anchoredPosition = value; } 68 | } 69 | 70 | public float SavedScale 71 | { 72 | get 73 | { 74 | return PlayerPrefs.GetFloat(SaveKeyScale, defaultScale); 75 | } 76 | set 77 | { 78 | PlayerPrefs.SetFloat(SaveKeyScale, value); 79 | PlayerPrefs.Save(); 80 | } 81 | } 82 | 83 | public float CurrentScale 84 | { 85 | get { return RectTransform.localScale.x; } 86 | set { RectTransform.localScale = Vector3.one * value; } 87 | } 88 | 89 | public float SavedAlpha 90 | { 91 | get 92 | { 93 | return PlayerPrefs.GetFloat(SaveKeyAlpha, defaultAlpha); 94 | } 95 | set 96 | { 97 | PlayerPrefs.SetFloat(SaveKeyAlpha, value); 98 | PlayerPrefs.Save(); 99 | } 100 | } 101 | 102 | public float CurrentAlpha 103 | { 104 | get { return CanvasGroup.alpha; } 105 | set { CanvasGroup.alpha = value; } 106 | } 107 | #endregion 108 | 109 | #region Events 110 | public System.Action onLoadPosition; 111 | public System.Action onLoadScale; 112 | public System.Action onLoadAlpha; 113 | public System.Action onSavePosition; 114 | public System.Action onSaveScale; 115 | public System.Action onSaveAlpha; 116 | #endregion 117 | 118 | public RectTransform RectTransform 119 | { 120 | get { return transform as RectTransform; } 121 | } 122 | 123 | private CanvasGroup canvasGroup; 124 | public CanvasGroup CanvasGroup 125 | { 126 | get 127 | { 128 | if (!canvasGroup) 129 | canvasGroup = GetComponent(); 130 | return canvasGroup; 131 | } 132 | } 133 | 134 | private Vector2 lastMousePosition; 135 | 136 | private void OnEnable() 137 | { 138 | LoadPosition(); 139 | LoadScale(); 140 | LoadAlpha(); 141 | } 142 | 143 | public void ResetPosition() 144 | { 145 | if (!isEditMode) 146 | return; 147 | CurrentPosition = defaultPosition; 148 | } 149 | 150 | public void SavePosition() 151 | { 152 | if (!isEditMode) 153 | return; 154 | SavedPosition = CurrentPosition; 155 | onSavePosition?.Invoke(CurrentPosition); 156 | } 157 | 158 | public void LoadPosition() 159 | { 160 | CurrentPosition = SavedPosition; 161 | onLoadPosition?.Invoke(CurrentPosition); 162 | } 163 | 164 | public void ResetScale() 165 | { 166 | if (!isEditMode) 167 | return; 168 | CurrentScale = defaultScale; 169 | } 170 | 171 | public void SaveScale() 172 | { 173 | if (!isEditMode) 174 | return; 175 | SavedScale = CurrentScale; 176 | onSaveScale?.Invoke(CurrentScale); 177 | } 178 | 179 | public void LoadScale() 180 | { 181 | CanvasGroup.alpha = SavedAlpha; 182 | CurrentScale = SavedScale; 183 | onLoadScale?.Invoke(CurrentScale); 184 | } 185 | 186 | public void SetScale(float amount) 187 | { 188 | amount = amount < minScale ? minScale : amount; 189 | amount = amount > maxScale ? maxScale : amount; 190 | CurrentScale = amount; 191 | } 192 | 193 | public void ResetAlpha() 194 | { 195 | if (!isEditMode) 196 | return; 197 | CurrentAlpha = defaultAlpha; 198 | } 199 | 200 | public void SaveAlpha() 201 | { 202 | if (!isEditMode) 203 | return; 204 | SavedAlpha = CurrentAlpha; 205 | onSaveAlpha?.Invoke(CurrentAlpha); 206 | } 207 | 208 | public void LoadAlpha() 209 | { 210 | CurrentAlpha = SavedAlpha; 211 | onLoadAlpha?.Invoke(CurrentAlpha); 212 | } 213 | 214 | public void SetAlpha(float amount) 215 | { 216 | amount = amount < minAlpha ? minAlpha : amount; 217 | amount = amount > maxAlpha ? maxAlpha : amount; 218 | CurrentAlpha = amount; 219 | } 220 | 221 | #if UNITY_EDITOR 222 | [ContextMenu("Set Default Position By Current Position To All Objects", false, 1000000)] 223 | public void SetDefaultPositionByCurrentPositionToAllObjects() 224 | { 225 | var objs = FindObjectsOfType(); 226 | foreach (var obj in objs) 227 | { 228 | obj.SetDefaultPositionByCurrentPosition(); 229 | } 230 | } 231 | 232 | [ContextMenu("Set Default Scale By Current Scale To All Objects", false, 1000001)] 233 | public void SetDefaultScaleByCurrentScaleToAllObjects() 234 | { 235 | var objs = FindObjectsOfType(); 236 | foreach (var obj in objs) 237 | { 238 | obj.SetDefaultScaleByCurrentScale(); 239 | } 240 | } 241 | 242 | [ContextMenu("Set Default Alpha By Current Alpha To All Objects", false, 1000002)] 243 | public void SetDefaultAlphaByCurrentAlphaToAllObjects() 244 | { 245 | var objs = FindObjectsOfType(); 246 | foreach (var obj in objs) 247 | { 248 | obj.SetDefaultAlphaByCurrentAlpha(); 249 | } 250 | } 251 | 252 | [ContextMenu("Set Default Position By Current Position", false, 1000100)] 253 | public void SetDefaultPositionByCurrentPosition() 254 | { 255 | defaultPosition = CurrentPosition; 256 | Debug.Log("[MobileInputPositionSave] Set default position to: " + defaultPosition); 257 | EditorUtility.SetDirty(this); 258 | } 259 | 260 | [ContextMenu("Set Default Scale By Current Scale", false, 1000101)] 261 | public void SetDefaultScaleByCurrentScale() 262 | { 263 | defaultScale = CurrentScale; 264 | Debug.Log("[MobileInputScaleSave] Set default scale to: " + defaultScale); 265 | EditorUtility.SetDirty(this); 266 | } 267 | 268 | [ContextMenu("Set Default Alpha By Current Alpha", false, 1000102)] 269 | public void SetDefaultAlphaByCurrentAlpha() 270 | { 271 | defaultAlpha = CurrentAlpha; 272 | Debug.Log("[MobileInputAlphaSave] Set default alpha to: " + defaultAlpha); 273 | EditorUtility.SetDirty(this); 274 | } 275 | 276 | [ContextMenu("Set Current Position By Default Position", false, 1000200)] 277 | public void SetCurrentPositionByDefaultPosition() 278 | { 279 | CurrentPosition = defaultPosition; 280 | Debug.Log("[MobileInputPositionSave] Set current position to: " + CurrentPosition); 281 | EditorUtility.SetDirty(this); 282 | } 283 | 284 | [ContextMenu("Set Current Scale By Default Scale", false, 1000201)] 285 | public void SetCurrentScaleByDefaultScale() 286 | { 287 | CurrentScale = defaultScale; 288 | Debug.Log("[MobileInputScaleSave] Set current scale to: " + CurrentScale); 289 | EditorUtility.SetDirty(this); 290 | } 291 | 292 | [ContextMenu("Set Current Alpha By Default Alpha", false, 1000202)] 293 | public void SetCurrentAlphaByDefaultAlpha() 294 | { 295 | CurrentAlpha = defaultAlpha; 296 | Debug.Log("[MobileInputAlphaSave] Set current alpha to: " + CurrentAlpha); 297 | EditorUtility.SetDirty(this); 298 | } 299 | 300 | [ContextMenu("Find And Remove Child Buttons", false, 1000300)] 301 | public void FindAndRemoveChildButtons() 302 | { 303 | Button[] components = GetComponentsInChildren