diff --git a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesByDiscriminatorValueConverter.cs b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesByDiscriminatorValueConverter.cs index 7922cf960122e88684e64a978bdad71bc5824a95..5d6a9f37ea8e9401f3eb7109a5be10f0dcd9cd62 100644 --- a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesByDiscriminatorValueConverter.cs +++ b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesByDiscriminatorValueConverter.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; namespace JsonSubTypes { diff --git a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverter.cs b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverter.cs index 80f436f915d588ec10d0a24f4414f85a6d53dcab..b03dda3b93b281c21a4e1ae4e5a92f6c390521a0 100644 --- a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverter.cs +++ b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; namespace JsonSubTypes { diff --git a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverterBuilder.cs b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverterBuilder.cs index 49c5c484a9317c1bc4f205722d4c858497c23373..edc3d32b63fceb8f0b52127f06f364271cc2ab78 100644 --- a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverterBuilder.cs +++ b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesConverterBuilder.cs @@ -1,5 +1,5 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; +using System; namespace JsonSubTypes { diff --git a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesWithPropertyConverterBuilder.cs b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesWithPropertyConverterBuilder.cs index 72cbe21d973e0e7c89f4946035276414fcd37c77..381602aa21e7035fc4503e9f9f046dfd0631d413 100644 --- a/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesWithPropertyConverterBuilder.cs +++ b/Assets/Plugins/JsonSubTypes/JsonSubTypes/JsonSubtypesWithPropertyConverterBuilder.cs @@ -1,6 +1,6 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; -using Newtonsoft.Json; namespace JsonSubTypes { diff --git a/Assets/Plugins/LowPolyWater_Pack/Scripts/Editor/GeneratePlane.cs b/Assets/Plugins/LowPolyWater_Pack/Scripts/Editor/GeneratePlane.cs index db511a869ffe0ceef1f3ac81877679610e0ba70a..9e2bfc583350c05c74d702b7826dc77c6944001c 100644 --- a/Assets/Plugins/LowPolyWater_Pack/Scripts/Editor/GeneratePlane.cs +++ b/Assets/Plugins/LowPolyWater_Pack/Scripts/Editor/GeneratePlane.cs @@ -1,6 +1,6 @@ -using UnityEngine; +using System.IO; using UnityEditor; -using System.IO; +using UnityEngine; namespace LowPolyWater { @@ -10,8 +10,8 @@ public class GeneratePlane : ScriptableWizard public int widthSegments = 1; //Number of pieces for dividing plane vertically public int heightSegments = 1; //Number of pieces for dividing plane horizontally - public float planeWidth = 1.0f; - public float planeHeight = 1.0f; + public float planeWidth = 1.0f; + public float planeHeight = 1.0f; public bool addCollider = false; //Add box collider? public Material material; //By default, it is assigned to 'LowPolyWaterMaterial' in the editor @@ -157,7 +157,7 @@ private void OnWizardCreate() //Add LowPolyWater as component plane.AddComponent<LowPolyWater>(); - + Selection.activeObject = plane; } } diff --git a/Assets/Plugins/LowPolyWater_Pack/Scripts/LowPolyWater.cs b/Assets/Plugins/LowPolyWater_Pack/Scripts/LowPolyWater.cs index f1ea5e408aafe2aa551474a6629ca632845699b3..7034faa9d080bbe81aefb94af1cb54fa6dab9424 100644 --- a/Assets/Plugins/LowPolyWater_Pack/Scripts/LowPolyWater.cs +++ b/Assets/Plugins/LowPolyWater_Pack/Scripts/LowPolyWater.cs @@ -43,7 +43,7 @@ MeshFilter CreateMeshLowPoly(MeshFilter mf) //Create a vector array for new vertices Vector3[] vertices = new Vector3[triangles.Length]; - + //Assign vertices to create triangles out of the mesh for (int i = 0; i < triangles.Length; i++) { @@ -60,7 +60,7 @@ MeshFilter CreateMeshLowPoly(MeshFilter mf) return mf; } - + void Update() { GenerateWaves(); @@ -86,7 +86,7 @@ void GenerateWaves() //Oscilate the wave height via sine to create a wave effect v.y = waveHeight * Mathf.Sin(Time.time * Mathf.PI * 2.0f * waveFrequency + (Mathf.PI * 2.0f * distance)); - + //Update the vertex vertices[i] = v; } diff --git a/Assets/Plugins/NaturePackLite/Prefabs/Tree_01.prefab b/Assets/Plugins/NaturePackLite/Prefabs/Tree_01.prefab index 9af736bee2be58d2286573adb73b5525490c733a..652b114e7d528825f8791551554628d9f3ddaf3b 100644 --- a/Assets/Plugins/NaturePackLite/Prefabs/Tree_01.prefab +++ b/Assets/Plugins/NaturePackLite/Prefabs/Tree_01.prefab @@ -57,6 +57,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -81,6 +82,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!64 &6601886996393371248 MeshCollider: m_ObjectHideFlags: 0 @@ -139,7 +141,7 @@ SphereCollider: m_IsTrigger: 0 m_Enabled: 1 serializedVersion: 2 - m_Radius: 0.5 + m_Radius: 0.4 m_Center: {x: 0, y: 0, z: 0} --- !u!33 &933372636075482527 MeshFilter: @@ -164,6 +166,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -188,3 +191,4 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} diff --git a/Assets/Plugins/SkythianCat/Glowing_Forest/Scripts/WaterGroup.cs b/Assets/Plugins/SkythianCat/Glowing_Forest/Scripts/WaterGroup.cs index 00d17617fc589bad85f24b7057534fcbac092db0..9cdeea40ad36f38cc2d45242f0f5189a2b43f0ef 100644 --- a/Assets/Plugins/SkythianCat/Glowing_Forest/Scripts/WaterGroup.cs +++ b/Assets/Plugins/SkythianCat/Glowing_Forest/Scripts/WaterGroup.cs @@ -1,62 +1,72 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; +using UnityEngine; [AddComponentMenu("SkythianCat/Glowing Forest/WaterGroup")] -public class WaterGroup : MonoBehaviour { - - public float waveSpeed; - public Vector2 waveDirection; - /// <summary> - /// Name of each water wave plain that child for WaterGroup script. - /// </summary> - public string nameToFind; - /// <summary> - /// List that contains all water wave plains after game start. - /// </summary> - private List<GameObject> waterWavePlains = new List<GameObject>(); - - - void Start(){ - if(nameToFind == null || nameToFind == ""){ - Debug.LogError (gameObject.name + " | nameToFind is null."); - } - - //Find all transforms that child for this script - Transform[] allChildTransforms = GetComponentsInChildren<Transform> (); - - //Find transforms in allChildTransforms that have nameToFind name and add their to waterWavePlains - foreach(Transform t in allChildTransforms){ - if(t.name == nameToFind){ - waterWavePlains.Add (t.gameObject); - } - } - - if(waterWavePlains.Count == 0){ - Debug.LogError (gameObject.name + " contains no one GameObject with \"" + nameToFind + "\" name."); - } - } - - void LateUpdate () { - if(waterWavePlains.Count != 0){ - foreach(GameObject g in waterWavePlains){ - WaveAnimation (g); - } - } - } - - - /// <summary> - /// Changes texture offset of waterWavePlain. - /// </summary> - /// <param name="waterWavePlain">Water wave plain GameObject.</param> - public void WaveAnimation(GameObject waterWavePlain){ - if(waterWavePlain != null){ - float dirX = Time.time * waveSpeed * waveDirection.x; - float dirY = Time.time * waveSpeed * waveDirection.y; - waterWavePlain.GetComponent<MeshRenderer>().material.SetTextureOffset("_MainTex", new Vector2(dirX, dirY)); - } - } +public class WaterGroup : MonoBehaviour +{ + + public float waveSpeed; + public Vector2 waveDirection; + /// <summary> + /// Name of each water wave plain that child for WaterGroup script. + /// </summary> + public string nameToFind; + /// <summary> + /// List that contains all water wave plains after game start. + /// </summary> + private List<GameObject> waterWavePlains = new List<GameObject>(); + + + void Start() + { + if (nameToFind == null || nameToFind == "") + { + Debug.LogError(gameObject.name + " | nameToFind is null."); + } + + //Find all transforms that child for this script + Transform[] allChildTransforms = GetComponentsInChildren<Transform>(); + + //Find transforms in allChildTransforms that have nameToFind name and add their to waterWavePlains + foreach (Transform t in allChildTransforms) + { + if (t.name == nameToFind) + { + waterWavePlains.Add(t.gameObject); + } + } + + if (waterWavePlains.Count == 0) + { + Debug.LogError(gameObject.name + " contains no one GameObject with \"" + nameToFind + "\" name."); + } + } + + void LateUpdate() + { + if (waterWavePlains.Count != 0) + { + foreach (GameObject g in waterWavePlains) + { + WaveAnimation(g); + } + } + } + + + /// <summary> + /// Changes texture offset of waterWavePlain. + /// </summary> + /// <param name="waterWavePlain">Water wave plain GameObject.</param> + public void WaveAnimation(GameObject waterWavePlain) + { + if (waterWavePlain != null) + { + float dirX = Time.time * waveSpeed * waveDirection.x; + float dirY = Time.time * waveSpeed * waveDirection.y; + waterWavePlain.GetComponent<MeshRenderer>().material.SetTextureOffset("_MainTex", new Vector2(dirX, dirY)); + } + } } diff --git a/Assets/Resources/Prefabs/Angle.prefab b/Assets/Resources/Prefabs/Angle.prefab index 29b1719c0cd94178beff4423ff2dcdcabe7cf650..32725c942e941a86d16988814617814ef214d0a5 100644 --- a/Assets/Resources/Prefabs/Angle.prefab +++ b/Assets/Resources/Prefabs/Angle.prefab @@ -10,8 +10,6 @@ GameObject: m_Component: - component: {fileID: 5828814633827486385} - component: {fileID: 7699224541667766671} - - component: {fileID: 6694473473003647560} - - component: {fileID: 562364442917191108} - component: {fileID: 6234540560952625969} m_Layer: 12 m_Name: AngleText_Back @@ -54,6 +52,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -78,22 +77,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 1 ---- !u!33 &6694473473003647560 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 874001566494999466} - m_Mesh: {fileID: 0} ---- !u!222 &562364442917191108 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 874001566494999466} - m_CullTransparentMesh: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &6234540560952625969 MonoBehaviour: m_ObjectHideFlags: 0 @@ -109,6 +93,7 @@ MonoBehaviour: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -134,13 +119,12 @@ MonoBehaviour: m_fontColorGradientPreset: {fileID: 0} m_spriteAsset: {fileID: 0} m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 m_overrideHtmlColors: 0 m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_outlineColor: - serializedVersion: 2 - rgba: 4278190080 m_fontSize: 2 m_fontSizeBase: 2 m_fontWeight: 400 @@ -148,7 +132,9 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 - m_textAlignment: 514 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -158,10 +144,8 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 m_linkedTextComponent: {fileID: 0} - m_isLinkedTextComponent: 0 - m_isTextTruncated: 0 + parentLinkedComponent: {fileID: 0} m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 @@ -169,42 +153,23 @@ MonoBehaviour: m_parseCtrlCharacters: 1 m_isOrthographic: 0 m_isCullingEnabled: 0 - m_ignoreRectMaskCulling: 0 - m_ignoreCulling: 1 m_horizontalMapping: 0 m_verticalMapping: 0 m_uvLineOffset: 0 m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 m_VertexBufferAutoSizeReduction: 1 - m_firstVisibleCharacter: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 m_margin: {x: 0, y: 0, z: 0, w: 0} - m_textInfo: - textComponent: {fileID: 6234540560952625969} - characterCount: 4 - spriteCount: 0 - spaceCount: 0 - wordCount: 1 - linkCount: 0 - lineCount: 1 - pageCount: 1 - materialCount: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 - m_spriteAnimator: {fileID: 0} m_hasFontAssetChanged: 0 m_renderer: {fileID: 7699224541667766671} - m_subTextObjects: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} m_maskType: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 --- !u!1 &3394522495515098197 GameObject: m_ObjectHideFlags: 0 @@ -264,6 +229,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -288,6 +254,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!64 &3394522495515098203 MeshCollider: m_ObjectHideFlags: 0 @@ -389,6 +356,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -413,6 +381,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!64 &3394522496185282006 MeshCollider: m_ObjectHideFlags: 0 @@ -453,7 +422,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a6b9fc46f5bfe6b4eb4adf01e6b65bac, type: 3} m_Name: m_EditorClassIdentifier: - meshRendererToChange: {fileID: 0} --- !u!1 &7144232170300037021 GameObject: m_ObjectHideFlags: 0 @@ -495,8 +463,6 @@ GameObject: m_Component: - component: {fileID: 6114879545313836302} - component: {fileID: 2846497428082229918} - - component: {fileID: 7050397055091509308} - - component: {fileID: 8918036850658686416} - component: {fileID: 3527746868028771423} m_Layer: 12 m_Name: AngleText_Front @@ -539,6 +505,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -563,22 +530,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 1 ---- !u!33 &7050397055091509308 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8247887023038618208} - m_Mesh: {fileID: 0} ---- !u!222 &8918036850658686416 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8247887023038618208} - m_CullTransparentMesh: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &3527746868028771423 MonoBehaviour: m_ObjectHideFlags: 0 @@ -594,6 +546,7 @@ MonoBehaviour: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -619,13 +572,12 @@ MonoBehaviour: m_fontColorGradientPreset: {fileID: 0} m_spriteAsset: {fileID: 0} m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 m_overrideHtmlColors: 0 m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_outlineColor: - serializedVersion: 2 - rgba: 4278190080 m_fontSize: 2 m_fontSizeBase: 2 m_fontWeight: 400 @@ -633,7 +585,9 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 - m_textAlignment: 514 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -643,10 +597,8 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 m_linkedTextComponent: {fileID: 0} - m_isLinkedTextComponent: 0 - m_isTextTruncated: 0 + parentLinkedComponent: {fileID: 0} m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 @@ -654,39 +606,20 @@ MonoBehaviour: m_parseCtrlCharacters: 1 m_isOrthographic: 0 m_isCullingEnabled: 0 - m_ignoreRectMaskCulling: 0 - m_ignoreCulling: 1 m_horizontalMapping: 0 m_verticalMapping: 0 m_uvLineOffset: 0 m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 m_VertexBufferAutoSizeReduction: 1 - m_firstVisibleCharacter: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 m_margin: {x: 0, y: 0, z: 0, w: 0} - m_textInfo: - textComponent: {fileID: 3527746868028771423} - characterCount: 4 - spriteCount: 0 - spaceCount: 0 - wordCount: 1 - linkCount: 0 - lineCount: 1 - pageCount: 1 - materialCount: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 - m_spriteAnimator: {fileID: 0} m_hasFontAssetChanged: 0 m_renderer: {fileID: 2846497428082229918} - m_subTextObjects: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} m_maskType: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 diff --git a/Assets/Resources/Prefabs/Line.prefab b/Assets/Resources/Prefabs/Line.prefab index b5cab9db1dc0efbe4c78af0fb24f077c80f1ee26..57ed1b8023de62a9772e0820dba0ad78a2c94041 100644 --- a/Assets/Resources/Prefabs/Line.prefab +++ b/Assets/Resources/Prefabs/Line.prefab @@ -42,8 +42,6 @@ GameObject: m_Component: - component: {fileID: 7972877566157790116} - component: {fileID: 2096909858734684758} - - component: {fileID: 6001947194413960154} - - component: {fileID: 2573920697083612823} - component: {fileID: 1723009895384754658} - component: {fileID: 1586728893263614116} m_Layer: 11 @@ -87,6 +85,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -111,22 +110,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 1 ---- !u!33 &6001947194413960154 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4853696702160906218} - m_Mesh: {fileID: 0} ---- !u!222 &2573920697083612823 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4853696702160906218} - m_CullTransparentMesh: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &1723009895384754658 MonoBehaviour: m_ObjectHideFlags: 0 @@ -142,6 +126,7 @@ MonoBehaviour: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -167,13 +152,12 @@ MonoBehaviour: m_fontColorGradientPreset: {fileID: 0} m_spriteAsset: {fileID: 0} m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 m_overrideHtmlColors: 0 m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_outlineColor: - serializedVersion: 2 - rgba: 4278190080 m_fontSize: 4 m_fontSizeBase: 4 m_fontWeight: 400 @@ -181,7 +165,9 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 - m_textAlignment: 258 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -191,10 +177,8 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 m_linkedTextComponent: {fileID: 0} - m_isLinkedTextComponent: 0 - m_isTextTruncated: 0 + parentLinkedComponent: {fileID: 0} m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 @@ -202,42 +186,23 @@ MonoBehaviour: m_parseCtrlCharacters: 1 m_isOrthographic: 0 m_isCullingEnabled: 0 - m_ignoreRectMaskCulling: 0 - m_ignoreCulling: 1 m_horizontalMapping: 0 m_verticalMapping: 0 m_uvLineOffset: 0 m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 m_VertexBufferAutoSizeReduction: 1 - m_firstVisibleCharacter: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 m_margin: {x: 0, y: 0, z: 0, w: 0} - m_textInfo: - textComponent: {fileID: 1723009895384754658} - characterCount: 4 - spriteCount: 0 - spaceCount: 0 - wordCount: 1 - linkCount: 0 - lineCount: 1 - pageCount: 1 - materialCount: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 - m_spriteAnimator: {fileID: 0} m_hasFontAssetChanged: 0 m_renderer: {fileID: 2096909858734684758} - m_subTextObjects: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} m_maskType: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 --- !u!114 &1586728893263614116 MonoBehaviour: m_ObjectHideFlags: 0 @@ -307,6 +272,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -331,6 +297,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &2544799164941842642 MonoBehaviour: m_ObjectHideFlags: 0 @@ -403,6 +370,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -427,6 +395,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &9069160241511124499 MonoBehaviour: m_ObjectHideFlags: 0 @@ -527,6 +496,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -551,3 +521,4 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} diff --git a/Assets/Resources/Prefabs/Rainmaker/BaseRainScript.cs b/Assets/Resources/Prefabs/Rainmaker/BaseRainScript.cs index fd2c71088f2ac722b6eaf944d2af6006fafb563f..895e48ab279bb63e8de6a693bb785126334e59fc 100644 --- a/Assets/Resources/Prefabs/Rainmaker/BaseRainScript.cs +++ b/Assets/Resources/Prefabs/Rainmaker/BaseRainScript.cs @@ -4,10 +4,6 @@ // -using System; -using System.Collections; -using System.Collections.Generic; - using UnityEngine; using UnityEngine.Audio; diff --git a/Assets/Resources/Prefabs/Rainmaker/RainScript.cs b/Assets/Resources/Prefabs/Rainmaker/RainScript.cs index 1436ffa0f54f24e52764c5ef55ce50687d313ae6..d9f5f717e27cd7d08c028dcb7f5d77b6084520a0 100644 --- a/Assets/Resources/Prefabs/Rainmaker/RainScript.cs +++ b/Assets/Resources/Prefabs/Rainmaker/RainScript.cs @@ -4,7 +4,6 @@ // using UnityEngine; -using System.Collections; namespace DigitalRuby.RainMaker { diff --git a/Assets/Resources/Prefabs/Rainmaker/RainScript2D.cs b/Assets/Resources/Prefabs/Rainmaker/RainScript2D.cs index e732696bae7d000de5206d8247f1351f061a29ce..41b99c48029a55666b3c6ca81d0b23415ae32c37 100644 --- a/Assets/Resources/Prefabs/Rainmaker/RainScript2D.cs +++ b/Assets/Resources/Prefabs/Rainmaker/RainScript2D.cs @@ -4,7 +4,6 @@ // using UnityEngine; -using System.Collections; namespace DigitalRuby.RainMaker { @@ -153,7 +152,7 @@ private void CheckForCollisionsMistParticles() for (int i = 0; i < count; i++) { Vector3 pos = particles[i].position + RainMistParticleSystem.transform.position; - hit = Physics2D.Raycast(pos, particles[i].velocity.normalized, particles[i].velocity.magnitude* Time.deltaTime, CollisionMask); + hit = Physics2D.Raycast(pos, particles[i].velocity.normalized, particles[i].velocity.magnitude * Time.deltaTime, CollisionMask); if (hit.collider != null) { particles[i].velocity *= RainMistCollisionMultiplier; diff --git a/Assets/Resources/Prefabs/Ray.prefab b/Assets/Resources/Prefabs/Ray.prefab index 91113a8a0af68d0643d97545ae2aa59bdee5e34d..308edcdf4df6a4b15b601faacdbb7e65796bc951 100644 --- a/Assets/Resources/Prefabs/Ray.prefab +++ b/Assets/Resources/Prefabs/Ray.prefab @@ -88,6 +88,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -112,6 +113,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &6869391996213895011 MonoBehaviour: m_ObjectHideFlags: 0 @@ -124,7 +126,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a6b9fc46f5bfe6b4eb4adf01e6b65bac, type: 3} m_Name: m_EditorClassIdentifier: - meshRendererToChange: {fileID: 323004521892560777} --- !u!1 &4853696702160906218 GameObject: m_ObjectHideFlags: 0 @@ -135,8 +136,6 @@ GameObject: m_Component: - component: {fileID: 7972877566157790116} - component: {fileID: 2096909858734684758} - - component: {fileID: 6001947194413960154} - - component: {fileID: 2573920697083612823} - component: {fileID: 1723009895384754658} - component: {fileID: 1586728893263614116} m_Layer: 13 @@ -180,10 +179,11 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + - {fileID: 2100000, guid: dc000ff84823e7045bac15e87d6da9b2, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -204,22 +204,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 1 ---- !u!33 &6001947194413960154 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4853696702160906218} - m_Mesh: {fileID: 0} ---- !u!222 &2573920697083612823 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4853696702160906218} - m_CullTransparentMesh: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &1723009895384754658 MonoBehaviour: m_ObjectHideFlags: 0 @@ -235,6 +220,7 @@ MonoBehaviour: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -260,13 +246,12 @@ MonoBehaviour: m_fontColorGradientPreset: {fileID: 0} m_spriteAsset: {fileID: 0} m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 m_overrideHtmlColors: 0 m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_outlineColor: - serializedVersion: 2 - rgba: 4278190080 m_fontSize: 4 m_fontSizeBase: 4 m_fontWeight: 400 @@ -274,7 +259,9 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 - m_textAlignment: 258 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -284,10 +271,8 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 m_linkedTextComponent: {fileID: 0} - m_isLinkedTextComponent: 0 - m_isTextTruncated: 0 + parentLinkedComponent: {fileID: 0} m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 @@ -295,42 +280,23 @@ MonoBehaviour: m_parseCtrlCharacters: 1 m_isOrthographic: 0 m_isCullingEnabled: 0 - m_ignoreRectMaskCulling: 0 - m_ignoreCulling: 1 m_horizontalMapping: 0 m_verticalMapping: 0 m_uvLineOffset: 0 m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 m_VertexBufferAutoSizeReduction: 1 - m_firstVisibleCharacter: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 m_margin: {x: 0, y: 0, z: 0, w: 0} - m_textInfo: - textComponent: {fileID: 1723009895384754658} - characterCount: 4 - spriteCount: 0 - spaceCount: 0 - wordCount: 1 - linkCount: 0 - lineCount: 1 - pageCount: 1 - materialCount: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 - m_spriteAnimator: {fileID: 0} m_hasFontAssetChanged: 0 m_renderer: {fileID: 2096909858734684758} - m_subTextObjects: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} m_maskType: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 --- !u!114 &1586728893263614116 MonoBehaviour: m_ObjectHideFlags: 0 @@ -404,6 +370,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -428,6 +395,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &9069160241511124499 MonoBehaviour: m_ObjectHideFlags: 0 @@ -528,6 +496,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -552,3 +521,4 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} diff --git a/Assets/Resources/Prefabs/Sphere.prefab b/Assets/Resources/Prefabs/Sphere.prefab index 7488167e39337b7868f9cd4fb795298bfad78a97..6748d1144311b8d58597d4b37a09353905df33c2 100644 --- a/Assets/Resources/Prefabs/Sphere.prefab +++ b/Assets/Resources/Prefabs/Sphere.prefab @@ -62,6 +62,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -86,6 +87,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!135 &8087426936968725520 SphereCollider: m_ObjectHideFlags: 0 @@ -134,8 +136,6 @@ GameObject: m_Component: - component: {fileID: 206589483256967431} - component: {fileID: 6333161707715706899} - - component: {fileID: 2886949256478333377} - - component: {fileID: 6637014556400691931} - component: {fileID: 4028707725789292921} - component: {fileID: 2878035603844960510} m_Layer: 10 @@ -179,6 +179,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -203,22 +204,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!33 &2886949256478333377 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 942938646191423391} - m_Mesh: {fileID: 0} ---- !u!222 &6637014556400691931 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 942938646191423391} - m_CullTransparentMesh: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!114 &4028707725789292921 MonoBehaviour: m_ObjectHideFlags: 0 @@ -234,6 +220,7 @@ MonoBehaviour: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -259,13 +246,12 @@ MonoBehaviour: m_fontColorGradientPreset: {fileID: 0} m_spriteAsset: {fileID: 0} m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 m_overrideHtmlColors: 0 m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_outlineColor: - serializedVersion: 2 - rgba: 4278190080 m_fontSize: 4 m_fontSizeBase: 4 m_fontWeight: 400 @@ -273,7 +259,9 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 - m_textAlignment: 258 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -283,10 +271,8 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 m_linkedTextComponent: {fileID: 0} - m_isLinkedTextComponent: 0 - m_isTextTruncated: 0 + parentLinkedComponent: {fileID: 0} m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 @@ -294,42 +280,23 @@ MonoBehaviour: m_parseCtrlCharacters: 1 m_isOrthographic: 0 m_isCullingEnabled: 0 - m_ignoreRectMaskCulling: 0 - m_ignoreCulling: 1 m_horizontalMapping: 0 m_verticalMapping: 0 m_uvLineOffset: 0 m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 m_VertexBufferAutoSizeReduction: 1 - m_firstVisibleCharacter: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 m_margin: {x: 0, y: 0, z: 0, w: 0} - m_textInfo: - textComponent: {fileID: 4028707725789292921} - characterCount: 4 - spriteCount: 0 - spaceCount: 0 - wordCount: 1 - linkCount: 0 - lineCount: 1 - pageCount: 1 - materialCount: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 - m_spriteAnimator: {fileID: 0} m_hasFontAssetChanged: 0 m_renderer: {fileID: 6333161707715706899} - m_subTextObjects: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} m_maskType: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 --- !u!114 &2878035603844960510 MonoBehaviour: m_ObjectHideFlags: 0 @@ -442,6 +409,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -466,6 +434,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &7718914877039665658 GameObject: m_ObjectHideFlags: 0 @@ -521,6 +490,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -545,3 +515,4 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} diff --git a/Assets/Scenes/RiverWorld.unity b/Assets/Scenes/RiverWorld.unity index a44cc8ad8f3c8ab11b57bc1931fe236cb486592d..ff124acf69ba4b1196d1887a3d0718843e62d2b9 100644 --- a/Assets/Scenes/RiverWorld.unity +++ b/Assets/Scenes/RiverWorld.unity @@ -43,7 +43,7 @@ RenderSettings: --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 - serializedVersion: 11 + serializedVersion: 12 m_GIWorkflowMode: 1 m_GISettings: serializedVersion: 2 @@ -98,7 +98,7 @@ LightmapSettings: m_TrainingDataDestination: TrainingData m_LightProbeSampleCountMultiplier: 4 m_LightingDataAsset: {fileID: 0} - m_UseShadowmask: 1 + m_LightingSettings: {fileID: 65208636} --- !u!196 &4 NavMeshSettings: serializedVersion: 2 @@ -118,6 +118,8 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 debug: m_Flags: 0 m_NavMeshData: {fileID: 0} @@ -573,6 +575,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -597,6 +600,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &30378783 MeshFilter: m_ObjectHideFlags: 0 @@ -1100,6 +1104,67 @@ Transform: type: 3} m_PrefabInstance: {fileID: 64596003} m_PrefabAsset: {fileID: 0} +--- !u!850595691 &65208636 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Settings.lighting + serializedVersion: 3 + m_GIWorkflowMode: 1 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_RealtimeEnvironmentLighting: 0 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 2 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_TextureCompression: 1 + m_AO: 1 + m_AOMaxDistance: 1 + m_CompAOExponent: 1.47 + m_CompAOExponentDirect: 0.33 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentMIS: 1 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 --- !u!1001 &66876687 PrefabInstance: m_ObjectHideFlags: 0 @@ -1819,6 +1884,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -1844,6 +1910,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &101830288 MeshFilter: m_ObjectHideFlags: 0 @@ -2831,6 +2898,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -2855,6 +2923,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &139953605 MeshFilter: m_ObjectHideFlags: 0 @@ -4119,6 +4188,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -4143,6 +4213,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &216428633 MeshFilter: m_ObjectHideFlags: 0 @@ -5033,6 +5104,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -5057,6 +5129,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &253748273 MeshFilter: m_ObjectHideFlags: 0 @@ -7016,6 +7089,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -7040,6 +7114,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &337499781 MeshFilter: m_ObjectHideFlags: 0 @@ -7755,6 +7830,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -7779,6 +7855,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &353217687 MeshFilter: m_ObjectHideFlags: 0 @@ -9267,6 +9344,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -9291,6 +9369,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &416160899 MeshFilter: m_ObjectHideFlags: 0 @@ -9871,6 +9950,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -9895,6 +9975,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &429920042 MeshFilter: m_ObjectHideFlags: 0 @@ -10045,6 +10126,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -10069,6 +10151,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &444871398 MeshFilter: m_ObjectHideFlags: 0 @@ -10587,6 +10670,7 @@ LineRenderer: m_LightProbeUsage: 0 m_ReflectionProbeUsage: 0 m_RayTracingMode: 0 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -10698,8 +10782,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c75823b1712c4914b987f0e1ba8a5cba, type: 3} m_Name: m_EditorClassIdentifier: - SmartMenu: {fileID: 5601740127768851631, guid: e693bf633c633d243b0254d117ec3893, - type: 3} --- !u!114 &492903079 MonoBehaviour: m_ObjectHideFlags: 0 @@ -11554,6 +11636,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -11578,6 +11661,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &531715946 MeshFilter: m_ObjectHideFlags: 0 @@ -12983,6 +13067,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -13008,6 +13093,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &612245681 MeshFilter: m_ObjectHideFlags: 0 @@ -13393,6 +13479,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -13419,6 +13506,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &624466475 MeshFilter: m_ObjectHideFlags: 0 @@ -15519,6 +15607,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -15543,6 +15632,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &729737314 MeshFilter: m_ObjectHideFlags: 0 @@ -18438,6 +18528,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -18462,6 +18553,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &846067193 MeshFilter: m_ObjectHideFlags: 0 @@ -19644,6 +19736,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -19669,6 +19762,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &882126365 MeshFilter: m_ObjectHideFlags: 0 @@ -20054,6 +20148,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -20078,6 +20173,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &903350951 MeshFilter: m_ObjectHideFlags: 0 @@ -20298,6 +20394,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -20322,6 +20419,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &913671513 MeshFilter: m_ObjectHideFlags: 0 @@ -21112,6 +21210,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -21137,6 +21236,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &959634217 MeshFilter: m_ObjectHideFlags: 0 @@ -21372,6 +21472,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -21397,6 +21498,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &968230991 MeshFilter: m_ObjectHideFlags: 0 @@ -22341,6 +22443,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -22365,6 +22468,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1010711902 MeshFilter: m_ObjectHideFlags: 0 @@ -22674,6 +22778,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -22698,6 +22803,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1022641576 MeshFilter: m_ObjectHideFlags: 0 @@ -22978,6 +23084,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -23002,6 +23109,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1038297210 MeshFilter: m_ObjectHideFlags: 0 @@ -23057,6 +23165,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -23081,6 +23190,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1038851522 MeshFilter: m_ObjectHideFlags: 0 @@ -26021,6 +26131,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -26045,6 +26156,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1194464167 MeshFilter: m_ObjectHideFlags: 0 @@ -26430,6 +26542,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -26454,6 +26567,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1215350000 MeshFilter: m_ObjectHideFlags: 0 @@ -26764,6 +26878,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -26788,6 +26903,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1231439635 MeshFilter: m_ObjectHideFlags: 0 @@ -27203,6 +27319,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -27229,6 +27346,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1258304419 MeshFilter: m_ObjectHideFlags: 0 @@ -29414,6 +29532,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -29438,6 +29557,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1403024660 MeshFilter: m_ObjectHideFlags: 0 @@ -31328,6 +31448,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -31352,6 +31473,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1493064306 MeshFilter: m_ObjectHideFlags: 0 @@ -31977,6 +32099,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -32001,6 +32124,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1551878557 MeshFilter: m_ObjectHideFlags: 0 @@ -32339,6 +32463,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -32363,6 +32488,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1558248473 MeshFilter: m_ObjectHideFlags: 1 @@ -32432,6 +32558,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -32456,6 +32583,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1560940263 MeshFilter: m_ObjectHideFlags: 0 @@ -33090,6 +33218,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -33114,6 +33243,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1593527563 MeshFilter: m_ObjectHideFlags: 0 @@ -34189,6 +34319,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -34213,6 +34344,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1635427267 MeshFilter: m_ObjectHideFlags: 0 @@ -35738,6 +35870,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -35762,6 +35895,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1712627345 MeshFilter: m_ObjectHideFlags: 0 @@ -35817,6 +35951,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -35841,6 +35976,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1719938470 MeshFilter: m_ObjectHideFlags: 0 @@ -38465,6 +38601,7 @@ Light: m_UseColorTemperature: 0 m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!1001 &1846679298 @@ -38604,6 +38741,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -38628,6 +38766,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1848800030 MeshFilter: m_ObjectHideFlags: 0 @@ -40110,6 +40249,7 @@ MeshRenderer: m_LightProbeUsage: 0 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -40134,6 +40274,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1902411367 MeshFilter: m_ObjectHideFlags: 0 @@ -53067,6 +53208,11 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1961703113} m_Modifications: + - target: {fileID: 539717056228735193, guid: 88f2fd29f58b9734683512546acec310, + type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2222111361404534124, guid: 88f2fd29f58b9734683512546acec310, type: 3} propertyPath: m_Name @@ -53196,6 +53342,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -53220,6 +53367,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1911980458 MeshFilter: m_ObjectHideFlags: 0 @@ -55311,6 +55459,7 @@ Light: m_UseColorTemperature: 0 m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!1 &2021868170 @@ -55403,6 +55552,7 @@ Light: m_UseColorTemperature: 0 m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!1001 &2039433987 @@ -57391,6 +57541,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -57416,6 +57567,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &2127241445 MeshFilter: m_ObjectHideFlags: 0 @@ -57978,6 +58130,7 @@ Light: m_UseColorTemperature: 0 m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!4 &685153537209802452 @@ -58065,6 +58218,21 @@ PrefabInstance: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 293934905664952486, guid: b996060e27da25c498842defc1996d84, + type: 3} + propertyPath: modredo + value: mod+redo + objectReference: {fileID: 0} + - target: {fileID: 293934905664952486, guid: b996060e27da25c498842defc1996d84, + type: 3} + propertyPath: modundo + value: mod+undo + objectReference: {fileID: 0} + - target: {fileID: 293934905664952486, guid: b996060e27da25c498842defc1996d84, + type: 3} + propertyPath: modifier + value: modifier + objectReference: {fileID: 0} - target: {fileID: 293934905664952486, guid: b996060e27da25c498842defc1996d84, type: 3} propertyPath: CamControl @@ -58295,6 +58463,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -58320,6 +58489,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &1017499588648496289 GameObject: m_ObjectHideFlags: 0 @@ -58359,6 +58529,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -58383,6 +58554,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!23 &1099843466031652983 MeshRenderer: m_ObjectHideFlags: 0 @@ -58398,6 +58570,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -58422,6 +58595,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &1316124618987194725 GameObject: m_ObjectHideFlags: 0 @@ -58545,6 +58719,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -58569,6 +58744,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &1745987128933336103 MeshFilter: m_ObjectHideFlags: 0 @@ -59143,6 +59319,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59168,6 +59345,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!23 &2600518979547571749 MeshRenderer: m_ObjectHideFlags: 0 @@ -59183,6 +59361,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59207,6 +59386,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!4 &2609522164336802835 Transform: m_ObjectHideFlags: 0 @@ -59361,6 +59541,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59385,6 +59566,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &4170768673617977780 GameObject: m_ObjectHideFlags: 0 @@ -59480,6 +59662,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59504,6 +59687,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!4 &4565031082369432565 Transform: m_ObjectHideFlags: 0 @@ -59550,6 +59734,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59574,6 +59759,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &5064968614624445547 MeshFilter: m_ObjectHideFlags: 0 @@ -59641,6 +59827,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59665,6 +59852,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!4 &5537943171067704051 Transform: m_ObjectHideFlags: 0 @@ -59722,6 +59910,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59746,6 +59935,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &5951941432316338672 MeshFilter: m_ObjectHideFlags: 0 @@ -59787,6 +59977,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59812,6 +60003,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &6256956892669881441 GameObject: m_ObjectHideFlags: 0 @@ -59881,6 +60073,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -59905,6 +60098,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1001 &6999573641241424516 PrefabInstance: m_ObjectHideFlags: 0 @@ -60062,7 +60256,9 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - m_RemovedComponents: [] + m_RemovedComponents: + - {fileID: 6999573642288568606, guid: 8590393c51194934a95cdc2075fc4dec, type: 3} + - {fileID: 6999573640440716766, guid: 8590393c51194934a95cdc2075fc4dec, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 8590393c51194934a95cdc2075fc4dec, type: 3} --- !u!4 &6999573641241424517 stripped Transform: @@ -60135,6 +60331,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60159,6 +60356,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!23 &7643328943036952926 MeshRenderer: m_ObjectHideFlags: 0 @@ -60174,6 +60372,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60200,6 +60399,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &7649001581117388135 MeshFilter: m_ObjectHideFlags: 0 @@ -60223,6 +60423,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60247,6 +60448,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &8037038874798551250 GameObject: m_ObjectHideFlags: 0 @@ -60294,6 +60496,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60318,6 +60521,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!23 &8284392456268054784 MeshRenderer: m_ObjectHideFlags: 0 @@ -60333,6 +60537,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60357,6 +60562,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!23 &8379924837567921489 MeshRenderer: m_ObjectHideFlags: 0 @@ -60372,6 +60578,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60396,6 +60603,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &8393955356175092067 MeshFilter: m_ObjectHideFlags: 0 @@ -60441,6 +60649,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60465,6 +60674,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!23 &8509506421963195749 MeshRenderer: m_ObjectHideFlags: 0 @@ -60480,6 +60690,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: @@ -60504,6 +60715,7 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!33 &8656279830196498237 MeshFilter: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CircleSegmentGenerator.cs b/Assets/Scripts/CircleSegmentGenerator.cs index 2347ff84b7a3811b77b32a0cabcbb19755467717..ce0ded896fbb84fdc9477aa16cc647cf34718b9d 100644 --- a/Assets/Scripts/CircleSegmentGenerator.cs +++ b/Assets/Scripts/CircleSegmentGenerator.cs @@ -1,5 +1,4 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(MeshFilter))] diff --git a/Assets/Scripts/HideUI.cs b/Assets/Scripts/HideUI.cs index 1719e1e5d490cd05f402ca8520a9f12e3222cde1..fdb33eced228aa81da415cd02a172c8c38fac7c0 100644 --- a/Assets/Scripts/HideUI.cs +++ b/Assets/Scripts/HideUI.cs @@ -1,6 +1,5 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; +using static CommunicationEvents; public class HideUI : MonoBehaviour { @@ -8,6 +7,11 @@ public class HideUI : MonoBehaviour public KeyCode Key = KeyCode.F1; //public KeyCode ScreenshotKey = KeyCode.F2; + public string + modifier, + modundo, + modredo; + public UnityStandardAssets.Characters.FirstPerson.FirstPersonController CamControl; public bool LockOnly = true; public MeshRenderer CursorRenderer; @@ -17,9 +21,9 @@ void Start() { if (!LockOnly) { - if(UICanvas==null) + if (UICanvas == null) UICanvas = GetComponentInChildren<Canvas>(); - bool camActive = !UICanvas.enabled; + bool camActive = !UICanvas.enabled; CamControl.enabled = camActive; CursorRenderer.enabled = camActive; } @@ -31,7 +35,6 @@ void Update() { if (Input.GetKeyDown(Key)) { - if (LockOnly) { CamControl.enabled = !CamControl.enabled; @@ -46,9 +49,16 @@ void Update() CamControl.enabled = camActive; CursorRenderer.enabled = camActive; } + } - + if (Input.GetButton(modifier)) + { + if (Input.GetButtonDown(modundo)) + Facts.undo(); + else if (Input.GetButtonDown(modredo)) + Facts.redo(); } + /* //Todo before capturing: Make directories "UFrameIT-Screenshots/Unity_ScreenCapture" in project folder else if (Input.GetKeyDown(ScreenshotKey)) { diff --git a/Assets/Scripts/HitWater.cs b/Assets/Scripts/HitWater.cs index f8c833ecbd92c1f4ee0a94e72c276aca819c3d9b..d981f84477bf5bae32c3e08a38d942c42371be44 100644 --- a/Assets/Scripts/HitWater.cs +++ b/Assets/Scripts/HitWater.cs @@ -1,12 +1,11 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class HitWater : MonoBehaviour { void OnControllerColliderHit(ControllerColliderHit hit) { - if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Water")) { + if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Water")) + { transform.position = new Vector3(-2.68f, 1f, 1.89f); } } diff --git a/Assets/Scripts/HoverText.cs b/Assets/Scripts/HoverText.cs index e3d07c9a4c07f8dc4e2bb48aaf4da3e454485598..6b13d8f2cd897c6c21fabc04ebfa458e22972ae1 100644 --- a/Assets/Scripts/HoverText.cs +++ b/Assets/Scripts/HoverText.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; using UnityEngine.EventSystems; public class HoverText : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler @@ -24,5 +22,5 @@ public void OnPointerExit(PointerEventData pointerEventData) TextTransform.gameObject.SetActive(false); } - + } diff --git a/Assets/Scripts/InteractionEngine/AlignText.cs b/Assets/Scripts/InteractionEngine/AlignText.cs index e59891e407388712b07d0655523dc747d9d68a7a..47706cb79a7670fe0609089ccfc3f4ff1faa9777 100644 --- a/Assets/Scripts/InteractionEngine/AlignText.cs +++ b/Assets/Scripts/InteractionEngine/AlignText.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class AlignText : MonoBehaviour { diff --git a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs index e38a240a28756860bf54abcfcf37c6d0365892f4..3cba5f0c5f7e0faf3b0a505cb3d0284fa934c507 100644 --- a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs +++ b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs @@ -59,7 +59,8 @@ public class AnimationEventWithUris : UnityEvent<List<string>> public static SignalEvent gameSucceededEvent = new SignalEvent(); public static SignalEvent gameNotSucceededEvent = new SignalEvent(); - + public static SignalEvent LevelReset = new SignalEvent(); + public static SignalEvent NewAssignmentEvent = new SignalEvent(); //TODO: Remove this event after CompletionsDemo isn't necessary anymore @@ -74,8 +75,8 @@ public class AnimationEventWithUris : UnityEvent<List<string>> //------------------------------------------------------------------------------------ //-------------------------------Global Variables------------------------------------- - //Global List of Facts - public static List<Fact> Facts = new List<Fact>(); + //Global Level-List of Facts + public static FactOrganizer Facts = new FactOrganizer(); public static bool ServerRunning = true; diff --git a/Assets/Scripts/InteractionEngine/Fact.cs b/Assets/Scripts/InteractionEngine/Fact.cs index fa5754df87ce58f5fd3013b4bfb433a8317f5649..bfc672fd3185c1c67cf4d97a30091987296cf3ab 100644 --- a/Assets/Scripts/InteractionEngine/Fact.cs +++ b/Assets/Scripts/InteractionEngine/Fact.cs @@ -4,6 +4,7 @@ using UnityEngine.Networking; using TMPro; using static JSONManager; +using static CommunicationEvents; public class ParsingDictionary { @@ -19,26 +20,64 @@ public class ParsingDictionary { } +public class AddFactResponse +{ + //class to Read AddFact Responses. + // public string factUri; + // public string factValUri; + public string uri; + + public static AddFactResponse sendAdd(string path, string body) + { + if (!CommunicationEvents.ServerRunning) + { + Debug.LogWarning("Server not running"); + return new AddFactResponse(); + } + Debug.Log(body); + //Put constructor parses stringbody to byteArray internally (goofy workaround) + UnityWebRequest www = UnityWebRequest.Put(path, body); + www.method = UnityWebRequest.kHttpVerbPOST; + www.SetRequestHeader("Content-Type", "application/json"); + www.timeout = 1; + + //TODO: implement real asynchronous communication ... + AsyncOperation op = www.SendWebRequest(); + while (!op.isDone) { } + if (www.isNetworkError || www.isHttpError) + { + Debug.LogWarning(www.error); + return new AddFactResponse(); + } + else + { + string answer = www.downloadHandler.text; + return JsonUtility.FromJson<AddFactResponse>(answer); + } + } +} + public abstract class Fact { - private int _id; + public GameObject Representation; + + public string backendURI; public string Label; public int Id { get { return _id; } set { - // if (_id == value) return; _id = value; - Label= ((Char)(64 + _id + 1)).ToString(); + Label = getLetter(_id); } } - public GameObject Representation; - public string backendURI; + private int _id; - public string format(float t) + + public void rename(string newLabel) { - return t.ToString("0.0000").Replace(',', '.'); + this.Label = newLabel; } //If FactType depends on other Facts, e.g. AngleFacts depend on 3 PointFacts @@ -48,6 +87,11 @@ public string format(float t) public abstract GameObject instantiateDisplay(GameObject prefab, Transform transform); + public virtual void delete() + { + //TODO: MMT + } + public abstract bool Equivalent(Fact f2); public abstract bool Equivalent(Fact f1, Fact f2); @@ -92,8 +136,8 @@ public AbstractLineFact(int pid1, int pid2, string backendURI) { this.Pid1 = pid1; this.Pid2 = pid2; - PointFact pf1 = CommunicationEvents.Facts.Find((x => x.Id == pid1)) as PointFact; - PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact; + PointFact pf1 = Facts[pid1] as PointFact; + PointFact pf2 = Facts[pid2] as PointFact; this.Dir = (pf2.Point - pf1.Point).normalized; this.backendURI = backendURI; } @@ -129,42 +173,6 @@ protected override bool EquivalentWrapped(AbstractLineFact f1, AbstractLineFact protected abstract bool EquivalentWrapped(T f1, T f2); } -public class AddFactResponse -{ - //class to Read AddFact Responses. - // public string factUri; - // public string factValUri; - public string uri; - - public static AddFactResponse sendAdd(string path, string body) - { - if (!CommunicationEvents.ServerRunning) - { - Debug.LogWarning("Server not running"); - return new AddFactResponse(); - } - Debug.Log(body); - //Put constructor parses stringbody to byteArray internally (goofy workaround) - UnityWebRequest www = UnityWebRequest.Put(path, body); - www.method = UnityWebRequest.kHttpVerbPOST; - www.SetRequestHeader("Content-Type", "application/json"); - www.timeout = 1; - - //TODO: implement real asynchronous communication ... - AsyncOperation op = www.SendWebRequest(); - while (!op.isDone) { } - if (www.isNetworkError || www.isHttpError) - { - Debug.LogWarning(www.error); - return new AddFactResponse(); - } - else - { - string answer = www.downloadHandler.text; - return JsonUtility.FromJson<AddFactResponse>(answer); - } - } -} //I am not sure if we ever need to attach these to an object, so one script for all for now... public class PointFact : FactWrappedCRTP<PointFact> @@ -256,8 +264,8 @@ public LineFact(int i, int pid1, int pid2) this.Id = i; this.Pid1 = pid1; this.Pid2 = pid2; - PointFact pf1 = CommunicationEvents.Facts.Find((x => x.Id == pid1)) as PointFact; - PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact; + PointFact pf1 = Facts[pid1] as PointFact; + PointFact pf2 = Facts[pid2] as PointFact; this.Dir = (pf2.Point - pf1.Point).normalized; //Label is currently set to Fact.setId @@ -293,13 +301,11 @@ public static LineFact parseFact(Scroll.ScrollFact fact) String uri = fact.@ref.uri; String pointAUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri; String pointBUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri; - if (CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointAUri)) && - CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointBUri))) - { - int pid1 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointAUri)).Id; - int pid2 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointBUri)).Id; + + if (Facts.searchURI(pointAUri, out int pid1) + && Facts.searchURI(pointBUri, out int pid2)) return new LineFact(pid1, pid2, uri); - } + //If dependent facts do not exist return null else { return null; @@ -309,8 +315,8 @@ public static LineFact parseFact(Scroll.ScrollFact fact) public override GameObject instantiateDisplay(GameObject prefab, Transform transform) { var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); - obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid1].Id); - obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid2].Id); + obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Pid1].Id); + obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Pid2].Id); obj.GetComponent<FactWrapper>().fact = this; return obj; } @@ -321,10 +327,10 @@ protected override bool EquivalentWrapped(LineFact f1, LineFact f2) //(f1.Pid1 == f2.Pid2 && f1.Pid2 == f2.Pid1)) return true; - PointFact p1f1 = (PointFact)CommunicationEvents.Facts[f1.Pid1]; - PointFact p2f1 = (PointFact)CommunicationEvents.Facts[f1.Pid2]; - PointFact p1f2 = (PointFact)CommunicationEvents.Facts[f2.Pid1]; - PointFact p2f2 = (PointFact)CommunicationEvents.Facts[f2.Pid2]; + PointFact p1f1 = (PointFact)Facts[f1.Pid1]; + PointFact p2f1 = (PointFact)Facts[f1.Pid2]; + PointFact p1f2 = (PointFact)Facts[f2.Pid1]; + PointFact p2f2 = (PointFact)Facts[f2.Pid2]; return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2)) ;//|| (p1f1.Equivalent(p2f2) && p2f1.Equivalent(p1f2)); @@ -340,8 +346,8 @@ public RayFact(int i, int pid1, int pid2) this.Id = i; this.Pid1 = pid1; this.Pid2 = pid2; - PointFact pf1 = CommunicationEvents.Facts.Find((x => x.Id == pid1)) as PointFact; - PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact; + PointFact pf1 = Facts[pid1] as PointFact; + PointFact pf2 = Facts[pid2] as PointFact; this.Dir = (pf2.Point - pf1.Point).normalized; string p1URI = pf1.backendURI; @@ -373,28 +379,20 @@ public static RayFact parseFact(Scroll.ScrollFact fact) { String pointAUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[0]).uri; String pointBUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[1]).uri; - if (CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointAUri)) && - CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointBUri))) - { - int pid1 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointAUri)).Id; - int pid2 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointBUri)).Id; + + if (Facts.searchURI(pointAUri, out int pid1) + && Facts.searchURI(pointBUri, out int pid2)) return new RayFact(pid1, pid2, uri); - } + //If dependent facts do not exist return null - else - { - return null; - } - } - else { - return null; } + return null; } public override GameObject instantiateDisplay(GameObject prefab, Transform transform) { var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(this.Id); - //obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid2].Id); + //obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts2[f.Pid2].Id); obj.GetComponent<FactWrapper>().fact = this; return obj; } @@ -404,10 +402,12 @@ protected override bool EquivalentWrapped(RayFact f1, RayFact f2) if (f1.Dir != f2.Dir && f1.Dir != -f2.Dir) return false; - PointFact p1f1 = (PointFact)CommunicationEvents.Facts[f1.Pid1]; - PointFact p1f2 = (PointFact)CommunicationEvents.Facts[f2.Pid1]; + PointFact p1f1 = (PointFact)Facts[f1.Pid1]; + PointFact p1f2 = (PointFact)Facts[f2.Pid1]; + PointFact p2f2 = (PointFact)Facts[f2.Pid2]; - return Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p1f2.Point); + return Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p1f2.Point) + && Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p2f2.Point); } } @@ -421,8 +421,8 @@ public OnLineFact(int i, int pid, int rid) this.Id = i; this.Pid = pid; this.Rid = rid; - PointFact pf = CommunicationEvents.Facts.Find((x => x.Id == pid)) as PointFact; - RayFact rf = CommunicationEvents.Facts.Find((x => x.Id == rid)) as RayFact; + PointFact pf = Facts[pid] as PointFact; + RayFact rf = Facts[rid] as RayFact; string pURI = pf.backendURI; string rURI = rf.backendURI; @@ -464,18 +464,14 @@ public static OnLineFact parseFact(Scroll.ScrollFact fact) String uri = fact.@ref.uri; String lineUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri; String pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri; - if (CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(lineUri)) && - CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointUri))) - { - int pid = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointUri)).Id; - int rid = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(lineUri)).Id; + + if (Facts.searchURI(lineUri, out int rid) + && Facts.searchURI(pointUri, out int pid)) return new OnLineFact(pid, rid, uri); - } + //If dependent facts do not exist return null else - { return null; - } } public override Boolean hasDependentFacts() @@ -491,8 +487,8 @@ public override int[] getDependentFactIds() public override GameObject instantiateDisplay(GameObject prefab, Transform transform) { var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); - obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid].Id); - obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Rid].Id); + obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Pid].Id); + obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Rid].Id); obj.GetComponent<FactWrapper>().fact = this; return obj; } @@ -507,10 +503,10 @@ protected override bool EquivalentWrapped(OnLineFact f1, OnLineFact f2) if (f1.Pid == f2.Pid && f1.Rid == f2.Rid) return true; - PointFact pf1 = (PointFact)CommunicationEvents.Facts[f1.Pid]; - RayFact rf1 = (RayFact)CommunicationEvents.Facts[f1.Rid]; - PointFact pf2 = (PointFact)CommunicationEvents.Facts[f2.Pid]; - RayFact rf2 = (RayFact)CommunicationEvents.Facts[f2.Rid]; + PointFact pf1 = (PointFact)Facts[f1.Pid]; + RayFact rf1 = (RayFact)Facts[f1.Rid]; + PointFact pf2 = (PointFact)Facts[f2.Pid]; + RayFact rf2 = (RayFact)Facts[f2.Rid]; return pf1.Equivalent(pf2) && rf1.Equivalent(rf2); } @@ -530,9 +526,9 @@ public AngleFact(int i, int pid1, int pid2, int pid3) this.Pid1 = pid1; this.Pid2 = pid2; this.Pid3 = pid3; - PointFact pf1 = CommunicationEvents.Facts.Find((x => x.Id == pid1)) as PointFact; - PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact; - PointFact pf3 = CommunicationEvents.Facts.Find((x => x.Id == pid3)) as PointFact; + PointFact pf1 = Facts[pid1] as PointFact; + PointFact pf2 = Facts[pid2] as PointFact; + PointFact pf3 = Facts[pid3] as PointFact; string p1URI = pf1.backendURI; string p2URI = pf2.backendURI; @@ -577,53 +573,33 @@ public AngleFact(int Pid1, int Pid2, int Pid3, string backendURI) public static AngleFact parseFact(Scroll.ScrollFact fact) { - String uri; + String uri = fact.@ref.uri; String pointAUri; String pointBUri; String pointCUri; - int pid1; - int pid2; - int pid3; //If angle is not a 90Degree-Angle if (fact.GetType().Equals(typeof(Scroll.ScrollValueFact))) { - uri = fact.@ref.uri; pointAUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri; pointBUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri; pointCUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[2]).uri; - //If dependent facts do not exist return null - if (!CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointAUri)) | - !CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointBUri)) | - !CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointCUri))) - { - return null; - } - - pid1 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointAUri)).Id; - pid2 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointBUri)).Id; - pid3 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointCUri)).Id; } //If angle is a 90Degree-Angle else { - uri = fact.@ref.uri; pointAUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).arguments[0]).uri; pointBUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).arguments[1]).uri; pointCUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).arguments[2]).uri; - //If dependent facts do not exist return null - if (!CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointAUri)) | - !CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointBUri)) | - !CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointCUri))) - { - return null; - } - - pid1 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointAUri)).Id; - pid2 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointBUri)).Id; - pid3 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointCUri)).Id; } - return new AngleFact(pid1, pid2, pid3, uri); + if (Facts.searchURI(pointAUri, out int pid1) + && Facts.searchURI(pointBUri, out int pid2) + && Facts.searchURI(pointCUri, out int pid3)) + + return new AngleFact(pid1, pid2, pid3, uri); + + else //If dependent facts do not exist return null + return null; } private MMTDeclaration generate90DegreeAngleDeclaration(float val, string p1URI, string p2URI, string p3URI) { @@ -680,9 +656,9 @@ public override int[] getDependentFactIds() public override GameObject instantiateDisplay(GameObject prefab, Transform transform) { var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); - obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid1].Id); - obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid2].Id); - obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid3].Id); + obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Pid1].Id); + obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Pid2].Id); + obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts[this.Pid3].Id); obj.GetComponent<FactWrapper>().fact = this; return obj; } @@ -698,12 +674,12 @@ protected override bool EquivalentWrapped(AngleFact f1, AngleFact f2) //(f1.Pid1 == f2.Pid3 && f1.Pid2 == f2.Pid2 && f1.Pid3 == f2.Pid1)) return true; - PointFact p1f1 = (PointFact)CommunicationEvents.Facts[f1.Pid1]; - PointFact p2f1 = (PointFact)CommunicationEvents.Facts[f1.Pid2]; - PointFact p3f1 = (PointFact)CommunicationEvents.Facts[f1.Pid3]; - PointFact p1f2 = (PointFact)CommunicationEvents.Facts[f2.Pid1]; - PointFact p2f2 = (PointFact)CommunicationEvents.Facts[f2.Pid2]; - PointFact p3f2 = (PointFact)CommunicationEvents.Facts[f2.Pid3]; + PointFact p1f1 = (PointFact)Facts[f1.Pid1]; + PointFact p2f1 = (PointFact)Facts[f1.Pid2]; + PointFact p3f1 = (PointFact)Facts[f1.Pid3]; + PointFact p1f2 = (PointFact)Facts[f2.Pid1]; + PointFact p2f2 = (PointFact)Facts[f2.Pid2]; + PointFact p3f2 = (PointFact)Facts[f2.Pid3]; return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2) && p3f1.Equivalent(p3f2)) ;//|| (p1f1.Equivalent(p3f2) && p2f1.Equivalent(p2f2) && p1f1.Equivalent(p3f2)); diff --git a/Assets/Scripts/InteractionEngine/FactManager.cs b/Assets/Scripts/InteractionEngine/FactManager.cs index fe5dcb7edd6527b98fa513a3bcc46e0ac1f36c8b..db0c9ecc47f187bf03c4452b73d307a99625235c 100644 --- a/Assets/Scripts/InteractionEngine/FactManager.cs +++ b/Assets/Scripts/InteractionEngine/FactManager.cs @@ -4,101 +4,61 @@ using TMPro; using UnityEngine; using static CommunicationEvents; + public class FactManager : MonoBehaviour { - public GameObject SmartMenu; private List<int> NextEmpties = new List<int>(); - // Start is called before the first frame update void Start() { - //We dont want to have this here anymore... - //CommunicationEvents.RemoveFactEvent.AddListener(DeleteFact); - NextEmpties.Add(0); } - // Update is called once per frame - void Update() + //TODO! communicate success + public static Fact AddFactIfNotFound(Fact fact, out bool exists, bool samestep) { - + return Facts[Facts.Add(fact, out exists, samestep)]; } - public static bool findFact(Fact search, out Fact found) + public PointFact AddPointFact(RaycastHit hit, int id, bool samestep = false) { - foreach (Fact f in CommunicationEvents.Facts) - { - if (f.GetType() == search.GetType() && f.Equivalent(search)) - { - found = f; - return true; - } - } - - found = search; - return false; + return (PointFact) AddFactIfNotFound(new PointFact(id, hit.point, hit.normal), out bool obsolete, samestep); } - public static void addFact(int id, Fact fact) + public PointFact AddPointFact(int id, Vector3 point, Vector3 normal, bool samestep = false) { - CommunicationEvents.Facts.Insert(id, fact); - //TODO (alt): insert in MMT if needed here/ on Invoke() - //TODO: remove Inovkes() elsewhere - CommunicationEvents.AddFactEvent.Invoke(fact); + return (PointFact) AddFactIfNotFound(new PointFact(id, point, normal), out bool obsolete, samestep); } - public static Fact AddFactIfNotFound(int id, Fact fact, out bool exists) + public OnLineFact AddOnLineFact(int pid, int lid, int id, bool samestep = false) { - if (exists = findFact(fact, out Fact res)) - { - //TODO: del 'fact' in MMT (alt.: s.TODO in addFact) - return res; - } - else - { - addFact(id, fact); - return fact; - } + return (OnLineFact)AddFactIfNotFound(new OnLineFact(id, pid, lid), out bool obsolete, samestep); } - public PointFact AddPointFact(RaycastHit hit, int id) + public LineFact AddLineFact(int pid1, int pid2, int id, bool samestep = false) { - return (PointFact) AddFactIfNotFound(id, new PointFact(id, hit.point, hit.normal), out bool obsolete); + return (LineFact)AddFactIfNotFound(new LineFact(id, pid1, pid2), out bool obsolete, samestep); } - public PointFact AddPointFact(int id, Vector3 point, Vector3 normal) + public RayFact AddRayFact(int pid1, int pid2, int id, bool samestep = false) { - return (PointFact) AddFactIfNotFound(id, new PointFact(id, point, normal), out bool obsolete); - } - - public OnLineFact AddOnLineFact(int pid, int lid, int id) - { - return (OnLineFact)AddFactIfNotFound(id, new OnLineFact(id, pid, lid), out bool obsolete); - } - - public LineFact AddLineFact(int pid1, int pid2, int id) - { - return (LineFact)AddFactIfNotFound(id, new LineFact(id, pid1, pid2), out bool obsolete); - } - - public RayFact AddRayFact(int pid1, int pid2, int id) - { - RayFact rayFact = (RayFact)AddFactIfNotFound(id, new RayFact(id, pid1, pid2), out bool exists); + RayFact rayFact = (RayFact)AddFactIfNotFound(new RayFact(id, pid1, pid2), out bool exists, samestep); if (exists) return rayFact; //Add all PointFacts on Ray as OnLineFacts PointFact rayP1 = (PointFact)Facts[rayFact.Pid1]; + PointFact rayP2 = (PointFact)Facts[rayFact.Pid2]; int layerMask = LayerMask.GetMask("Point"); RaycastHit[] hitsA = Physics.RaycastAll(rayP1.Point, rayFact.Dir, Mathf.Infinity, layerMask); - RaycastHit[] hitsB = Physics.RaycastAll(rayP1.Point, -rayFact.Dir, Mathf.Infinity, layerMask); + RaycastHit[] hitsB = Physics.RaycastAll(rayP2.Point, -rayFact.Dir, Mathf.Infinity, layerMask); void AddHitIfOnLine(RaycastHit hit) { if (Math3d.IsPointApproximatelyOnLine(rayP1.Point, rayFact.Dir, hit.transform.position)) { - AddOnLineFact(hit.transform.gameObject.GetComponent<FactObject>().Id, rayFact.Id, GetFirstEmptyID()); + AddOnLineFact(hit.transform.gameObject.GetComponent<FactObject>().Id, rayFact.Id, GetFirstEmptyID(), true); } } @@ -108,23 +68,17 @@ void AddHitIfOnLine(RaycastHit hit) foreach (RaycastHit hit in hitsB) AddHitIfOnLine(hit); + // for good measure + AddOnLineFact(rayFact.Pid1, rayFact.Id, GetFirstEmptyID(), true); + AddOnLineFact(rayFact.Pid2, rayFact.Id, GetFirstEmptyID(), true); + return rayFact; } - public AngleFact AddAngleFact(int pid1, int pid2, int pid3, int id) - { - return (AngleFact)AddFactIfNotFound(id, new AngleFact(id, pid1, pid2, pid3), out bool obsolete); - } - - public void DeleteFact(Fact fact) + public AngleFact AddAngleFact(int pid1, int pid2, int pid3, int id, bool samestep = false) { - if (Facts.Contains(fact)) { - NextEmpties.Add(fact.Id); - //Facts.RemoveAt(fact.Id); - Facts.Remove(Facts.Find(x => x.Id == fact.Id)); - CommunicationEvents.RemoveFactEvent.Invoke(fact); - } + return (AngleFact)AddFactIfNotFound(new AngleFact(id, pid1, pid2, pid3), out bool obsolete, samestep); } public int GetFirstEmptyID() diff --git a/Assets/Scripts/InteractionEngine/FactObject.cs b/Assets/Scripts/InteractionEngine/FactObject.cs index 8d983829808102d5b751fc85a6a305308c10ef40..fdde5741cbe988b6d4fc07300d04e8ca5ac8060f 100644 --- a/Assets/Scripts/InteractionEngine/FactObject.cs +++ b/Assets/Scripts/InteractionEngine/FactObject.cs @@ -1,11 +1,9 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class FactObject : MonoBehaviour { //object that can represent arbitrary facts //used to access entry in global Fact Collection public int Id; - + } diff --git a/Assets/Scripts/InteractionEngine/FactSpawner.cs b/Assets/Scripts/InteractionEngine/FactSpawner.cs index 8a59091650cd4c02ea085386d348cf983e8925d4..8f3457d799cf4c83b4edad05a16e5384ef82a113 100644 --- a/Assets/Scripts/InteractionEngine/FactSpawner.cs +++ b/Assets/Scripts/InteractionEngine/FactSpawner.cs @@ -8,7 +8,7 @@ public class FactSpawner : MonoBehaviour { private GameObject FactRepresentation; - private Camera camera; + //private Camera camera; void Start() { @@ -21,7 +21,7 @@ void Start() //Default FactRepresenation = Sphere-Prefab for Points this.FactRepresentation = (GameObject) Resources.Load("Prefabs/Sphere", typeof(GameObject)); - camera = Camera.main; + //camera = Camera.main; } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs index 0243c99b2aa8e86d9dca5a36ecca343e81c66020..e8e8e4a56cc6b2235107783c101a08544cb3af6f 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs @@ -27,10 +27,14 @@ public class AngleTool : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Angle Mode"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } //Initialize Gadget when enabled AND activated @@ -131,11 +135,12 @@ public void ActivateCurveDrawing() public void UpdateCurveDrawing(Vector3 currentPosition) { - + //TODO! PERF O(n) //Find the nearest of all potential third points PointFact nearestPoint = null; - foreach (Fact fact in Facts) + foreach (var entry in Facts) { + Fact fact = entry.Value; if (fact is PointFact && fact.Id != angleModeFirstPointSelected.Id && fact.Id != angleModeSecondPointSelected.Id && nearestPoint == null) nearestPoint = (PointFact)fact; else if (fact is PointFact && fact.Id != angleModeFirstPointSelected.Id && fact.Id != angleModeSecondPointSelected.Id && (nearestPoint.Point - currentPosition).magnitude > (((PointFact)fact).Point - currentPosition).magnitude) diff --git a/Assets/Scripts/InteractionEngine/Gadgets/ExtraGadget.cs b/Assets/Scripts/InteractionEngine/Gadgets/ExtraGadget.cs index c37ee9b7324466fbdfb1eb553451f52dc5bdad7b..68835b94ccaf2fe6879aa2ee582222e8551d5314 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/ExtraGadget.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/ExtraGadget.cs @@ -1,7 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using static CommunicationEvents; +using UnityEngine; public class ExtraGadget : Gadget { @@ -9,10 +6,14 @@ public class ExtraGadget : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Extra Mode"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } void OnEnable() diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs b/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs index d9705bddd9478dac40ed94c82e7235bf6fa81468..c4981d5699c4fa85815358ad1450ee14d8f14e33 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Gadget.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class Gadget : MonoBehaviour @@ -14,10 +12,12 @@ public class Gadget : MonoBehaviour void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + CommunicationEvents.TriggerEvent.AddListener(OnHit); } - public virtual void OnHit(RaycastHit hit){} + public virtual void OnHit(RaycastHit hit) { } } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/GadgetManager.cs b/Assets/Scripts/InteractionEngine/Gadgets/GadgetManager.cs index 96ff39acbae7c5bbec5b357911eb62f64f91a359..9e8b43b97ec4418754e874f75765c179e39f87ec 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/GadgetManager.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/GadgetManager.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; using UnityEngine.UI; public class GadgetManager : MonoBehaviour @@ -16,7 +14,8 @@ void Start() gadgets = GetComponentsInChildren<Gadget>(); Debug.Log(gadgets.Length); - for (int i = 0; i < gadgets.Length; i++) { + for (int i = 0; i < gadgets.Length; i++) + { gadgets[i].id = i; //Create Buttons and add them to UI CreateButton(gadgets[i]); @@ -26,7 +25,8 @@ void Start() gadgets[i].gameObject.SetActive(true); activeGadget = gadgets[i]; } - else { + else + { gadgets[i].gameObject.SetActive(false); } } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs index b3cc159e7a3908c0da7a55854803abfe32dcf8e0..f7b2dde78aaaf4bf31eaaba6501727e2179bf7ba 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs @@ -18,10 +18,14 @@ public class LineTool : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Line Mode"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } //Initialize Gadget when enabled AND activated @@ -56,7 +60,8 @@ public override void OnHit(RaycastHit hit) } //if we hit the top snap zone - else if (hit.transform.gameObject.tag == "SnapZone") + //TODO: check behaviour + else if (hit.transform.gameObject.CompareTag("SnapZone")) { if (this.LineModeIsFirstPointSelected) { @@ -69,11 +74,10 @@ public override void OnHit(RaycastHit hit) int idB = this.LineModeFirstPointSelected.Id; int idC = FactManager.GetFirstEmptyID(); FactManager.AddPointFact(hit, idC); - this.DeactivateLineDrawing(); //Create LineFact FactManager.AddAngleFact(idA, idB, idC, FactManager.GetFirstEmptyID()); - this.LineModeIsFirstPointSelected = false; - this.LineModeFirstPointSelected = null; + + this.ResetGadget(); } } } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs index 3b1d83456fb1a6aff1e6400e8522526f4b86e44a..1e0e9af2e0fdaa8ef34e3fa7ac27e6174a009d88 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/LotTool.cs @@ -23,10 +23,14 @@ public class LotTool : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Lot Mode"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } //Initialize Gadget when enabled AND activated @@ -43,14 +47,14 @@ void OnDisable() public override void OnHit(RaycastHit hit) { - void CreateRayAndAngles(int pidIntersectionPoint, int pidLotPoint) + void CreateRayAndAngles(int pidIntersectionPoint, int pidLotPoint, bool samestep) { - FactManager.AddRayFact(pidIntersectionPoint, pidLotPoint, FactManager.GetFirstEmptyID()); + FactManager.AddRayFact(pidIntersectionPoint, pidLotPoint, FactManager.GetFirstEmptyID(), samestep); //TODO: create at all? / for all points on basline? FactManager.AddAngleFact( this.LotModeLineSelected.Pid1 == pidIntersectionPoint ? this.LotModeLineSelected.Pid2 : this.LotModeLineSelected.Pid1, - pidIntersectionPoint, pidLotPoint, FactManager.GetFirstEmptyID()); + pidIntersectionPoint, pidLotPoint, FactManager.GetFirstEmptyID(), true); } if (!this.isActiveAndEnabled) return; @@ -63,7 +67,7 @@ void CreateRayAndAngles(int pidIntersectionPoint, int pidLotPoint) //TODO: which normal? FactManager.AddPointFact(pidLotPoint, LotPoint, hit.normal); - CreateRayAndAngles(this.LotModeIntersectionPoint.Id, pidLotPoint); + CreateRayAndAngles(this.LotModeIntersectionPoint.Id, pidLotPoint, true); this.ResetGadget(); } @@ -87,9 +91,9 @@ void CreateRayAndAngles(int pidIntersectionPoint, int pidLotPoint) FactManager.AddPointFact(intersectionId, intersectionPoint, this.LotModeLineHit.normal); if(this.LotModeLineSelected is RayFact) //Add OnLineFact only on Ray not Line - FactManager.AddOnLineFact(intersectionId, this.LotModeLineSelected.Id, FactManager.GetFirstEmptyID()); + FactManager.AddOnLineFact(intersectionId, this.LotModeLineSelected.Id, FactManager.GetFirstEmptyID(), true); - CreateRayAndAngles(intersectionId, tempFact.Id); + CreateRayAndAngles(intersectionId, tempFact.Id, true); this.ResetGadget(); } @@ -103,7 +107,7 @@ void CreateRayAndAngles(int pidIntersectionPoint, int pidLotPoint) //Activate LineDrawing for preview this.LotModeIsLineSelected = true; this.LotModeLineSelected = tempFact as AbstractLineFact; - this.LotModeLinePointA = (PointFact)CommunicationEvents.Facts[this.LotModeLineSelected.Pid1]; + this.LotModeLinePointA = (PointFact) Facts[this.LotModeLineSelected.Pid1]; this.LotModeLineHit = hit; this.ActivateLineDrawing(); } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs b/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs index 4d96a17d4b7e69441ffc2c96fcbeb20e1bad0a1a..83dcf7d0bbde34ab42b570a30aaa00877db21a39 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Pendulum.cs @@ -16,10 +16,14 @@ public class Pendulum : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Pendulum"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } void OnEnable() diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs b/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs index 08e13e8e901bff21bfdfcbb38abe0a45dc7ffd66..be9f29ac661eb14266257aaa005d0948e41ddcda 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Pointer.cs @@ -9,10 +9,14 @@ public class Pointer : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Point Mode"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } void OnEnable() @@ -29,7 +33,7 @@ public override void OnHit(RaycastHit hit) if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ray")) { - FactManager.AddOnLineFact(pid, hit.transform.GetComponent<FactObject>().Id, FactManager.GetFirstEmptyID()); + FactManager.AddOnLineFact(pid, hit.transform.GetComponent<FactObject>().Id, FactManager.GetFirstEmptyID(), true); } } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs b/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs index d1e4896e0931a19a88274a06a1140c2f3febe7dd..1de81facb47ab7629bdfc7dfc7fde1a43bb0dbcf 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs @@ -18,10 +18,14 @@ public class Tape : Gadget void Awake() { - if (FactManager == null) FactManager = GameObject.FindObjectOfType<FactManager>(); - CommunicationEvents.TriggerEvent.AddListener(OnHit); - if (this.Cursor == null) this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + if (FactManager == null) + FactManager = GameObject.FindObjectOfType<FactManager>(); + + if (this.Cursor == null) + this.Cursor = GameObject.FindObjectOfType<WorldCursor>(); + this.UiName = "Distance Mode"; + CommunicationEvents.TriggerEvent.AddListener(OnHit); } //Initialize Gadget when enabled AND activated @@ -58,23 +62,10 @@ public override void OnHit(RaycastHit hit) this.ActivateLineDrawing(); } } - /* - //if we want to spawn a new point - else if (Input.GetKey(KeyCode.LeftShift)) - { - if (this.TapeModeIsFirstPointSelected) - { - - this.DeactivateLineDrawing(); - SmallRocket(hit, this.TapeModeFirstPointSelected.Id); - - this.ResetGadget(); - } - } - */ //if we hit the top snap zone - else if (hit.transform.gameObject.tag == "SnapZone") + //TODO: check behaviour + else if (hit.transform.gameObject.CompareTag("SnapZone")) { if (this.TapeModeIsFirstPointSelected) { @@ -87,11 +78,10 @@ public override void OnHit(RaycastHit hit) int idB = this.TapeModeFirstPointSelected.Id; int idC = FactManager.GetFirstEmptyID(); FactManager.AddPointFact(hit, idC); - this.DeactivateLineDrawing(); //Create LineFact - FactManager.AddAngleFact(idA, idB, idC, FactManager.GetFirstEmptyID()); - this.TapeModeIsFirstPointSelected = false; - this.TapeModeFirstPointSelected = null; + FactManager.AddAngleFact(idA, idB, idC, FactManager.GetFirstEmptyID(), true); + + this.ResetGadget(); } } } @@ -108,27 +98,6 @@ public override void OnHit(RaycastHit hit) } } - /* - //Creating 90-degree Angles - public void SmallRocket(RaycastHit hit, int idA) - { - //enable collider to measure angle to the treetop - int idB = this.GetFirstEmptyID(); - CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(hit, idB)); - Facts[idB].Representation.GetComponentInChildren<Collider>().enabled = true; - //third point with unknown height - int idC = FactManager.GetFirstEmptyID(); - var skyHit = hit; - skyHit.point = (Facts[idA] as PointFact).Point + Vector3.up * 20; - CommunicationEvents.AddFactEvent.Invoke(FactManager.AddPointFact(skyHit, idC)); - //lines - CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(idA, idB, this.GetFirstEmptyID())); - //lines - CommunicationEvents.AddFactEvent.Invoke(FactManager.AddLineFact(idA, idC, this.GetFirstEmptyID())); - //90degree angle - CommunicationEvents.AddFactEvent.Invoke(FactManager.AddAngleFact(idB, idA, idC, GetFirstEmptyID())); - }*/ - void Update() { if (!this.isActiveAndEnabled) return; diff --git a/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs b/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs index a3c549b5baecbbb06fdf0b1ea7b4c2fa9563095c..03f1a42ef532c859a6c4b22598329e53fa30968d 100644 --- a/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs +++ b/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs @@ -9,7 +9,7 @@ public class ImageHintAnimation : MonoBehaviour private Color animationStartColor; private Color animationEndColor; - + private float animateDuration; private bool animating = false; private float timer = 0; @@ -70,7 +70,8 @@ private void Reset() imageToChange.color = imageToChangeDefaultColor; } - private void updateAnimationParameters() { + private void updateAnimationParameters() + { animationStartColor = globalSettings.hintAnimationStartColor; animationEndColor = globalSettings.hintAnimationEndColor; animateDuration = globalSettings.hintAnimationDuration; diff --git a/Assets/Scripts/InteractionEngine/MMTInterface.cs b/Assets/Scripts/InteractionEngine/MMTInterface.cs index d76c0d52fa9c7ad98c371692c27ae94291f2ef66..7d97d9d8b06b797a395c2b2b9aa771b3587ef4d4 100644 --- a/Assets/Scripts/InteractionEngine/MMTInterface.cs +++ b/Assets/Scripts/InteractionEngine/MMTInterface.cs @@ -1,8 +1,4 @@ -using System; -using System.Diagnostics; -using System.ComponentModel; -using System.Collections; -using System.Collections.Generic; +using System.Diagnostics; using UnityEngine; public class MMTInterface : MonoBehaviour @@ -12,7 +8,7 @@ public class MMTInterface : MonoBehaviour // Start is called before the first frame update - + void Start() { //Start the mmt.bat for carrying out http-Requests @@ -27,9 +23,9 @@ void Start() mmtServerProcess = Process.Start(mmtServerProcessInfo); */ - // CommunicationEvents.AddPointEvent.AddListener(AddFactToMMT); - // CommunicationEvents.RemoveEvent.AddListener(RemoveFactFromMMT); - + // CommunicationEvents.AddPointEvent.AddListener(AddFactToMMT); + // CommunicationEvents.RemoveEvent.AddListener(RemoveFactFromMMT); + } /* @@ -44,5 +40,5 @@ void RemoveFactFromMMT( int id) UnityEngine.Debug.Log("remove fact"+ id); } */ - + } diff --git a/Assets/Scripts/InteractionEngine/MeshRendererHintAnimation.cs b/Assets/Scripts/InteractionEngine/MeshRendererHintAnimation.cs index f11ef71b1aec40fb97be9da76788e53176c1d5cb..b0989c5f18d28f69c53f3dc0b91abec1abe6f669 100644 --- a/Assets/Scripts/InteractionEngine/MeshRendererHintAnimation.cs +++ b/Assets/Scripts/InteractionEngine/MeshRendererHintAnimation.cs @@ -6,7 +6,7 @@ public class MeshRendererHintAnimation : MonoBehaviour { private MeshRenderer meshRendererToChange; private Color meshRendererToChangeDefaultColor; - + private Color animationStartColor; private Color animationEndColor; @@ -26,13 +26,15 @@ void Start() // Update is called once per frame void Update() { - if (animating) { + if (animating) + { this.timer += Time.deltaTime; Animate(); } } - public void AnimationTrigger() { + public void AnimationTrigger() + { if (meshRendererToChange != null) { updateAnimationParameters(); @@ -40,14 +42,16 @@ public void AnimationTrigger() { } } - private void Animate() { + private void Animate() + { if (timer >= animateDuration) { animating = false; timer = 0; meshRendererToChange.material.color = meshRendererToChangeDefaultColor; } - else { + else + { meshRendererToChange.material.color = Color.Lerp(animationStartColor, animationEndColor, Mathf.PingPong(Time.time, 1)); } } diff --git a/Assets/Scripts/InteractionEngine/SmartMenu.cs b/Assets/Scripts/InteractionEngine/SmartMenu.cs index 4c3ef4c46271ecb459e82645f0c505676029fa69..1146bf0de3fba2045295f991286c9dd0579a07fb 100644 --- a/Assets/Scripts/InteractionEngine/SmartMenu.cs +++ b/Assets/Scripts/InteractionEngine/SmartMenu.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class SmartMenu : MonoBehaviour { @@ -9,9 +7,7 @@ public class SmartMenu : MonoBehaviour public void DestroyObject() { - FactManager.DeleteFact(CommunicationEvents.Facts[transform.parent.GetComponent<FactObject>().Id]); - // CommunicationEvents.RemoveFactEvent.Invoke(CommunicationEvents.Facts[transform.parent.GetComponent<FactObject>().Id]); - + CommunicationEvents.Facts.Remove(CommunicationEvents.Facts[transform.parent.GetComponent<FactObject>().Id]); } diff --git a/Assets/Scripts/InteractionEngine/ToolModeText.cs b/Assets/Scripts/InteractionEngine/ToolModeText.cs index ddb6eecbc2b975a3e831b54758575f9090312b80..101e7d54aea71f2ce2b5dceba66c32aa36a61c26 100644 --- a/Assets/Scripts/InteractionEngine/ToolModeText.cs +++ b/Assets/Scripts/InteractionEngine/ToolModeText.cs @@ -1,7 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; +using UnityEngine; public class ToolModeText : MonoBehaviour { @@ -12,7 +9,8 @@ void Start() CommunicationEvents.ToolModeChangedEvent.AddListener(OnToolModeChanged); } - void OnToolModeChanged(int id) { + void OnToolModeChanged(int id) + { //When ToolMode changes: Change Text of active gadget gameObject.GetComponentInChildren<UnityEngine.UI.Text>().text = GadgetManager.gadgets[id].UiName; diff --git a/Assets/Scripts/InteractionEngine/WorldCursor.cs b/Assets/Scripts/InteractionEngine/WorldCursor.cs index ee3670b813a592ffbe2511ef90d56583ba48cbb3..44e9b3f54372ab444fda95016e8b1ffedfd1ac20 100644 --- a/Assets/Scripts/InteractionEngine/WorldCursor.cs +++ b/Assets/Scripts/InteractionEngine/WorldCursor.cs @@ -89,8 +89,8 @@ void Update() || Hit.collider.gameObject.layer == LayerMask.NameToLayer("Line")) { int id = Hit.collider.gameObject.GetComponent<FactObject>().Id; - AbstractLineFact lineFact = CommunicationEvents.Facts.Find((x => x.Id == id)) as AbstractLineFact; - PointFact p1 = CommunicationEvents.Facts.Find((x => x.Id == lineFact.Pid1)) as PointFact; + AbstractLineFact lineFact = CommunicationEvents.Facts[id] as AbstractLineFact; + PointFact p1 = CommunicationEvents.Facts[lineFact.Pid1] as PointFact; Hit.point = Math3d.ProjectPointOnLine(p1.Point, lineFact.Dir, Hit.point); CheckMouseButtons(true,true); @@ -102,7 +102,6 @@ void Update() CheckMouseButtons(true); } - transform.position = Hit.point; transform.up = Hit.normal; diff --git a/Assets/Scripts/InteractionEngine/ZZZ_CompletionDemo.cs b/Assets/Scripts/InteractionEngine/ZZZ_CompletionDemo.cs index ac7455c477c2eea08de3d41d41bcec258df2ea0e..a2784b93b85fa091bc7ad2cfc341049e8829c04f 100644 --- a/Assets/Scripts/InteractionEngine/ZZZ_CompletionDemo.cs +++ b/Assets/Scripts/InteractionEngine/ZZZ_CompletionDemo.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; using TMPro; using UnityEngine; using static CommunicationEvents; @@ -47,7 +46,8 @@ void Update() } - public void CompletionDemo() { + public void CompletionDemo() + { FactManager.AddPointFact(point1, 0); FactManager.AddPointFact(point2, 1); FactManager.AddPointFact(point3, 2); diff --git a/Assets/Scripts/InventoryStuff/DisplayFacts.cs b/Assets/Scripts/InventoryStuff/DisplayFacts.cs index 68c35a2b161b8da8126f006b8ee45a018d77e90d..eace9107740d0a3409bdfd36466f3c1808cc9707 100644 --- a/Assets/Scripts/InventoryStuff/DisplayFacts.cs +++ b/Assets/Scripts/InventoryStuff/DisplayFacts.cs @@ -40,6 +40,7 @@ void Start() number_of_Column = Mathf.Max(1, (int)(rect.rect.width / prefab_Point.GetComponent<RectTransform>().rect.width) - 1); AddFactEvent.AddListener(AddFact); + RemoveFactEvent.AddListener(RemoveFact); AnimateExistingFactEvent.AddListener(AnimateFact); } @@ -50,6 +51,12 @@ public void AddFact(Fact fact) { displayedFacts.Add(fact.backendURI, obj); } + public void RemoveFact(Fact fact) + { + GameObject.Destroy(displayedFacts[fact.backendURI]); + displayedFacts.Remove(fact.backendURI); + } + public void AnimateFact(Fact fact) { var factIcon = displayedFacts[fact.backendURI]; factIcon.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger(); diff --git a/Assets/Scripts/InventoryStuff/DisplayScrolls.cs b/Assets/Scripts/InventoryStuff/DisplayScrolls.cs index dcad7c8de721dd579ee9646d4581dff91d1446cb..ad3b639e3c0ace2641a14ddcbb8cf0e9f6e34670 100644 --- a/Assets/Scripts/InventoryStuff/DisplayScrolls.cs +++ b/Assets/Scripts/InventoryStuff/DisplayScrolls.cs @@ -1,8 +1,8 @@ using System.Collections; using System.Collections.Generic; using System.IO; -using UnityEngine; using TMPro; +using UnityEngine; using UnityEngine.Networking; public class DisplayScrolls : MonoBehaviour @@ -36,10 +36,10 @@ public Vector3 GetPosition(int i) return new Vector3(x_Start + (X_Pacece_Between_Items * (i % number_of_Column)), y_Start + (-y_Pacece_Between_Items * (i / number_of_Column)), 0f); } - /* [System.Serializable] - class ScrollArrayWrapper { - public Scroll[] Scrolls; - };*/ + /* [System.Serializable] + class ScrollArrayWrapper { + public Scroll[] Scrolls; + };*/ // Start is called before the first frame update void Start() @@ -57,22 +57,25 @@ void Start() } - IEnumerator getScrollsfromServer() { + IEnumerator getScrollsfromServer() + { //Try /scroll/listAll endpoint when scroll/list is not working UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list"); //Postman-Echo-Mock //UnityWebRequest request = UnityWebRequest.Get("https://019a8ea5-843a-498b-8d0c-778669aef987.mock.pstmn.io/get"); - for (int i = 0; i < this.tryScrollListTimes; i++) { + for (int i = 0; i < this.tryScrollListTimes; i++) + { request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list"); request.method = UnityWebRequest.kHttpVerbGET; yield return request.Send(); if (request.isNetworkError || request.isHttpError) { Debug.LogWarning(request.error); - Debug.Log("GET Scroll/list failed. Attempt: " + (i+1).ToString()); + Debug.Log("GET Scroll/list failed. Attempt: " + (i + 1).ToString()); } - else { + else + { break; } } @@ -89,7 +92,7 @@ IEnumerator getScrollsfromServer() { CommunicationEvents.ServerRunning = true; string jsonString = request.downloadHandler.text; Debug.Log("JsonString from Server: \n" + jsonString); - if(jsonString.Equals("[]")) + if (jsonString.Equals("[]")) jsonString = File.ReadAllText(Application.streamingAssetsPath + "/scrolls.json"); Debug.Log("Used JsonString: \n" + jsonString); //scroll display not yet implemented; @@ -97,7 +100,7 @@ IEnumerator getScrollsfromServer() { BuildScrolls(jsonString); } } - + void BuildScrolls(string jsonString) { var scrolls = Scroll.FromJSON(jsonString); @@ -114,9 +117,9 @@ void BuildScrolls(string jsonString) obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.scrolls[i].label; ScrollButtons[i] = obj; } - + Scroll preferredStartScroll = this.scrolls.Find(x => x.label.Equals(preferredStartScrollName)); - if(preferredStartScroll != null) + if (preferredStartScroll != null) this.DetailScreen.GetComponent<ScrollDetails>().setScroll(preferredStartScroll); } } diff --git a/Assets/Scripts/InventoryStuff/DragHandling.cs b/Assets/Scripts/InventoryStuff/DragHandling.cs index 09791e49bb9331751ce8cd50d407d52c2700a931..878cc591d30553d33a2737d37226339bf4411900 100644 --- a/Assets/Scripts/InventoryStuff/DragHandling.cs +++ b/Assets/Scripts/InventoryStuff/DragHandling.cs @@ -1,14 +1,14 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; using UnityEngine.EventSystems; public class DragHandling : MonoBehaviour, IDragHandler, IEndDragHandler { private Vector3 StartingPosition; private bool dragged = false; - public void OnDrag(PointerEventData eventData){ - if(! dragged ){ + public void OnDrag(PointerEventData eventData) + { + if (!dragged) + { StartingPosition = transform.localPosition; GetComponent<CanvasGroup>().blocksRaycasts = false; dragged = true; @@ -16,21 +16,22 @@ public void OnDrag(PointerEventData eventData){ transform.position = Input.mousePosition; } - public void OnEndDrag(PointerEventData eventData){ + public void OnEndDrag(PointerEventData eventData) + { transform.localPosition = StartingPosition; - GetComponent<CanvasGroup>().blocksRaycasts = true ; + GetComponent<CanvasGroup>().blocksRaycasts = true; dragged = false; - } + } // Start is called before the first frame update void Start() { - + } // Update is called once per frame void Update() { - + } } diff --git a/Assets/Scripts/InventoryStuff/DropHandling.cs b/Assets/Scripts/InventoryStuff/DropHandling.cs index 39c2e70b6c40f074e0e5b1554bfa69f6823570fb..b9f19cf42b830341f91178032088127f4dd1a33f 100644 --- a/Assets/Scripts/InventoryStuff/DropHandling.cs +++ b/Assets/Scripts/InventoryStuff/DropHandling.cs @@ -6,16 +6,17 @@ public class DropHandling : MonoBehaviour, IDropHandler, IPointerClickHandler GameObject current; public Fact currentFact; - public void OnDrop(PointerEventData eventData){ - + public void OnDrop(PointerEventData eventData) + { + var scrollFact = gameObject.GetComponent<RenderedScrollFact>(); - Debug.Log(eventData.pointerDrag.GetComponent<FactWrapper>().fact.Label+ " was dropped on " - + gameObject.name+ " " +scrollFact.ID + "/" + - ScrollDetails.ParameterDisplays.Count+" label: "+scrollFact.Label); - + Debug.Log(eventData.pointerDrag.GetComponent<FactWrapper>().fact.Label + " was dropped on " + + gameObject.name + " " + scrollFact.ID + "/" + + ScrollDetails.ParameterDisplays.Count + " label: " + scrollFact.Label); + Destroy(current); - current = Instantiate(eventData.pointerDrag,Vector3.zero, Quaternion.identity); + current = Instantiate(eventData.pointerDrag, Vector3.zero, Quaternion.identity); //Set imageToChangeDefaultColor of current: Fix so that current won't take the color //the dragged item was having during animation current.GetComponent<ImageHintAnimation>().imageToChangeDefaultColor = eventData.pointerDrag.GetComponent<ImageHintAnimation>().imageToChangeDefaultColor; @@ -29,11 +30,11 @@ public void OnDrop(PointerEventData eventData){ CommunicationEvents.NewAssignmentEvent.Invoke(); } - public void OnPointerClick(PointerEventData eventData) { + public void OnPointerClick(PointerEventData eventData) + { Destroy(current); currentFact = null; CommunicationEvents.NewAssignmentEvent.Invoke(); } } - \ No newline at end of file diff --git a/Assets/Scripts/InventoryStuff/FactWrapper.cs b/Assets/Scripts/InventoryStuff/FactWrapper.cs index fda2652c27ba48aa6aa7bccdef5f1ffccec0cfb6..559831d6b476003eb1c4dc4fb86d2471168151df 100644 --- a/Assets/Scripts/InventoryStuff/FactWrapper.cs +++ b/Assets/Scripts/InventoryStuff/FactWrapper.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class FactWrapper : MonoBehaviour { diff --git a/Assets/Scripts/InventoryStuff/PointWrapper.cs b/Assets/Scripts/InventoryStuff/PointWrapper.cs index a0738d5d85c1aaccee70c66957aadbbc56b23475..a8da0acd5943d0d223f7cd13b2eaa03b34e2e9b5 100644 --- a/Assets/Scripts/InventoryStuff/PointWrapper.cs +++ b/Assets/Scripts/InventoryStuff/PointWrapper.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class PointWrapper : MonoBehaviour { diff --git a/Assets/Scripts/InventoryStuff/PythagorasScript.cs b/Assets/Scripts/InventoryStuff/PythagorasScript.cs index 1cc4d56d0aaeb206115cef005ad538f4a306637a..0b7537d1d9fce9776263e1d6b0c02cfaffbd0775 100644 --- a/Assets/Scripts/InventoryStuff/PythagorasScript.cs +++ b/Assets/Scripts/InventoryStuff/PythagorasScript.cs @@ -1,21 +1,24 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; public class PythagorasScript : MonoBehaviour { private Dictionary<string, Fact> items = new Dictionary<string, Fact>(); - public void putFact(string name, Fact obj) { - if (this.items.ContainsKey(name)) { + public void putFact(string name, Fact obj) + { + if (this.items.ContainsKey(name)) + { this.items.Remove(name); } this.items.Add(name, obj); } - public void doMagic() { + public void doMagic() + { Dictionary<string, Fact>.Enumerator enumerator = this.items.GetEnumerator(); - while (enumerator.MoveNext()){ + while (enumerator.MoveNext()) + { Debug.Log(enumerator.Current.Key + " is mapped to " + enumerator.Current.Value); } } diff --git a/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs b/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs index 4aa715dcaccc7f2f59411bcb2ca6588b3b115f65..5f12b6c4029a6255837ef8840ae75afa146db1c9 100644 --- a/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs +++ b/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs @@ -1,6 +1,6 @@ -using TMPro; +using System.Collections.Generic; +using TMPro; using UnityEngine; -using System.Collections.Generic; using static CommunicationEvents; public class RenderedScrollFact : MonoBehaviour @@ -29,18 +29,21 @@ void Start() HintAvailableEvent.AddListener(OnHintAvailable); } - public void OnClickHintButton() { + public void OnClickHintButton() + { ScrollFactHintEvent.Invoke(this.ScrollParameterObject, factUri); } - public void OnHintAvailable(List<string> uris) { + public void OnHintAvailable(List<string> uris) + { GameObject hintButton = ScrollParameterObject.transform.GetChild(2).gameObject; if (uris.Contains(factUri)) { hintButton.SetActive(true); } - else { + else + { hintButton.SetActive(false); } } diff --git a/Assets/Scripts/InventoryStuff/Scroll.cs b/Assets/Scripts/InventoryStuff/Scroll.cs index abc13bde453618fc6ae1ed75d3f9e0caa1401ff2..888c155b463ba8905dbd005b1f5edba316fd04e6 100644 --- a/Assets/Scripts/InventoryStuff/Scroll.cs +++ b/Assets/Scripts/InventoryStuff/Scroll.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; +using JsonSubTypes; +using Newtonsoft.Json; using System; +using System.Collections.Generic; using static JSONManager; -using JsonSubTypes; -using Newtonsoft.Json; public class Scroll { @@ -70,8 +70,9 @@ public class ScrollSymbolFact : ScrollFact { public MMTTerm tp; public MMTTerm df; - - public override String getType() { + + public override String getType() + { if (this.tp is OMS) return ((OMS)this.tp).uri; else if (this.tp is OMA) diff --git a/Assets/Scripts/InventoryStuff/ScrollClickedScript.cs b/Assets/Scripts/InventoryStuff/ScrollClickedScript.cs index e25d2cd6da28c27c994689bec1b2faf38a01ec26..2dbf5d8de8db58dd33ef908163df295d4329e08c 100644 --- a/Assets/Scripts/InventoryStuff/ScrollClickedScript.cs +++ b/Assets/Scripts/InventoryStuff/ScrollClickedScript.cs @@ -1,13 +1,12 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; -public class ScrollClickedScript: MonoBehaviour +public class ScrollClickedScript : MonoBehaviour { public Scroll scroll; public GameObject DetailScreen; - public void onClick() { + public void onClick() + { this.DetailScreen.GetComponent<ScrollDetails>().setScroll(this.scroll); } } diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs index fe676ae2b5cbac38b80a99a12d7151c12bfa2c89..02644e1ae75ab4b0406404aca6a7612ca133a9c0 100644 --- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs +++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs @@ -161,7 +161,8 @@ private void readPushout(List<Scroll.ScrollFact> pushoutFacts) if(pushoutFacts.Count == 0) PushoutFactFailEvent.Invoke(null); - for (int i = 0; i < pushoutFacts.Count; i++) + bool samestep = false; + for (int i = 0; i < pushoutFacts.Count; i++, samestep = true) { Fact newFact = ParsingDictionary.parseFactDictionary[pushoutFacts[i].getType()].Invoke(pushoutFacts[i]); if (newFact != null) @@ -169,7 +170,7 @@ private void readPushout(List<Scroll.ScrollFact> pushoutFacts) int id = factManager.GetFirstEmptyID(); newFact.Id = id; - FactManager.AddFactIfNotFound(id, newFact, out bool exists); + FactManager.AddFactIfNotFound(newFact, out bool exists, samestep); if(!exists) PushoutFactEvent.Invoke(newFact); } @@ -237,9 +238,9 @@ public void animateHint(GameObject scrollParameter, string scrollParameterUri) { if (suitableCompletion != null) { - fact = Facts.Find(x => x.backendURI.Equals(suitableCompletion.assignment.uri)); - if (fact != null) + if (Facts.searchURI(suitableCompletion.assignment.uri, out int factId)) { + fact = Facts[factId]; //Animate ScrollParameter scrollParameter.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger(); //Animate Fact in FactPanel @@ -248,13 +249,15 @@ public void animateHint(GameObject scrollParameter, string scrollParameterUri) { fact.Representation.GetComponentInChildren<MeshRendererHintAnimation>().AnimationTrigger(); } } - else if (LatestRenderedHints.Exists(x => x.backendURI.Equals(scrollParameterUri))) { + else if (LatestRenderedHints.Exists(x => x.backendURI.Equals(scrollParameterUri))) + { fact = LatestRenderedHints.Find(x => x.backendURI.Equals(scrollParameterUri)); + int factId = fact.Id; //If there is an equal existing fact -> Animate that fact AND ScrollParameter - if (Facts.Exists(x => x.Equals(fact))) + if (Facts.ContainsKey(factId)) { - Fact existingFact = Facts.Find(x => x.Equals(fact)); + Fact existingFact = Facts[factId]; //Animate ScrollParameter scrollParameter.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger(); diff --git a/Assets/Scripts/Level.cs b/Assets/Scripts/Level.cs index bd58a9c7c5f33317e98bad487732c0060f0ae1fd..a65344b1702760760a9b101b71d5699bcd4660ce 100644 --- a/Assets/Scripts/Level.cs +++ b/Assets/Scripts/Level.cs @@ -1,6 +1,5 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; +using static CommunicationEvents; //TODO: think about having one Level class and then different subclasses like TreeLevel, Tangenslevel? public class Level : MonoBehaviour @@ -28,14 +27,17 @@ public static bool gameSolved() return true; else { - var Facts = CommunicationEvents.Facts; //Look for solutionFact in global factList - foreach (Fact fact in Facts) + foreach (var entry in Facts) { + Fact fact = entry.Value; if (typeof(LineFact).IsInstanceOfType(fact)) { - tempDir1 = ((PointFact)Facts.Find(x => x.Id == ((LineFact)fact).Pid1)).Point - ((PointFact)Facts.Find(x => x.Id == ((LineFact)fact).Pid2)).Point; - tempDir2 = ((PointFact)Facts.Find(x => x.Id == ((LineFact)fact).Pid2)).Point - ((PointFact)Facts.Find(x => x.Id == ((LineFact)fact).Pid1)).Point; + tempDir1 = ((PointFact) Facts[((LineFact) fact).Pid1]).Point + - ((PointFact) Facts[((LineFact) fact).Pid2]).Point; + tempDir2 = ((PointFact) Facts[((LineFact) fact).Pid2]).Point + - ((PointFact) Facts[((LineFact) fact).Pid1]).Point; + if (solutionVector == tempDir1 || solutionVector == tempDir2) { solved = true; diff --git a/Assets/Scripts/Math3d.cs b/Assets/Scripts/Math3d.cs index 6d63cfd76b07d5ba593c3ef2a3c1922ccc697ebd..c675190229cdbe722993621be32991644aab0073 100644 --- a/Assets/Scripts/Math3d.cs +++ b/Assets/Scripts/Math3d.cs @@ -1,1209 +1,1212 @@ -using UnityEngine; -using System.Collections; +using System; using System.Collections.Generic; -using System; +using UnityEngine; public class Math3d { - public const float vectorPrecission = 1e-5f; //For Vector comparisons - - private static Transform tempChild = null; - private static Transform tempParent = null; - - private static Vector3[] positionRegister; - private static float[] posTimeRegister; - private static int positionSamplesTaken = 0; - - private static Quaternion[] rotationRegister; - private static float[] rotTimeRegister; - private static int rotationSamplesTaken = 0; - - public static void Init() - { - - tempChild = (new GameObject("Math3d_TempChild")).transform; - tempParent = (new GameObject("Math3d_TempParent")).transform; - - tempChild.gameObject.hideFlags = HideFlags.HideAndDontSave; - MonoBehaviour.DontDestroyOnLoad(tempChild.gameObject); - - tempParent.gameObject.hideFlags = HideFlags.HideAndDontSave; - MonoBehaviour.DontDestroyOnLoad(tempParent.gameObject); - - //set the parent - tempChild.parent = tempParent; - } - - //Get a point on a Catmull-Rom spline. - //The percentage is in range 0 to 1, which starts at the second control point and ends at the second last control point. - //The array cPoints should contain all control points. The minimum amount of control points should be 4. - //Source: https://forum.unity.com/threads/waypoints-and-constant-variable-speed-problems.32954/#post-213942 - public static Vector2 GetPointOnSpline(float percentage, Vector2[] cPoints) - { - - //Minimum size is 4 - if (cPoints.Length >= 4) - { - - //Convert the input range (0 to 1) to range (0 to numSections) - int numSections = cPoints.Length - 3; - int curPoint = Mathf.Min(Mathf.FloorToInt(percentage * (float)numSections), numSections - 1); - float t = percentage * (float)numSections - (float)curPoint; - - //Get the 4 control points around the location to be sampled. - Vector2 p0 = cPoints[curPoint]; - Vector2 p1 = cPoints[curPoint + 1]; - Vector2 p2 = cPoints[curPoint + 2]; - Vector2 p3 = cPoints[curPoint + 3]; - - //The Catmull-Rom spline can be written as: - // 0.5 * (2*P1 + (-P0 + P2) * t + (2*P0 - 5*P1 + 4*P2 - P3) * t^2 + (-P0 + 3*P1 - 3*P2 + P3) * t^3) - //Variables P0 to P3 are the control points. - //Variable t is the position on the spline, with a range of 0 to numSections. - //C# way of writing the function. Note that f means float (to force precision). - Vector2 result = .5f * (2f * p1 + (-p0 + p2) * t + (2f * p0 - 5f * p1 + 4f * p2 - p3) * (t * t) + (-p0 + 3f * p1 - 3f * p2 + p3) * (t * t * t)); - - return new Vector2(result.x, result.y); - } - - else - { - - return new Vector2(0, 0); - } - } - - //Finds the intersection points between a straight line and a spline. Solves a Cubic polynomial equation - //The output is in the form of a percentage along the length of the spline (range 0 to 1). - //The linePoints array should contain two points which form a straight line. - //The cPoints array should contain all the control points of the spline. - //Use case: create a gauge with a non-linear scale by defining an array with needle angles vs the number it should point at. The array creates a spline. - //Driving the needle with a float in range 0 to 1 gives an unpredictable result. Instead, use the GetLineSplineIntersections() function to find the angle the - //gauge needle should have for a given number it should point at. In this case, cPoints should contain x for angle and y for scale number. - //Make a horizontal line at the given scale number (y) you want to find the needle angle for. The returned float is a percentage location on the spline (range 0 to 1). - //Plug this value into the GetPointOnSpline() function to get the x coordinate which represents the needle angle. - //Source: https://medium.com/@csaba.apagyi/finding-catmull-rom-spline-and-line-intersection-part-2-mathematical-approach-dfb969019746 - public static float[] GetLineSplineIntersections(Vector2[] linePoints, Vector2[] cPoints) - { - - List<float> list = new List<float>(); - float[] crossings; - - int numSections = cPoints.Length - 3; - - //The line spline intersection can only be calculated for one segment of a spline, meaning 4 control points, - //with a spline segment between the middle two control points. So check all spline segments. - for (int i = 0; i < numSections; i++) - { - - //Get the 4 control points around the location to be sampled. - Vector2 p0 = cPoints[i]; - Vector2 p1 = cPoints[i + 1]; - Vector2 p2 = cPoints[i + 2]; - Vector2 p3 = cPoints[i + 3]; - - //The Catmull-Rom spline can be written as: - // 0.5 * (2P1 + (-P0 + P2) * t + (2P0 - 5P1 + 4P2 - P3) * t^2 + (-P0 + 3P1 - 3P2 + P3) * t^3) - //Variables P0 to P3 are the control points. - //Notation: 2P1 means 2*controlPoint1 - //Variable t is the position on the spline, converted from a range of 0 to 1. - //C# way of writing the function is below. Note that f means float (to force precision). - //Vector2 result = .5f * (2f * p1 + (-p0 + p2) * t + (2f * p0 - 5f * p1 + 4f * p2 - p3) * (t * t) + (-p0 + 3f * p1 - 3f * p2 + p3) * (t * t * t)); - - //The variable t is the only unknown, so the rest can be substituted: - //a = 0.5 * (-p0 + 3*p1 - 3*p2 + p3) - //b = 0.5 * (2*p0 - 5*p1 + 4*p2 - p3) - //c = 0.5 * (-p0 + p2) - //d = 0.5 * (2*p1) - - //This gives rise to the following Cubic equation: - //a * t^3 + b * t^2 + c * t + d = 0 - - //The spline control points (p0-3) consist of two variables: the x and y coordinates. They are independent so we can handle them separately. - //Below, a1 is substitution a where the x coordinate of each point is used, like so: a1 = 0.5 * (-p0.x + 3*p1.x - 3*p2.x + p3.x) - //Below, a2 is substitution a where the y coordinate of each point is used, like so: a2 = 0.5 * (-p0.y + 3*p1.y - 3*p2.y + p3.y) - //The same logic applies for substitutions b, c, and d. - - float a1 = 0.5f * (-p0.x + 3f * p1.x - 3f * p2.x + p3.x); - float a2 = 0.5f * (-p0.y + 3f * p1.y - 3f * p2.y + p3.y); - float b1 = 0.5f * (2f * p0.x - 5f * p1.x + 4f * p2.x - p3.x); - float b2 = 0.5f * (2f * p0.y - 5f * p1.y + 4f * p2.y - p3.y); - float c1 = 0.5f * (-p0.x + p2.x); - float c2 = 0.5f * (-p0.y + p2.y); - float d1 = 0.5f * (2f * p1.x); - float d2 = 0.5f * (2f * p1.y); - - //We now have two Cubic functions. One for x and one for y. - //Note that a, b, c, and d are not vector variables itself but substituted functions. - //x = a1 * t^3 + b1 * t^2 + c1 * t + d1 - //y = a2 * t^3 + b2 * t^2 + c2 * t + d2 - - //Line formula, standard form: - //Ax + By + C = 0 - float A = linePoints[0].y - linePoints[1].y; - float B = linePoints[1].x - linePoints[0].x; - float C = (linePoints[0].x - linePoints[1].x) * linePoints[0].y + (linePoints[1].y - linePoints[0].y) * linePoints[0].x; - - //Substituting the values of x and y from the separated Spline formula into the Line formula, we get: - //A * (a1 * t^3 + b1 * t^2 + c1 * t + d1) + B * (a2 * t^3 + b2 * t^2 + c2 * t + d2) + C = 0 - - //Rearranged version: - //(A * a1 + B * a2) * t^3 + (A * b1 + B * b2) * t^2 + (A * c1 + B * c2) * t + (A * d1 + B * d2 + C) = 0 - - //Substituting gives rise to a Cubic function: - //a * t^3 + b * t^2 + c * t + d = 0 - float a = A * a1 + B * a2; - float b = A * b1 + B * b2; - float c = A * c1 + B * c2; - float d = A * d1 + B * d2 + C; - - - //This is again a Cubic equation, combined from the Line and the Spline equation. If you solve this you can get up to 3 line-spline cross points. - //How to solve a Cubic equation is described here: - //https://www.cs.rit.edu/~ark/pj/lib/edu/rit/numeric/Cubic.shtml - //https://www.codeproject.com/Articles/798474/To-Solve-a-Cubic-Equation - - int crossAmount; - float cross1; - float cross2; - float cross3; - float crossCorrected; - - //Two different implementations of solving a Cubic equation. - // SolveCubic2(out crossAmount, out cross1, out cross2, out cross3, a, b, c, d); - SolveCubic(out crossAmount, out cross1, out cross2, out cross3, a, b, c, d); - - //Get the highest and lowest value (in range 0 to 1) of the current section and calculate the difference. - float currentSectionLowest = (float)i / (float)numSections; - float currentSectionHighest = ((float)i + 1f) / (float)numSections; - float diff = currentSectionHighest - currentSectionLowest; - - //Only use the result if it is within range 0 to 1. - //The range 0 to 1 is within the current segment. It has to be converted to the range of the entire spline, - //which still uses a range of 0 to 1. - if (cross1 >= 0 && cross1 <= 1) - { - - //Map an intermediate range (0 to 1) to the lowest and highest section values. - crossCorrected = (cross1 * diff) + currentSectionLowest; - - //Add the result to the list. - list.Add(crossCorrected); - } - - if (cross2 >= 0 && cross2 <= 1) - { - - //Map an intermediate range (0 to 1) to the lowest and highest section values. - crossCorrected = (cross2 * diff) + currentSectionLowest; - - //Add the result to the list. - list.Add(crossCorrected); - } - - if (cross3 >= 0 && cross3 <= 1) - { - - //Map an intermediate range (0 to 1) to the lowest and highest section values. - crossCorrected = (cross3 * diff) + currentSectionLowest; - - //Add the result to the list. - list.Add(crossCorrected); - } - } - - //Convert the list to an array. - crossings = list.ToArray(); - - return crossings; - } - - //Solve cubic equation according to Cardano. - //Source: https://www.cs.rit.edu/~ark/pj/lib/edu/rit/numeric/Cubic.shtml - private static void SolveCubic(out int nRoots, out float x1, out float x2, out float x3, float a, float b, float c, float d) - { - - float TWO_PI = 2f * Mathf.PI; - float FOUR_PI = 4f * Mathf.PI; - - // Normalize coefficients. - float denom = a; - a = b / denom; - b = c / denom; - c = d / denom; - - // Commence solution. - float a_over_3 = a / 3f; - float Q = (3f * b - a * a) / 9f; - float Q_CUBE = Q * Q * Q; - float R = (9f * a * b - 27f * c - 2f * a * a * a) / 54f; - float R_SQR = R * R; - float D = Q_CUBE + R_SQR; - - if (D < 0.0f) - { - - // Three unequal real roots. - nRoots = 3; - float theta = Mathf.Acos(R / Mathf.Sqrt(-Q_CUBE)); - float SQRT_Q = Mathf.Sqrt(-Q); - x1 = 2f * SQRT_Q * Mathf.Cos(theta / 3f) - a_over_3; - x2 = 2f * SQRT_Q * Mathf.Cos((theta + TWO_PI) / 3f) - a_over_3; - x3 = 2f * SQRT_Q * Mathf.Cos((theta + FOUR_PI) / 3f) - a_over_3; - } - - else if (D > 0.0f) - { - - // One real root. - nRoots = 1; - float SQRT_D = Mathf.Sqrt(D); - float S = CubeRoot(R + SQRT_D); - float T = CubeRoot(R - SQRT_D); - x1 = (S + T) - a_over_3; - x2 = float.NaN; - x3 = float.NaN; - } - - else - { - - // Three real roots, at least two equal. - nRoots = 3; - float CBRT_R = CubeRoot(R); - x1 = 2 * CBRT_R - a_over_3; - x2 = CBRT_R - a_over_3; - x3 = x2; - } - } - - //Mathf.Pow is used as an alternative for cube root (Math.cbrt) here. - private static float CubeRoot(float d) - { - - if (d < 0.0f) - { - - return -Mathf.Pow(-d, 1f / 3f); - } - - else - { - - return Mathf.Pow(d, 1f / 3f); - } - } - - - //increase or decrease the length of vector by size - public static Vector3 AddVectorLength(Vector3 vector, float size) - { - - //get the vector length - float magnitude = Vector3.Magnitude(vector); - - //calculate new vector length - float newMagnitude = magnitude + size; - - //calculate the ratio of the new length to the old length - float scale = newMagnitude / magnitude; - - //scale the vector - return vector * scale; - } - - //create a vector of direction "vector" with length "size" - public static Vector3 SetVectorLength(Vector3 vector, float size) - { - - //normalize the vector - Vector3 vectorNormalized = Vector3.Normalize(vector); - - //scale the vector - return vectorNormalized *= size; - } - - - //caclulate the rotational difference from A to B - public static Quaternion SubtractRotation(Quaternion B, Quaternion A) - { - - Quaternion C = Quaternion.Inverse(A) * B; - return C; - } - - //Add rotation B to rotation A. - public static Quaternion AddRotation(Quaternion A, Quaternion B) - { - - Quaternion C = A * B; - return C; - } - - //Same as the build in TransformDirection(), but using a rotation instead of a transform. - public static Vector3 TransformDirectionMath(Quaternion rotation, Vector3 vector) - { - - Vector3 output = rotation * vector; - return output; - } - - //Same as the build in InverseTransformDirection(), but using a rotation instead of a transform. - public static Vector3 InverseTransformDirectionMath(Quaternion rotation, Vector3 vector) - { - - Vector3 output = Quaternion.Inverse(rotation) * vector; - return output; - } - - //Rotate a vector as if it is attached to an object with rotation "from", which is then rotated to rotation "to". - //Similar to TransformWithParent(), but rotating a vector instead of a transform. - public static Vector3 RotateVectorFromTo(Quaternion from, Quaternion to, Vector3 vector) - { - //Note: comments are in case all inputs are in World Space. - Quaternion Q = SubtractRotation(to, from); //Output is in object space. - Vector3 A = InverseTransformDirectionMath(from, vector);//Output is in object space. - Vector3 B = Q * A; //Output is in local space. - Vector3 C = TransformDirectionMath(from, B); //Output is in world space. - return C; - } - - //Find the line of intersection between two planes. The planes are defined by a normal and a point on that plane. - //The outputs are a point on the line and a vector which indicates it's direction. If the planes are not parallel, - //the function outputs true, otherwise false. - public static bool PlanePlaneIntersection(out Vector3 linePoint, out Vector3 lineVec, Vector3 plane1Normal, Vector3 plane1Position, Vector3 plane2Normal, Vector3 plane2Position) - { - - linePoint = Vector3.zero; - lineVec = Vector3.zero; - - //We can get the direction of the line of intersection of the two planes by calculating the - //cross product of the normals of the two planes. Note that this is just a direction and the line - //is not fixed in space yet. We need a point for that to go with the line vector. - lineVec = Vector3.Cross(plane1Normal, plane2Normal); - - //Next is to calculate a point on the line to fix it's position in space. This is done by finding a vector from - //the plane2 location, moving parallel to it's plane, and intersecting plane1. To prevent rounding - //errors, this vector also has to be perpendicular to lineDirection. To get this vector, calculate - //the cross product of the normal of plane2 and the lineDirection. - Vector3 ldir = Vector3.Cross(plane2Normal, lineVec); - - float denominator = Vector3.Dot(plane1Normal, ldir); - - //Prevent divide by zero and rounding errors by requiring about 5 degrees angle between the planes. - if (Mathf.Abs(denominator) > 0.006f) - { - - Vector3 plane1ToPlane2 = plane1Position - plane2Position; - float t = Vector3.Dot(plane1Normal, plane1ToPlane2) / denominator; - linePoint = plane2Position + t * ldir; - - return true; - } - - //output not valid - else - { - return false; - } - } - - //Get the intersection between a line and a plane. - //If the line and plane are not parallel, the function outputs true, otherwise false. - public static bool LinePlaneIntersection(out Vector3 intersection, Vector3 linePoint, Vector3 lineVec, Vector3 planeNormal, Vector3 planePoint) - { - - float length; - float dotNumerator; - float dotDenominator; - Vector3 vector; - intersection = Vector3.zero; - - //calculate the distance between the linePoint and the line-plane intersection point - dotNumerator = Vector3.Dot((planePoint - linePoint), planeNormal); - dotDenominator = Vector3.Dot(lineVec, planeNormal); - - //line and plane are not parallel - if (dotDenominator != 0.0f) - { - length = dotNumerator / dotDenominator; - - //create a vector from the linePoint to the intersection point - vector = SetVectorLength(lineVec, length); - - //get the coordinates of the line-plane intersection point - intersection = linePoint + vector; - - return true; - } - - //output not valid - else - { - return false; - } - } - - //Calculate the intersection point of two lines. Returns true if lines intersect, otherwise false. - //Note that in 3d, two lines do not intersect most of the time. So if the two lines are not in the - //same plane, use ClosestPointsOnTwoLines() instead. - public static bool LineLineIntersection(out Vector3 intersection, Vector3 linePoint1, Vector3 lineVec1, Vector3 linePoint2, Vector3 lineVec2) - { - - Vector3 lineVec3 = linePoint2 - linePoint1; - Vector3 crossVec1and2 = Vector3.Cross(lineVec1, lineVec2); - Vector3 crossVec3and2 = Vector3.Cross(lineVec3, lineVec2); - - float planarFactor = Vector3.Dot(lineVec3, crossVec1and2); - - //is coplanar, and not parrallel - if (Mathf.Abs(planarFactor) < 0.0001f && crossVec1and2.sqrMagnitude > 0.0001f) - { - float s = Vector3.Dot(crossVec3and2, crossVec1and2) / crossVec1and2.sqrMagnitude; - intersection = linePoint1 + (lineVec1 * s); - return true; - } - else - { - intersection = Vector3.zero; - return false; - } - } + public const double vectorPrecission = 1e-4d; //For Vector comparisons + + private static Transform tempChild = null; + private static Transform tempParent = null; + + private static Vector3[] positionRegister; + private static float[] posTimeRegister; + private static int positionSamplesTaken = 0; + + private static Quaternion[] rotationRegister; + private static float[] rotTimeRegister; + private static int rotationSamplesTaken = 0; + + public static void Init() + { + + tempChild = (new GameObject("Math3d_TempChild")).transform; + tempParent = (new GameObject("Math3d_TempParent")).transform; + + tempChild.gameObject.hideFlags = HideFlags.HideAndDontSave; + MonoBehaviour.DontDestroyOnLoad(tempChild.gameObject); + + tempParent.gameObject.hideFlags = HideFlags.HideAndDontSave; + MonoBehaviour.DontDestroyOnLoad(tempParent.gameObject); + + //set the parent + tempChild.parent = tempParent; + } + + //Get a point on a Catmull-Rom spline. + //The percentage is in range 0 to 1, which starts at the second control point and ends at the second last control point. + //The array cPoints should contain all control points. The minimum amount of control points should be 4. + //Source: https://forum.unity.com/threads/waypoints-and-constant-variable-speed-problems.32954/#post-213942 + public static Vector2 GetPointOnSpline(float percentage, Vector2[] cPoints) + { + + //Minimum size is 4 + if (cPoints.Length >= 4) + { + + //Convert the input range (0 to 1) to range (0 to numSections) + int numSections = cPoints.Length - 3; + int curPoint = Mathf.Min(Mathf.FloorToInt(percentage * (float)numSections), numSections - 1); + float t = percentage * (float)numSections - (float)curPoint; + + //Get the 4 control points around the location to be sampled. + Vector2 p0 = cPoints[curPoint]; + Vector2 p1 = cPoints[curPoint + 1]; + Vector2 p2 = cPoints[curPoint + 2]; + Vector2 p3 = cPoints[curPoint + 3]; + + //The Catmull-Rom spline can be written as: + // 0.5 * (2*P1 + (-P0 + P2) * t + (2*P0 - 5*P1 + 4*P2 - P3) * t^2 + (-P0 + 3*P1 - 3*P2 + P3) * t^3) + //Variables P0 to P3 are the control points. + //Variable t is the position on the spline, with a range of 0 to numSections. + //C# way of writing the function. Note that f means float (to force precision). + Vector2 result = .5f * (2f * p1 + (-p0 + p2) * t + (2f * p0 - 5f * p1 + 4f * p2 - p3) * (t * t) + (-p0 + 3f * p1 - 3f * p2 + p3) * (t * t * t)); + + return new Vector2(result.x, result.y); + } + + else + { + + return new Vector2(0, 0); + } + } + + //Finds the intersection points between a straight line and a spline. Solves a Cubic polynomial equation + //The output is in the form of a percentage along the length of the spline (range 0 to 1). + //The linePoints array should contain two points which form a straight line. + //The cPoints array should contain all the control points of the spline. + //Use case: create a gauge with a non-linear scale by defining an array with needle angles vs the number it should point at. The array creates a spline. + //Driving the needle with a float in range 0 to 1 gives an unpredictable result. Instead, use the GetLineSplineIntersections() function to find the angle the + //gauge needle should have for a given number it should point at. In this case, cPoints should contain x for angle and y for scale number. + //Make a horizontal line at the given scale number (y) you want to find the needle angle for. The returned float is a percentage location on the spline (range 0 to 1). + //Plug this value into the GetPointOnSpline() function to get the x coordinate which represents the needle angle. + //Source: https://medium.com/@csaba.apagyi/finding-catmull-rom-spline-and-line-intersection-part-2-mathematical-approach-dfb969019746 + public static float[] GetLineSplineIntersections(Vector2[] linePoints, Vector2[] cPoints) + { + + List<float> list = new List<float>(); + float[] crossings; + + int numSections = cPoints.Length - 3; + + //The line spline intersection can only be calculated for one segment of a spline, meaning 4 control points, + //with a spline segment between the middle two control points. So check all spline segments. + for (int i = 0; i < numSections; i++) + { + + //Get the 4 control points around the location to be sampled. + Vector2 p0 = cPoints[i]; + Vector2 p1 = cPoints[i + 1]; + Vector2 p2 = cPoints[i + 2]; + Vector2 p3 = cPoints[i + 3]; + + //The Catmull-Rom spline can be written as: + // 0.5 * (2P1 + (-P0 + P2) * t + (2P0 - 5P1 + 4P2 - P3) * t^2 + (-P0 + 3P1 - 3P2 + P3) * t^3) + //Variables P0 to P3 are the control points. + //Notation: 2P1 means 2*controlPoint1 + //Variable t is the position on the spline, converted from a range of 0 to 1. + //C# way of writing the function is below. Note that f means float (to force precision). + //Vector2 result = .5f * (2f * p1 + (-p0 + p2) * t + (2f * p0 - 5f * p1 + 4f * p2 - p3) * (t * t) + (-p0 + 3f * p1 - 3f * p2 + p3) * (t * t * t)); + + //The variable t is the only unknown, so the rest can be substituted: + //a = 0.5 * (-p0 + 3*p1 - 3*p2 + p3) + //b = 0.5 * (2*p0 - 5*p1 + 4*p2 - p3) + //c = 0.5 * (-p0 + p2) + //d = 0.5 * (2*p1) + + //This gives rise to the following Cubic equation: + //a * t^3 + b * t^2 + c * t + d = 0 + + //The spline control points (p0-3) consist of two variables: the x and y coordinates. They are independent so we can handle them separately. + //Below, a1 is substitution a where the x coordinate of each point is used, like so: a1 = 0.5 * (-p0.x + 3*p1.x - 3*p2.x + p3.x) + //Below, a2 is substitution a where the y coordinate of each point is used, like so: a2 = 0.5 * (-p0.y + 3*p1.y - 3*p2.y + p3.y) + //The same logic applies for substitutions b, c, and d. + + float a1 = 0.5f * (-p0.x + 3f * p1.x - 3f * p2.x + p3.x); + float a2 = 0.5f * (-p0.y + 3f * p1.y - 3f * p2.y + p3.y); + float b1 = 0.5f * (2f * p0.x - 5f * p1.x + 4f * p2.x - p3.x); + float b2 = 0.5f * (2f * p0.y - 5f * p1.y + 4f * p2.y - p3.y); + float c1 = 0.5f * (-p0.x + p2.x); + float c2 = 0.5f * (-p0.y + p2.y); + float d1 = 0.5f * (2f * p1.x); + float d2 = 0.5f * (2f * p1.y); + + //We now have two Cubic functions. One for x and one for y. + //Note that a, b, c, and d are not vector variables itself but substituted functions. + //x = a1 * t^3 + b1 * t^2 + c1 * t + d1 + //y = a2 * t^3 + b2 * t^2 + c2 * t + d2 + + //Line formula, standard form: + //Ax + By + C = 0 + float A = linePoints[0].y - linePoints[1].y; + float B = linePoints[1].x - linePoints[0].x; + float C = (linePoints[0].x - linePoints[1].x) * linePoints[0].y + (linePoints[1].y - linePoints[0].y) * linePoints[0].x; + + //Substituting the values of x and y from the separated Spline formula into the Line formula, we get: + //A * (a1 * t^3 + b1 * t^2 + c1 * t + d1) + B * (a2 * t^3 + b2 * t^2 + c2 * t + d2) + C = 0 + + //Rearranged version: + //(A * a1 + B * a2) * t^3 + (A * b1 + B * b2) * t^2 + (A * c1 + B * c2) * t + (A * d1 + B * d2 + C) = 0 + + //Substituting gives rise to a Cubic function: + //a * t^3 + b * t^2 + c * t + d = 0 + float a = A * a1 + B * a2; + float b = A * b1 + B * b2; + float c = A * c1 + B * c2; + float d = A * d1 + B * d2 + C; + + + //This is again a Cubic equation, combined from the Line and the Spline equation. If you solve this you can get up to 3 line-spline cross points. + //How to solve a Cubic equation is described here: + //https://www.cs.rit.edu/~ark/pj/lib/edu/rit/numeric/Cubic.shtml + //https://www.codeproject.com/Articles/798474/To-Solve-a-Cubic-Equation + + int crossAmount; + float cross1; + float cross2; + float cross3; + float crossCorrected; + + //Two different implementations of solving a Cubic equation. + // SolveCubic2(out crossAmount, out cross1, out cross2, out cross3, a, b, c, d); + SolveCubic(out crossAmount, out cross1, out cross2, out cross3, a, b, c, d); + + //Get the highest and lowest value (in range 0 to 1) of the current section and calculate the difference. + float currentSectionLowest = (float)i / (float)numSections; + float currentSectionHighest = ((float)i + 1f) / (float)numSections; + float diff = currentSectionHighest - currentSectionLowest; + + //Only use the result if it is within range 0 to 1. + //The range 0 to 1 is within the current segment. It has to be converted to the range of the entire spline, + //which still uses a range of 0 to 1. + if (cross1 >= 0 && cross1 <= 1) + { + + //Map an intermediate range (0 to 1) to the lowest and highest section values. + crossCorrected = (cross1 * diff) + currentSectionLowest; + + //Add the result to the list. + list.Add(crossCorrected); + } + + if (cross2 >= 0 && cross2 <= 1) + { + + //Map an intermediate range (0 to 1) to the lowest and highest section values. + crossCorrected = (cross2 * diff) + currentSectionLowest; + + //Add the result to the list. + list.Add(crossCorrected); + } + + if (cross3 >= 0 && cross3 <= 1) + { + + //Map an intermediate range (0 to 1) to the lowest and highest section values. + crossCorrected = (cross3 * diff) + currentSectionLowest; + + //Add the result to the list. + list.Add(crossCorrected); + } + } + + //Convert the list to an array. + crossings = list.ToArray(); + + return crossings; + } + + //Solve cubic equation according to Cardano. + //Source: https://www.cs.rit.edu/~ark/pj/lib/edu/rit/numeric/Cubic.shtml + private static void SolveCubic(out int nRoots, out float x1, out float x2, out float x3, float a, float b, float c, float d) + { + + float TWO_PI = 2f * Mathf.PI; + float FOUR_PI = 4f * Mathf.PI; + + // Normalize coefficients. + float denom = a; + a = b / denom; + b = c / denom; + c = d / denom; + + // Commence solution. + float a_over_3 = a / 3f; + float Q = (3f * b - a * a) / 9f; + float Q_CUBE = Q * Q * Q; + float R = (9f * a * b - 27f * c - 2f * a * a * a) / 54f; + float R_SQR = R * R; + float D = Q_CUBE + R_SQR; + + if (D < 0.0f) + { + + // Three unequal real roots. + nRoots = 3; + float theta = Mathf.Acos(R / Mathf.Sqrt(-Q_CUBE)); + float SQRT_Q = Mathf.Sqrt(-Q); + x1 = 2f * SQRT_Q * Mathf.Cos(theta / 3f) - a_over_3; + x2 = 2f * SQRT_Q * Mathf.Cos((theta + TWO_PI) / 3f) - a_over_3; + x3 = 2f * SQRT_Q * Mathf.Cos((theta + FOUR_PI) / 3f) - a_over_3; + } + + else if (D > 0.0f) + { + + // One real root. + nRoots = 1; + float SQRT_D = Mathf.Sqrt(D); + float S = CubeRoot(R + SQRT_D); + float T = CubeRoot(R - SQRT_D); + x1 = (S + T) - a_over_3; + x2 = float.NaN; + x3 = float.NaN; + } + + else + { + + // Three real roots, at least two equal. + nRoots = 3; + float CBRT_R = CubeRoot(R); + x1 = 2 * CBRT_R - a_over_3; + x2 = CBRT_R - a_over_3; + x3 = x2; + } + } + + //Mathf.Pow is used as an alternative for cube root (Math.cbrt) here. + private static float CubeRoot(float d) + { + + if (d < 0.0f) + { + + return -Mathf.Pow(-d, 1f / 3f); + } + + else + { + + return Mathf.Pow(d, 1f / 3f); + } + } + + + //increase or decrease the length of vector by size + public static Vector3 AddVectorLength(Vector3 vector, float size) + { + + //get the vector length + float magnitude = Vector3.Magnitude(vector); + + //calculate new vector length + float newMagnitude = magnitude + size; + + //calculate the ratio of the new length to the old length + float scale = newMagnitude / magnitude; + + //scale the vector + return vector * scale; + } + + //create a vector of direction "vector" with length "size" + public static Vector3 SetVectorLength(Vector3 vector, float size) + { + + //normalize the vector + Vector3 vectorNormalized = Vector3.Normalize(vector); + + //scale the vector + return vectorNormalized *= size; + } + + + //caclulate the rotational difference from A to B + public static Quaternion SubtractRotation(Quaternion B, Quaternion A) + { + + Quaternion C = Quaternion.Inverse(A) * B; + return C; + } + + //Add rotation B to rotation A. + public static Quaternion AddRotation(Quaternion A, Quaternion B) + { + + Quaternion C = A * B; + return C; + } + + //Same as the build in TransformDirection(), but using a rotation instead of a transform. + public static Vector3 TransformDirectionMath(Quaternion rotation, Vector3 vector) + { + + Vector3 output = rotation * vector; + return output; + } + + //Same as the build in InverseTransformDirection(), but using a rotation instead of a transform. + public static Vector3 InverseTransformDirectionMath(Quaternion rotation, Vector3 vector) + { + + Vector3 output = Quaternion.Inverse(rotation) * vector; + return output; + } + + //Rotate a vector as if it is attached to an object with rotation "from", which is then rotated to rotation "to". + //Similar to TransformWithParent(), but rotating a vector instead of a transform. + public static Vector3 RotateVectorFromTo(Quaternion from, Quaternion to, Vector3 vector) + { + //Note: comments are in case all inputs are in World Space. + Quaternion Q = SubtractRotation(to, from); //Output is in object space. + Vector3 A = InverseTransformDirectionMath(from, vector);//Output is in object space. + Vector3 B = Q * A; //Output is in local space. + Vector3 C = TransformDirectionMath(from, B); //Output is in world space. + return C; + } + + //Find the line of intersection between two planes. The planes are defined by a normal and a point on that plane. + //The outputs are a point on the line and a vector which indicates it's direction. If the planes are not parallel, + //the function outputs true, otherwise false. + public static bool PlanePlaneIntersection(out Vector3 linePoint, out Vector3 lineVec, Vector3 plane1Normal, Vector3 plane1Position, Vector3 plane2Normal, Vector3 plane2Position) + { + + linePoint = Vector3.zero; + lineVec = Vector3.zero; + + //We can get the direction of the line of intersection of the two planes by calculating the + //cross product of the normals of the two planes. Note that this is just a direction and the line + //is not fixed in space yet. We need a point for that to go with the line vector. + lineVec = Vector3.Cross(plane1Normal, plane2Normal); + + //Next is to calculate a point on the line to fix it's position in space. This is done by finding a vector from + //the plane2 location, moving parallel to it's plane, and intersecting plane1. To prevent rounding + //errors, this vector also has to be perpendicular to lineDirection. To get this vector, calculate + //the cross product of the normal of plane2 and the lineDirection. + Vector3 ldir = Vector3.Cross(plane2Normal, lineVec); + + float denominator = Vector3.Dot(plane1Normal, ldir); + + //Prevent divide by zero and rounding errors by requiring about 5 degrees angle between the planes. + if (Mathf.Abs(denominator) > 0.006f) + { + + Vector3 plane1ToPlane2 = plane1Position - plane2Position; + float t = Vector3.Dot(plane1Normal, plane1ToPlane2) / denominator; + linePoint = plane2Position + t * ldir; + + return true; + } + + //output not valid + else + { + return false; + } + } + + //Get the intersection between a line and a plane. + //If the line and plane are not parallel, the function outputs true, otherwise false. + public static bool LinePlaneIntersection(out Vector3 intersection, Vector3 linePoint, Vector3 lineVec, Vector3 planeNormal, Vector3 planePoint) + { + + float length; + float dotNumerator; + float dotDenominator; + Vector3 vector; + intersection = Vector3.zero; + + //calculate the distance between the linePoint and the line-plane intersection point + dotNumerator = Vector3.Dot((planePoint - linePoint), planeNormal); + dotDenominator = Vector3.Dot(lineVec, planeNormal); + + //line and plane are not parallel + if (dotDenominator != 0.0f) + { + length = dotNumerator / dotDenominator; + + //create a vector from the linePoint to the intersection point + vector = SetVectorLength(lineVec, length); + + //get the coordinates of the line-plane intersection point + intersection = linePoint + vector; + + return true; + } + + //output not valid + else + { + return false; + } + } + + //Calculate the intersection point of two lines. Returns true if lines intersect, otherwise false. + //Note that in 3d, two lines do not intersect most of the time. So if the two lines are not in the + //same plane, use ClosestPointsOnTwoLines() instead. + public static bool LineLineIntersection(out Vector3 intersection, Vector3 linePoint1, Vector3 lineVec1, Vector3 linePoint2, Vector3 lineVec2) + { + + Vector3 lineVec3 = linePoint2 - linePoint1; + Vector3 crossVec1and2 = Vector3.Cross(lineVec1, lineVec2); + Vector3 crossVec3and2 = Vector3.Cross(lineVec3, lineVec2); + + float planarFactor = Vector3.Dot(lineVec3, crossVec1and2); + + //is coplanar, and not parrallel + if (Mathf.Abs(planarFactor) < 0.0001f && crossVec1and2.sqrMagnitude > 0.0001f) + { + float s = Vector3.Dot(crossVec3and2, crossVec1and2) / crossVec1and2.sqrMagnitude; + intersection = linePoint1 + (lineVec1 * s); + return true; + } + else + { + intersection = Vector3.zero; + return false; + } + } - //Two non-parallel lines which may or may not touch each other have a point on each line which are closest - //to each other. This function finds those two points. If the lines are not parallel, the function - //outputs true, otherwise false. - public static bool ClosestPointsOnTwoLines(out Vector3 closestPointLine1, out Vector3 closestPointLine2, Vector3 linePoint1, Vector3 lineVec1, Vector3 linePoint2, Vector3 lineVec2) - { + //Two non-parallel lines which may or may not touch each other have a point on each line which are closest + //to each other. This function finds those two points. If the lines are not parallel, the function + //outputs true, otherwise false. + public static bool ClosestPointsOnTwoLines(out Vector3 closestPointLine1, out Vector3 closestPointLine2, Vector3 linePoint1, Vector3 lineVec1, Vector3 linePoint2, Vector3 lineVec2) + { - closestPointLine1 = Vector3.zero; - closestPointLine2 = Vector3.zero; + closestPointLine1 = Vector3.zero; + closestPointLine2 = Vector3.zero; - float a = Vector3.Dot(lineVec1, lineVec1); - float b = Vector3.Dot(lineVec1, lineVec2); - float e = Vector3.Dot(lineVec2, lineVec2); + float a = Vector3.Dot(lineVec1, lineVec1); + float b = Vector3.Dot(lineVec1, lineVec2); + float e = Vector3.Dot(lineVec2, lineVec2); - float d = a * e - b * b; + float d = a * e - b * b; - //lines are not parallel - if (d != 0.0f) - { + //lines are not parallel + if (d != 0.0f) + { - Vector3 r = linePoint1 - linePoint2; - float c = Vector3.Dot(lineVec1, r); - float f = Vector3.Dot(lineVec2, r); + Vector3 r = linePoint1 - linePoint2; + float c = Vector3.Dot(lineVec1, r); + float f = Vector3.Dot(lineVec2, r); - float s = (b * f - c * e) / d; - float t = (a * f - c * b) / d; + float s = (b * f - c * e) / d; + float t = (a * f - c * b) / d; - closestPointLine1 = linePoint1 + lineVec1 * s; - closestPointLine2 = linePoint2 + lineVec2 * t; + closestPointLine1 = linePoint1 + lineVec1 * s; + closestPointLine2 = linePoint2 + lineVec2 * t; - return true; - } + return true; + } - else - { - return false; - } - } + else + { + return false; + } + } - //This function returns a point which is a projection from a point to a line. - //The line is regarded infinite. If the line is finite, use ProjectPointOnLineSegment() instead. - public static Vector3 ProjectPointOnLine(Vector3 linePoint, Vector3 lineVec, Vector3 point) - { + //This function returns a point which is a projection from a point to a line. + //The line is regarded infinite. If the line is finite, use ProjectPointOnLineSegment() instead. + public static Vector3 ProjectPointOnLine(Vector3 linePoint, Vector3 lineVec, Vector3 point) + { - //get vector from point on line to point in space - Vector3 linePointToPoint = point - linePoint; + //get vector from point on line to point in space + Vector3 linePointToPoint = point - linePoint; - float t = Vector3.Dot(linePointToPoint, lineVec); + float t = Vector3.Dot(linePointToPoint, lineVec); - return linePoint + lineVec * t; - } + return linePoint + lineVec * t; + } - //This function returns true if a point is on a line. - //The line is regarded infinite. - public static bool IsPointOnLine(Vector3 linePoint, Vector3 lineVec, Vector3 point) - { + //This function returns true if a point is on a line. + //The line is regarded infinite. + public static bool IsPointOnLine(Vector3 linePoint, Vector3 lineVec, Vector3 point) + { - //get vector from point on line to point in space - Vector3 linePointToPoint = point - linePoint; + //get vector from point on line to point in space + Vector3 linePointToPoint = point - linePoint; - float t = Vector3.Dot(linePointToPoint, lineVec); + float t = Vector3.Dot(linePointToPoint, lineVec); - return t == 0; - } + return t == 0; + } - //This function returns true if a point is approximately on a line. - //The line is regarded infinite. - public static bool IsPointApproximatelyOnLine(Vector3 linePoint, Vector3 lineVec, Vector3 point, float precission = Math3d.vectorPrecission) - { + //This function returns true if a point is approximately on a line. + //The line is regarded infinite. + public static bool IsPointApproximatelyOnLine(Vector3 linePoint, Vector3 lineVec, Vector3 point, double precission = Math3d.vectorPrecission) + { - //get vector from point on line to point in space - Vector3 linePointToPoint = point - linePoint; + //get vector from point on line to point in space + Vector3 linePointToPoint = point - linePoint; - float t = Vector3.Dot(linePointToPoint, lineVec); + double t = Vector3.Dot(linePointToPoint.normalized, lineVec); - return t < precission; - } + return Math.Abs(t - 1d) < precission || Math.Abs(t) < precission; + } - //This function returns a point which is a projection from a point to a line segment. - //If the projected point lies outside of the line segment, the projected point will - //be clamped to the appropriate line edge. - //If the line is infinite instead of a segment, use ProjectPointOnLine() instead. - public static Vector3 ProjectPointOnLineSegment(Vector3 linePoint1, Vector3 linePoint2, Vector3 point) - { + //This function returns a point which is a projection from a point to a line segment. + //If the projected point lies outside of the line segment, the projected point will + //be clamped to the appropriate line edge. + //If the line is infinite instead of a segment, use ProjectPointOnLine() instead. + public static Vector3 ProjectPointOnLineSegment(Vector3 linePoint1, Vector3 linePoint2, Vector3 point) + { - Vector3 vector = linePoint2 - linePoint1; + Vector3 vector = linePoint2 - linePoint1; - Vector3 projectedPoint = ProjectPointOnLine(linePoint1, vector.normalized, point); + Vector3 projectedPoint = ProjectPointOnLine(linePoint1, vector.normalized, point); - int side = PointOnWhichSideOfLineSegment(linePoint1, linePoint2, projectedPoint); + int side = PointOnWhichSideOfLineSegment(linePoint1, linePoint2, projectedPoint); - //The projected point is on the line segment - if (side == 0) - { + //The projected point is on the line segment + if (side == 0) + { - return projectedPoint; - } + return projectedPoint; + } - if (side == 1) - { + if (side == 1) + { - return linePoint1; - } + return linePoint1; + } - if (side == 2) - { + if (side == 2) + { - return linePoint2; - } + return linePoint2; + } - //output is invalid - return Vector3.zero; - } + //output is invalid + return Vector3.zero; + } - //This function returns a point which is a projection from a point to a plane. - public static Vector3 ProjectPointOnPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 point) - { + //This function returns a point which is a projection from a point to a plane. + public static Vector3 ProjectPointOnPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 point) + { - float distance; - Vector3 translationVector; + float distance; + Vector3 translationVector; - //First calculate the distance from the point to the plane: - distance = SignedDistancePlanePoint(planeNormal, planePoint, point); + //First calculate the distance from the point to the plane: + distance = SignedDistancePlanePoint(planeNormal, planePoint, point); - //Reverse the sign of the distance - distance *= -1; + //Reverse the sign of the distance + distance *= -1; - //Get a translation vector - translationVector = SetVectorLength(planeNormal, distance); + //Get a translation vector + translationVector = SetVectorLength(planeNormal, distance); - //Translate the point to form a projection - return point + translationVector; - } + //Translate the point to form a projection + return point + translationVector; + } - //Projects a vector onto a plane. The output is not normalized. - public static Vector3 ProjectVectorOnPlane(Vector3 planeNormal, Vector3 vector) - { + //Projects a vector onto a plane. The output is not normalized. + public static Vector3 ProjectVectorOnPlane(Vector3 planeNormal, Vector3 vector) + { - return vector - (Vector3.Dot(vector, planeNormal) * planeNormal); - } + return vector - (Vector3.Dot(vector, planeNormal) * planeNormal); + } - //Get the shortest distance between a point and a plane. The output is signed so it holds information - //as to which side of the plane normal the point is. - public static float SignedDistancePlanePoint(Vector3 planeNormal, Vector3 planePoint, Vector3 point) - { + //Get the shortest distance between a point and a plane. The output is signed so it holds information + //as to which side of the plane normal the point is. + public static float SignedDistancePlanePoint(Vector3 planeNormal, Vector3 planePoint, Vector3 point) + { - return Vector3.Dot(planeNormal, (point - planePoint)); - } + return Vector3.Dot(planeNormal, (point - planePoint)); + } - //This function calculates a signed (+ or - sign instead of being ambiguous) dot product. It is basically used - //to figure out whether a vector is positioned to the left or right of another vector. The way this is done is - //by calculating a vector perpendicular to one of the vectors and using that as a reference. This is because - //the result of a dot product only has signed information when an angle is transitioning between more or less - //than 90 degrees. - public static float SignedDotProduct(Vector3 vectorA, Vector3 vectorB, Vector3 normal) - { + //This function calculates a signed (+ or - sign instead of being ambiguous) dot product. It is basically used + //to figure out whether a vector is positioned to the left or right of another vector. The way this is done is + //by calculating a vector perpendicular to one of the vectors and using that as a reference. This is because + //the result of a dot product only has signed information when an angle is transitioning between more or less + //than 90 degrees. + public static float SignedDotProduct(Vector3 vectorA, Vector3 vectorB, Vector3 normal) + { - Vector3 perpVector; - float dot; + Vector3 perpVector; + float dot; - //Use the geometry object normal and one of the input vectors to calculate the perpendicular vector - perpVector = Vector3.Cross(normal, vectorA); + //Use the geometry object normal and one of the input vectors to calculate the perpendicular vector + perpVector = Vector3.Cross(normal, vectorA); - //Now calculate the dot product between the perpendicular vector (perpVector) and the other input vector - dot = Vector3.Dot(perpVector, vectorB); + //Now calculate the dot product between the perpendicular vector (perpVector) and the other input vector + dot = Vector3.Dot(perpVector, vectorB); - return dot; - } + return dot; + } - public static float SignedVectorAngle(Vector3 referenceVector, Vector3 otherVector, Vector3 normal) - { - Vector3 perpVector; - float angle; + public static float SignedVectorAngle(Vector3 referenceVector, Vector3 otherVector, Vector3 normal) + { + Vector3 perpVector; + float angle; - //Use the geometry object normal and one of the input vectors to calculate the perpendicular vector - perpVector = Vector3.Cross(normal, referenceVector); + //Use the geometry object normal and one of the input vectors to calculate the perpendicular vector + perpVector = Vector3.Cross(normal, referenceVector); - //Now calculate the dot product between the perpendicular vector (perpVector) and the other input vector - angle = Vector3.Angle(referenceVector, otherVector); - angle *= Mathf.Sign(Vector3.Dot(perpVector, otherVector)); + //Now calculate the dot product between the perpendicular vector (perpVector) and the other input vector + angle = Vector3.Angle(referenceVector, otherVector); + angle *= Mathf.Sign(Vector3.Dot(perpVector, otherVector)); - return angle; - } + return angle; + } - //Calculate the angle between a vector and a plane. The plane is made by a normal vector. - //Output is in radians. - public static float AngleVectorPlane(Vector3 vector, Vector3 normal) - { + //Calculate the angle between a vector and a plane. The plane is made by a normal vector. + //Output is in radians. + public static float AngleVectorPlane(Vector3 vector, Vector3 normal) + { - float dot; - float angle; + float dot; + float angle; - //calculate the the dot product between the two input vectors. This gives the cosine between the two vectors - dot = Vector3.Dot(vector, normal); + //calculate the the dot product between the two input vectors. This gives the cosine between the two vectors + dot = Vector3.Dot(vector, normal); - //this is in radians - angle = (float)Math.Acos(dot); + //this is in radians + angle = (float)Math.Acos(dot); - return 1.570796326794897f - angle; //90 degrees - angle - } + return 1.570796326794897f - angle; //90 degrees - angle + } - //Calculate the dot product as an angle - public static float DotProductAngle(Vector3 vec1, Vector3 vec2) - { + //Calculate the dot product as an angle + public static float DotProductAngle(Vector3 vec1, Vector3 vec2) + { - double dot; - double angle; + double dot; + double angle; - //get the dot product - dot = Vector3.Dot(vec1, vec2); + //get the dot product + dot = Vector3.Dot(vec1, vec2); - //Clamp to prevent NaN error. Shouldn't need this in the first place, but there could be a rounding error issue. - if (dot < -1.0f) - { - dot = -1.0f; - } - if (dot > 1.0f) - { - dot = 1.0f; - } + //Clamp to prevent NaN error. Shouldn't need this in the first place, but there could be a rounding error issue. + if (dot < -1.0f) + { + dot = -1.0f; + } + if (dot > 1.0f) + { + dot = 1.0f; + } - //Calculate the angle. The output is in radians - //This step can be skipped for optimization... - angle = Math.Acos(dot); - - return (float)angle; - } - - //Convert a plane defined by 3 points to a plane defined by a vector and a point. - //The plane point is the middle of the triangle defined by the 3 points. - public static void PlaneFrom3Points(out Vector3 planeNormal, out Vector3 planePoint, Vector3 pointA, Vector3 pointB, Vector3 pointC) - { - - planeNormal = Vector3.zero; - planePoint = Vector3.zero; - - //Make two vectors from the 3 input points, originating from point A - Vector3 AB = pointB - pointA; - Vector3 AC = pointC - pointA; - - //Calculate the normal - planeNormal = Vector3.Normalize(Vector3.Cross(AB, AC)); - - //Get the points in the middle AB and AC - Vector3 middleAB = pointA + (AB / 2.0f); - Vector3 middleAC = pointA + (AC / 2.0f); - - //Get vectors from the middle of AB and AC to the point which is not on that line. - Vector3 middleABtoC = pointC - middleAB; - Vector3 middleACtoB = pointB - middleAC; - - //Calculate the intersection between the two lines. This will be the center - //of the triangle defined by the 3 points. - //We could use LineLineIntersection instead of ClosestPointsOnTwoLines but due to rounding errors - //this sometimes doesn't work. - Vector3 temp; - ClosestPointsOnTwoLines(out planePoint, out temp, middleAB, middleABtoC, middleAC, middleACtoB); - } - - //Returns the forward vector of a quaternion - public static Vector3 GetForwardVector(Quaternion q) - { - - return q * Vector3.forward; - } - - //Returns the up vector of a quaternion - public static Vector3 GetUpVector(Quaternion q) - { - - return q * Vector3.up; - } - - //Returns the right vector of a quaternion - public static Vector3 GetRightVector(Quaternion q) - { - - return q * Vector3.right; - } - - //Gets a quaternion from a matrix - public static Quaternion QuaternionFromMatrix(Matrix4x4 m) - { - - return Quaternion.LookRotation(m.GetColumn(2), m.GetColumn(1)); - } - - //Gets a position from a matrix - public static Vector3 PositionFromMatrix(Matrix4x4 m) - { - - Vector4 vector4Position = m.GetColumn(3); - return new Vector3(vector4Position.x, vector4Position.y, vector4Position.z); - } - - //This is an alternative for Quaternion.LookRotation. Instead of aligning the forward and up vector of the game - //object with the input vectors, a custom direction can be used instead of the fixed forward and up vectors. - //alignWithVector and alignWithNormal are in world space. - //customForward and customUp are in object space. - //Usage: use alignWithVector and alignWithNormal as if you are using the default LookRotation function. - //Set customForward and customUp to the vectors you wish to use instead of the default forward and up vectors. - public static void LookRotationExtended(ref GameObject gameObjectInOut, Vector3 alignWithVector, Vector3 alignWithNormal, Vector3 customForward, Vector3 customUp) - { - - //Set the rotation of the destination - Quaternion rotationA = Quaternion.LookRotation(alignWithVector, alignWithNormal); - - //Set the rotation of the custom normal and up vectors. - //When using the default LookRotation function, this would be hard coded to the forward and up vector. - Quaternion rotationB = Quaternion.LookRotation(customForward, customUp); - - //Calculate the rotation - gameObjectInOut.transform.rotation = rotationA * Quaternion.Inverse(rotationB); - } - - //This function transforms one object as if it was parented to the other. - //Before using this function, the Init() function must be called - //Input: parentRotation and parentPosition: the current parent transform. - //Input: startParentRotation and startParentPosition: the transform of the parent object at the time the objects are parented. - //Input: startChildRotation and startChildPosition: the transform of the child object at the time the objects are parented. - //Output: childRotation and childPosition. - //All transforms are in world space. - public static void TransformWithParent(out Quaternion childRotation, out Vector3 childPosition, Quaternion parentRotation, Vector3 parentPosition, Quaternion startParentRotation, Vector3 startParentPosition, Quaternion startChildRotation, Vector3 startChildPosition) - { - - childRotation = Quaternion.identity; - childPosition = Vector3.zero; - - //set the parent start transform - tempParent.rotation = startParentRotation; - tempParent.position = startParentPosition; - tempParent.localScale = Vector3.one; //to prevent scale wandering - - //set the child start transform - tempChild.rotation = startChildRotation; - tempChild.position = startChildPosition; - tempChild.localScale = Vector3.one; //to prevent scale wandering - - //translate and rotate the child by moving the parent - tempParent.rotation = parentRotation; - tempParent.position = parentPosition; - - //get the child transform - childRotation = tempChild.rotation; - childPosition = tempChild.position; - } - - //With this function you can align a triangle of an object with any transform. - //Usage: gameObjectInOut is the game object you want to transform. - //alignWithVector, alignWithNormal, and alignWithPosition is the transform with which the triangle of the object should be aligned with. - //triangleForward, triangleNormal, and trianglePosition is the transform of the triangle from the object. - //alignWithVector, alignWithNormal, and alignWithPosition are in world space. - //triangleForward, triangleNormal, and trianglePosition are in object space. - //trianglePosition is the mesh position of the triangle. The effect of the scale of the object is handled automatically. - //trianglePosition can be set at any position, it does not have to be at a vertex or in the middle of the triangle. - public static void PreciseAlign(ref GameObject gameObjectInOut, Vector3 alignWithVector, Vector3 alignWithNormal, Vector3 alignWithPosition, Vector3 triangleForward, Vector3 triangleNormal, Vector3 trianglePosition) - { - - //Set the rotation. - LookRotationExtended(ref gameObjectInOut, alignWithVector, alignWithNormal, triangleForward, triangleNormal); - - //Get the world space position of trianglePosition - Vector3 trianglePositionWorld = gameObjectInOut.transform.TransformPoint(trianglePosition); - - //Get a vector from trianglePosition to alignWithPosition - Vector3 translateVector = alignWithPosition - trianglePositionWorld; - - //Now transform the object so the triangle lines up correctly. - gameObjectInOut.transform.Translate(translateVector, Space.World); - } - - - //Convert a position, direction, and normal vector to a transform - public static void VectorsToTransform(ref GameObject gameObjectInOut, Vector3 positionVector, Vector3 directionVector, Vector3 normalVector) - { - - gameObjectInOut.transform.position = positionVector; - gameObjectInOut.transform.rotation = Quaternion.LookRotation(directionVector, normalVector); - } - - //This function finds out on which side of a line segment the point is located. - //The point is assumed to be on a line created by linePoint1 and linePoint2. If the point is not on - //the line segment, project it on the line using ProjectPointOnLine() first. - //Returns 0 if point is on the line segment. - //Returns 1 if point is outside of the line segment and located on the side of linePoint1. - //Returns 2 if point is outside of the line segment and located on the side of linePoint2. - public static int PointOnWhichSideOfLineSegment(Vector3 linePoint1, Vector3 linePoint2, Vector3 point) - { - - Vector3 lineVec = linePoint2 - linePoint1; - Vector3 pointVec = point - linePoint1; - - float dot = Vector3.Dot(pointVec, lineVec); - - //point is on side of linePoint2, compared to linePoint1 - if (dot > 0) - { - - //point is on the line segment - if (pointVec.magnitude <= lineVec.magnitude) - { - - return 0; - } - - //point is not on the line segment and it is on the side of linePoint2 - else - { - - return 2; - } - } - - //Point is not on side of linePoint2, compared to linePoint1. - //Point is not on the line segment and it is on the side of linePoint1. - else - { - - return 1; - } - } + //Calculate the angle. The output is in radians + //This step can be skipped for optimization... + angle = Math.Acos(dot); + + return (float)angle; + } + + //Convert a plane defined by 3 points to a plane defined by a vector and a point. + //The plane point is the middle of the triangle defined by the 3 points. + public static void PlaneFrom3Points(out Vector3 planeNormal, out Vector3 planePoint, Vector3 pointA, Vector3 pointB, Vector3 pointC) + { + + planeNormal = Vector3.zero; + planePoint = Vector3.zero; + + //Make two vectors from the 3 input points, originating from point A + Vector3 AB = pointB - pointA; + Vector3 AC = pointC - pointA; + + //Calculate the normal + planeNormal = Vector3.Normalize(Vector3.Cross(AB, AC)); + + //Get the points in the middle AB and AC + Vector3 middleAB = pointA + (AB / 2.0f); + Vector3 middleAC = pointA + (AC / 2.0f); + + //Get vectors from the middle of AB and AC to the point which is not on that line. + Vector3 middleABtoC = pointC - middleAB; + Vector3 middleACtoB = pointB - middleAC; + + //Calculate the intersection between the two lines. This will be the center + //of the triangle defined by the 3 points. + //We could use LineLineIntersection instead of ClosestPointsOnTwoLines but due to rounding errors + //this sometimes doesn't work. + Vector3 temp; + ClosestPointsOnTwoLines(out planePoint, out temp, middleAB, middleABtoC, middleAC, middleACtoB); + } + + //Returns the forward vector of a quaternion + public static Vector3 GetForwardVector(Quaternion q) + { + + return q * Vector3.forward; + } + + //Returns the up vector of a quaternion + public static Vector3 GetUpVector(Quaternion q) + { + + return q * Vector3.up; + } + + //Returns the right vector of a quaternion + public static Vector3 GetRightVector(Quaternion q) + { + + return q * Vector3.right; + } + + //Gets a quaternion from a matrix + public static Quaternion QuaternionFromMatrix(Matrix4x4 m) + { + + return Quaternion.LookRotation(m.GetColumn(2), m.GetColumn(1)); + } + + //Gets a position from a matrix + public static Vector3 PositionFromMatrix(Matrix4x4 m) + { + + Vector4 vector4Position = m.GetColumn(3); + return new Vector3(vector4Position.x, vector4Position.y, vector4Position.z); + } + + //This is an alternative for Quaternion.LookRotation. Instead of aligning the forward and up vector of the game + //object with the input vectors, a custom direction can be used instead of the fixed forward and up vectors. + //alignWithVector and alignWithNormal are in world space. + //customForward and customUp are in object space. + //Usage: use alignWithVector and alignWithNormal as if you are using the default LookRotation function. + //Set customForward and customUp to the vectors you wish to use instead of the default forward and up vectors. + public static void LookRotationExtended(ref GameObject gameObjectInOut, Vector3 alignWithVector, Vector3 alignWithNormal, Vector3 customForward, Vector3 customUp) + { + + //Set the rotation of the destination + Quaternion rotationA = Quaternion.LookRotation(alignWithVector, alignWithNormal); + + //Set the rotation of the custom normal and up vectors. + //When using the default LookRotation function, this would be hard coded to the forward and up vector. + Quaternion rotationB = Quaternion.LookRotation(customForward, customUp); + + //Calculate the rotation + gameObjectInOut.transform.rotation = rotationA * Quaternion.Inverse(rotationB); + } + + //This function transforms one object as if it was parented to the other. + //Before using this function, the Init() function must be called + //Input: parentRotation and parentPosition: the current parent transform. + //Input: startParentRotation and startParentPosition: the transform of the parent object at the time the objects are parented. + //Input: startChildRotation and startChildPosition: the transform of the child object at the time the objects are parented. + //Output: childRotation and childPosition. + //All transforms are in world space. + public static void TransformWithParent(out Quaternion childRotation, out Vector3 childPosition, Quaternion parentRotation, Vector3 parentPosition, Quaternion startParentRotation, Vector3 startParentPosition, Quaternion startChildRotation, Vector3 startChildPosition) + { + + childRotation = Quaternion.identity; + childPosition = Vector3.zero; + + //set the parent start transform + tempParent.rotation = startParentRotation; + tempParent.position = startParentPosition; + tempParent.localScale = Vector3.one; //to prevent scale wandering + + //set the child start transform + tempChild.rotation = startChildRotation; + tempChild.position = startChildPosition; + tempChild.localScale = Vector3.one; //to prevent scale wandering + + //translate and rotate the child by moving the parent + tempParent.rotation = parentRotation; + tempParent.position = parentPosition; + + //get the child transform + childRotation = tempChild.rotation; + childPosition = tempChild.position; + } + + //With this function you can align a triangle of an object with any transform. + //Usage: gameObjectInOut is the game object you want to transform. + //alignWithVector, alignWithNormal, and alignWithPosition is the transform with which the triangle of the object should be aligned with. + //triangleForward, triangleNormal, and trianglePosition is the transform of the triangle from the object. + //alignWithVector, alignWithNormal, and alignWithPosition are in world space. + //triangleForward, triangleNormal, and trianglePosition are in object space. + //trianglePosition is the mesh position of the triangle. The effect of the scale of the object is handled automatically. + //trianglePosition can be set at any position, it does not have to be at a vertex or in the middle of the triangle. + public static void PreciseAlign(ref GameObject gameObjectInOut, Vector3 alignWithVector, Vector3 alignWithNormal, Vector3 alignWithPosition, Vector3 triangleForward, Vector3 triangleNormal, Vector3 trianglePosition) + { + + //Set the rotation. + LookRotationExtended(ref gameObjectInOut, alignWithVector, alignWithNormal, triangleForward, triangleNormal); + + //Get the world space position of trianglePosition + Vector3 trianglePositionWorld = gameObjectInOut.transform.TransformPoint(trianglePosition); + + //Get a vector from trianglePosition to alignWithPosition + Vector3 translateVector = alignWithPosition - trianglePositionWorld; + + //Now transform the object so the triangle lines up correctly. + gameObjectInOut.transform.Translate(translateVector, Space.World); + } + + + //Convert a position, direction, and normal vector to a transform + public static void VectorsToTransform(ref GameObject gameObjectInOut, Vector3 positionVector, Vector3 directionVector, Vector3 normalVector) + { + + gameObjectInOut.transform.position = positionVector; + gameObjectInOut.transform.rotation = Quaternion.LookRotation(directionVector, normalVector); + } + + //This function finds out on which side of a line segment the point is located. + //The point is assumed to be on a line created by linePoint1 and linePoint2. If the point is not on + //the line segment, project it on the line using ProjectPointOnLine() first. + //Returns 0 if point is on the line segment. + //Returns 1 if point is outside of the line segment and located on the side of linePoint1. + //Returns 2 if point is outside of the line segment and located on the side of linePoint2. + public static int PointOnWhichSideOfLineSegment(Vector3 linePoint1, Vector3 linePoint2, Vector3 point) + { + + Vector3 lineVec = linePoint2 - linePoint1; + Vector3 pointVec = point - linePoint1; + + float dot = Vector3.Dot(pointVec, lineVec); + + //point is on side of linePoint2, compared to linePoint1 + if (dot > 0) + { + + //point is on the line segment + if (pointVec.magnitude <= lineVec.magnitude) + { + + return 0; + } + + //point is not on the line segment and it is on the side of linePoint2 + else + { + + return 2; + } + } + + //Point is not on side of linePoint2, compared to linePoint1. + //Point is not on the line segment and it is on the side of linePoint1. + else + { + + return 1; + } + } - //Returns the pixel distance from the mouse pointer to a line. - //Alternative for HandleUtility.DistanceToLine(). Works both in Editor mode and Play mode. - //Do not call this function from OnGUI() as the mouse position will be wrong. - public static float MouseDistanceToLine(Vector3 linePoint1, Vector3 linePoint2) - { - - Camera currentCamera; - Vector3 mousePosition; + //Returns the pixel distance from the mouse pointer to a line. + //Alternative for HandleUtility.DistanceToLine(). Works both in Editor mode and Play mode. + //Do not call this function from OnGUI() as the mouse position will be wrong. + public static float MouseDistanceToLine(Vector3 linePoint1, Vector3 linePoint2) + { + + Camera currentCamera; + Vector3 mousePosition; #if UNITY_EDITOR - if(Camera.current != null){ - - currentCamera = Camera.current; - } - - else{ - - currentCamera = Camera.main; - } - - //convert format because y is flipped - mousePosition = new Vector3(Event.current.mousePosition.x, currentCamera.pixelHeight - Event.current.mousePosition.y, 0f); - + if (Camera.current != null) + { + + currentCamera = Camera.current; + } + + else + { + + currentCamera = Camera.main; + } + + //convert format because y is flipped + mousePosition = new Vector3(Event.current.mousePosition.x, currentCamera.pixelHeight - Event.current.mousePosition.y, 0f); + #else currentCamera = Camera.main; mousePosition = Input.mousePosition; #endif - Vector3 screenPos1 = currentCamera.WorldToScreenPoint(linePoint1); - Vector3 screenPos2 = currentCamera.WorldToScreenPoint(linePoint2); - Vector3 projectedPoint = ProjectPointOnLineSegment(screenPos1, screenPos2, mousePosition); + Vector3 screenPos1 = currentCamera.WorldToScreenPoint(linePoint1); + Vector3 screenPos2 = currentCamera.WorldToScreenPoint(linePoint2); + Vector3 projectedPoint = ProjectPointOnLineSegment(screenPos1, screenPos2, mousePosition); - //set z to zero - projectedPoint = new Vector3(projectedPoint.x, projectedPoint.y, 0f); + //set z to zero + projectedPoint = new Vector3(projectedPoint.x, projectedPoint.y, 0f); - Vector3 vector = projectedPoint - mousePosition; - return vector.magnitude; - } + Vector3 vector = projectedPoint - mousePosition; + return vector.magnitude; + } - //Returns the pixel distance from the mouse pointer to a camera facing circle. - //Alternative for HandleUtility.DistanceToCircle(). Works both in Editor mode and Play mode. - //Do not call this function from OnGUI() as the mouse position will be wrong. - //If you want the distance to a point instead of a circle, set the radius to 0. - public static float MouseDistanceToCircle(Vector3 point, float radius) - { + //Returns the pixel distance from the mouse pointer to a camera facing circle. + //Alternative for HandleUtility.DistanceToCircle(). Works both in Editor mode and Play mode. + //Do not call this function from OnGUI() as the mouse position will be wrong. + //If you want the distance to a point instead of a circle, set the radius to 0. + public static float MouseDistanceToCircle(Vector3 point, float radius) + { - Camera currentCamera; - Vector3 mousePosition; + Camera currentCamera; + Vector3 mousePosition; #if UNITY_EDITOR - if(Camera.current != null){ - - currentCamera = Camera.current; - } - - else{ - - currentCamera = Camera.main; - } - - //convert format because y is flipped - mousePosition = new Vector3(Event.current.mousePosition.x, currentCamera.pixelHeight - Event.current.mousePosition.y, 0f); + if (Camera.current != null) + { + + currentCamera = Camera.current; + } + + else + { + + currentCamera = Camera.main; + } + + //convert format because y is flipped + mousePosition = new Vector3(Event.current.mousePosition.x, currentCamera.pixelHeight - Event.current.mousePosition.y, 0f); #else currentCamera = Camera.main; mousePosition = Input.mousePosition; #endif - Vector3 screenPos = currentCamera.WorldToScreenPoint(point); + Vector3 screenPos = currentCamera.WorldToScreenPoint(point); - //set z to zero - screenPos = new Vector3(screenPos.x, screenPos.y, 0f); + //set z to zero + screenPos = new Vector3(screenPos.x, screenPos.y, 0f); - Vector3 vector = screenPos - mousePosition; - float fullDistance = vector.magnitude; - float circleDistance = fullDistance - radius; + Vector3 vector = screenPos - mousePosition; + float fullDistance = vector.magnitude; + float circleDistance = fullDistance - radius; - return circleDistance; - } + return circleDistance; + } - //Returns true if a line segment (made up of linePoint1 and linePoint2) is fully or partially in a rectangle - //made up of RectA to RectD. The line segment is assumed to be on the same plane as the rectangle. If the line is - //not on the plane, use ProjectPointOnPlane() on linePoint1 and linePoint2 first. - public static bool IsLineInRectangle(Vector3 linePoint1, Vector3 linePoint2, Vector3 rectA, Vector3 rectB, Vector3 rectC, Vector3 rectD) - { + //Returns true if a line segment (made up of linePoint1 and linePoint2) is fully or partially in a rectangle + //made up of RectA to RectD. The line segment is assumed to be on the same plane as the rectangle. If the line is + //not on the plane, use ProjectPointOnPlane() on linePoint1 and linePoint2 first. + public static bool IsLineInRectangle(Vector3 linePoint1, Vector3 linePoint2, Vector3 rectA, Vector3 rectB, Vector3 rectC, Vector3 rectD) + { - bool pointAInside = false; - bool pointBInside = false; + bool pointAInside = false; + bool pointBInside = false; - pointAInside = IsPointInRectangle(linePoint1, rectA, rectC, rectB, rectD); + pointAInside = IsPointInRectangle(linePoint1, rectA, rectC, rectB, rectD); - if (!pointAInside) - { + if (!pointAInside) + { - pointBInside = IsPointInRectangle(linePoint2, rectA, rectC, rectB, rectD); - } + pointBInside = IsPointInRectangle(linePoint2, rectA, rectC, rectB, rectD); + } - //none of the points are inside, so check if a line is crossing - if (!pointAInside && !pointBInside) - { + //none of the points are inside, so check if a line is crossing + if (!pointAInside && !pointBInside) + { - bool lineACrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectA, rectB); - bool lineBCrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectB, rectC); - bool lineCCrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectC, rectD); - bool lineDCrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectD, rectA); + bool lineACrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectA, rectB); + bool lineBCrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectB, rectC); + bool lineCCrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectC, rectD); + bool lineDCrossing = AreLineSegmentsCrossing(linePoint1, linePoint2, rectD, rectA); - if (lineACrossing || lineBCrossing || lineCCrossing || lineDCrossing) - { + if (lineACrossing || lineBCrossing || lineCCrossing || lineDCrossing) + { - return true; - } + return true; + } - else - { + else + { - return false; - } - } + return false; + } + } - else - { + else + { - return true; - } - } + return true; + } + } - //Returns true if "point" is in a rectangle mad up of RectA to RectD. The line point is assumed to be on the same - //plane as the rectangle. If the point is not on the plane, use ProjectPointOnPlane() first. - public static bool IsPointInRectangle(Vector3 point, Vector3 rectA, Vector3 rectC, Vector3 rectB, Vector3 rectD) - { + //Returns true if "point" is in a rectangle mad up of RectA to RectD. The line point is assumed to be on the same + //plane as the rectangle. If the point is not on the plane, use ProjectPointOnPlane() first. + public static bool IsPointInRectangle(Vector3 point, Vector3 rectA, Vector3 rectC, Vector3 rectB, Vector3 rectD) + { - Vector3 vector; - Vector3 linePoint; + Vector3 vector; + Vector3 linePoint; - //get the center of the rectangle - vector = rectC - rectA; - float size = -(vector.magnitude / 2f); - vector = AddVectorLength(vector, size); - Vector3 middle = rectA + vector; + //get the center of the rectangle + vector = rectC - rectA; + float size = -(vector.magnitude / 2f); + vector = AddVectorLength(vector, size); + Vector3 middle = rectA + vector; - Vector3 xVector = rectB - rectA; - float width = xVector.magnitude / 2f; + Vector3 xVector = rectB - rectA; + float width = xVector.magnitude / 2f; - Vector3 yVector = rectD - rectA; - float height = yVector.magnitude / 2f; + Vector3 yVector = rectD - rectA; + float height = yVector.magnitude / 2f; - linePoint = ProjectPointOnLine(middle, xVector.normalized, point); - vector = linePoint - point; - float yDistance = vector.magnitude; + linePoint = ProjectPointOnLine(middle, xVector.normalized, point); + vector = linePoint - point; + float yDistance = vector.magnitude; - linePoint = ProjectPointOnLine(middle, yVector.normalized, point); - vector = linePoint - point; - float xDistance = vector.magnitude; + linePoint = ProjectPointOnLine(middle, yVector.normalized, point); + vector = linePoint - point; + float xDistance = vector.magnitude; - if ((xDistance <= width) && (yDistance <= height)) - { + if ((xDistance <= width) && (yDistance <= height)) + { - return true; - } + return true; + } - else - { + else + { - return false; - } - } + return false; + } + } - //Returns true if line segment made up of pointA1 and pointA2 is crossing line segment made up of - //pointB1 and pointB2. The two lines are assumed to be in the same plane. - public static bool AreLineSegmentsCrossing(Vector3 pointA1, Vector3 pointA2, Vector3 pointB1, Vector3 pointB2) - { + //Returns true if line segment made up of pointA1 and pointA2 is crossing line segment made up of + //pointB1 and pointB2. The two lines are assumed to be in the same plane. + public static bool AreLineSegmentsCrossing(Vector3 pointA1, Vector3 pointA2, Vector3 pointB1, Vector3 pointB2) + { - Vector3 closestPointA; - Vector3 closestPointB; - int sideA; - int sideB; + Vector3 closestPointA; + Vector3 closestPointB; + int sideA; + int sideB; - Vector3 lineVecA = pointA2 - pointA1; - Vector3 lineVecB = pointB2 - pointB1; + Vector3 lineVecA = pointA2 - pointA1; + Vector3 lineVecB = pointB2 - pointB1; - bool valid = ClosestPointsOnTwoLines(out closestPointA, out closestPointB, pointA1, lineVecA.normalized, pointB1, lineVecB.normalized); + bool valid = ClosestPointsOnTwoLines(out closestPointA, out closestPointB, pointA1, lineVecA.normalized, pointB1, lineVecB.normalized); - //lines are not parallel - if (valid) - { + //lines are not parallel + if (valid) + { - sideA = PointOnWhichSideOfLineSegment(pointA1, pointA2, closestPointA); - sideB = PointOnWhichSideOfLineSegment(pointB1, pointB2, closestPointB); + sideA = PointOnWhichSideOfLineSegment(pointA1, pointA2, closestPointA); + sideB = PointOnWhichSideOfLineSegment(pointB1, pointB2, closestPointB); - if ((sideA == 0) && (sideB == 0)) - { + if ((sideA == 0) && (sideB == 0)) + { - return true; - } + return true; + } - else - { + else + { - return false; - } - } + return false; + } + } - //lines are parallel - else - { + //lines are parallel + else + { - return false; - } - } + return false; + } + } - //This function calculates the acceleration vector in meter/second^2. - //Input: position. If the output is used for motion simulation, the input transform - //has to be located at the seat base, not at the vehicle CG. Attach an empty GameObject - //at the correct location and use that as the input for this function. - //Gravity is not taken into account but this can be added to the output if needed. - //A low number of samples can give a jittery result due to rounding errors. - //If more samples are used, the output is more smooth but has a higher latency. - public static bool LinearAcceleration(out Vector3 vector, Vector3 position, int samples) - { + //This function calculates the acceleration vector in meter/second^2. + //Input: position. If the output is used for motion simulation, the input transform + //has to be located at the seat base, not at the vehicle CG. Attach an empty GameObject + //at the correct location and use that as the input for this function. + //Gravity is not taken into account but this can be added to the output if needed. + //A low number of samples can give a jittery result due to rounding errors. + //If more samples are used, the output is more smooth but has a higher latency. + public static bool LinearAcceleration(out Vector3 vector, Vector3 position, int samples) + { - Vector3 averageSpeedChange = Vector3.zero; - vector = Vector3.zero; - Vector3 deltaDistance; - float deltaTime; - Vector3 speedA; - Vector3 speedB; + Vector3 averageSpeedChange = Vector3.zero; + vector = Vector3.zero; + Vector3 deltaDistance; + float deltaTime; + Vector3 speedA; + Vector3 speedB; - //Clamp sample amount. In order to calculate acceleration we need at least 2 changes - //in speed, so we need at least 3 position samples. - if (samples < 3) - { + //Clamp sample amount. In order to calculate acceleration we need at least 2 changes + //in speed, so we need at least 3 position samples. + if (samples < 3) + { - samples = 3; - } + samples = 3; + } - //Initialize - if (positionRegister == null) - { + //Initialize + if (positionRegister == null) + { - positionRegister = new Vector3[samples]; - posTimeRegister = new float[samples]; - } + positionRegister = new Vector3[samples]; + posTimeRegister = new float[samples]; + } - //Fill the position and time sample array and shift the location in the array to the left - //each time a new sample is taken. This way index 0 will always hold the oldest sample and the - //highest index will always hold the newest sample. - for (int i = 0; i < positionRegister.Length - 1; i++) - { + //Fill the position and time sample array and shift the location in the array to the left + //each time a new sample is taken. This way index 0 will always hold the oldest sample and the + //highest index will always hold the newest sample. + for (int i = 0; i < positionRegister.Length - 1; i++) + { - positionRegister[i] = positionRegister[i + 1]; - posTimeRegister[i] = posTimeRegister[i + 1]; - } - positionRegister[positionRegister.Length - 1] = position; - posTimeRegister[posTimeRegister.Length - 1] = Time.time; + positionRegister[i] = positionRegister[i + 1]; + posTimeRegister[i] = posTimeRegister[i + 1]; + } + positionRegister[positionRegister.Length - 1] = position; + posTimeRegister[posTimeRegister.Length - 1] = Time.time; - positionSamplesTaken++; + positionSamplesTaken++; - //The output acceleration can only be calculated if enough samples are taken. - if (positionSamplesTaken >= samples) - { + //The output acceleration can only be calculated if enough samples are taken. + if (positionSamplesTaken >= samples) + { - //Calculate average speed change. - for (int i = 0; i < positionRegister.Length - 2; i++) - { + //Calculate average speed change. + for (int i = 0; i < positionRegister.Length - 2; i++) + { - deltaDistance = positionRegister[i + 1] - positionRegister[i]; - deltaTime = posTimeRegister[i + 1] - posTimeRegister[i]; + deltaDistance = positionRegister[i + 1] - positionRegister[i]; + deltaTime = posTimeRegister[i + 1] - posTimeRegister[i]; - //If deltaTime is 0, the output is invalid. - if (deltaTime == 0) - { + //If deltaTime is 0, the output is invalid. + if (deltaTime == 0) + { - return false; - } + return false; + } - speedA = deltaDistance / deltaTime; - deltaDistance = positionRegister[i + 2] - positionRegister[i + 1]; - deltaTime = posTimeRegister[i + 2] - posTimeRegister[i + 1]; + speedA = deltaDistance / deltaTime; + deltaDistance = positionRegister[i + 2] - positionRegister[i + 1]; + deltaTime = posTimeRegister[i + 2] - posTimeRegister[i + 1]; - if (deltaTime == 0) - { + if (deltaTime == 0) + { - return false; - } + return false; + } - speedB = deltaDistance / deltaTime; + speedB = deltaDistance / deltaTime; - //This is the accumulated speed change at this stage, not the average yet. - averageSpeedChange += speedB - speedA; - } + //This is the accumulated speed change at this stage, not the average yet. + averageSpeedChange += speedB - speedA; + } - //Now this is the average speed change. - averageSpeedChange /= positionRegister.Length - 2; + //Now this is the average speed change. + averageSpeedChange /= positionRegister.Length - 2; - //Get the total time difference. - float deltaTimeTotal = posTimeRegister[posTimeRegister.Length - 1] - posTimeRegister[0]; + //Get the total time difference. + float deltaTimeTotal = posTimeRegister[posTimeRegister.Length - 1] - posTimeRegister[0]; - //Now calculate the acceleration, which is an average over the amount of samples taken. - vector = averageSpeedChange / deltaTimeTotal; + //Now calculate the acceleration, which is an average over the amount of samples taken. + vector = averageSpeedChange / deltaTimeTotal; - return true; - } + return true; + } - else - { + else + { - return false; - } - } + return false; + } + } - /* + /* //This function calculates angular acceleration in object space as deg/second^2, encoded as a vector. //For example, if the output vector is 0,0,-5, the angular acceleration is 5 deg/second^2 around the object Z axis, to the left. //Input: rotation (quaternion). If the output is used for motion simulation, the input transform @@ -1227,170 +1230,170 @@ public static bool LinearAcceleration(out Vector3 vector, Vector3 position, int dir = Math3d.SetVectorLength(dir, dir.magnitude * scale); dir = gameObject.transform.TransformDirection(dir); Debug.DrawRay(gameObject.transform.position, dir, Color.blue); */ - public static bool AngularAcceleration(out Vector3 vector, Quaternion rotation, int samples) - { + public static bool AngularAcceleration(out Vector3 vector, Quaternion rotation, int samples) + { - Vector3 averageSpeedChange = Vector3.zero; - vector = Vector3.zero; - Quaternion deltaRotation; - float deltaTime; - Vector3 speedA; - Vector3 speedB; + Vector3 averageSpeedChange = Vector3.zero; + vector = Vector3.zero; + Quaternion deltaRotation; + float deltaTime; + Vector3 speedA; + Vector3 speedB; - //Clamp sample amount. In order to calculate acceleration we need at least 2 changes - //in speed, so we need at least 3 rotation samples. - if (samples < 3) - { + //Clamp sample amount. In order to calculate acceleration we need at least 2 changes + //in speed, so we need at least 3 rotation samples. + if (samples < 3) + { - samples = 3; - } + samples = 3; + } - //Initialize - if (rotationRegister == null) - { + //Initialize + if (rotationRegister == null) + { - rotationRegister = new Quaternion[samples]; - rotTimeRegister = new float[samples]; - } + rotationRegister = new Quaternion[samples]; + rotTimeRegister = new float[samples]; + } - //Fill the rotation and time sample array and shift the location in the array to the left - //each time a new sample is taken. This way index 0 will always hold the oldest sample and the - //highest index will always hold the newest sample. - for (int i = 0; i < rotationRegister.Length - 1; i++) - { + //Fill the rotation and time sample array and shift the location in the array to the left + //each time a new sample is taken. This way index 0 will always hold the oldest sample and the + //highest index will always hold the newest sample. + for (int i = 0; i < rotationRegister.Length - 1; i++) + { - rotationRegister[i] = rotationRegister[i + 1]; - rotTimeRegister[i] = rotTimeRegister[i + 1]; - } - rotationRegister[rotationRegister.Length - 1] = rotation; - rotTimeRegister[rotTimeRegister.Length - 1] = Time.time; + rotationRegister[i] = rotationRegister[i + 1]; + rotTimeRegister[i] = rotTimeRegister[i + 1]; + } + rotationRegister[rotationRegister.Length - 1] = rotation; + rotTimeRegister[rotTimeRegister.Length - 1] = Time.time; - rotationSamplesTaken++; + rotationSamplesTaken++; - //The output acceleration can only be calculated if enough samples are taken. - if (rotationSamplesTaken >= samples) - { + //The output acceleration can only be calculated if enough samples are taken. + if (rotationSamplesTaken >= samples) + { - //Calculate average speed change. - for (int i = 0; i < rotationRegister.Length - 2; i++) - { + //Calculate average speed change. + for (int i = 0; i < rotationRegister.Length - 2; i++) + { - deltaRotation = SubtractRotation(rotationRegister[i + 1], rotationRegister[i]); - deltaTime = rotTimeRegister[i + 1] - rotTimeRegister[i]; + deltaRotation = SubtractRotation(rotationRegister[i + 1], rotationRegister[i]); + deltaTime = rotTimeRegister[i + 1] - rotTimeRegister[i]; - //If deltaTime is 0, the output is invalid. - if (deltaTime == 0) - { + //If deltaTime is 0, the output is invalid. + if (deltaTime == 0) + { - return false; - } + return false; + } - speedA = RotDiffToSpeedVec(deltaRotation, deltaTime); - deltaRotation = SubtractRotation(rotationRegister[i + 2], rotationRegister[i + 1]); - deltaTime = rotTimeRegister[i + 2] - rotTimeRegister[i + 1]; + speedA = RotDiffToSpeedVec(deltaRotation, deltaTime); + deltaRotation = SubtractRotation(rotationRegister[i + 2], rotationRegister[i + 1]); + deltaTime = rotTimeRegister[i + 2] - rotTimeRegister[i + 1]; - if (deltaTime == 0) - { + if (deltaTime == 0) + { - return false; - } + return false; + } - speedB = RotDiffToSpeedVec(deltaRotation, deltaTime); + speedB = RotDiffToSpeedVec(deltaRotation, deltaTime); - //This is the accumulated speed change at this stage, not the average yet. - averageSpeedChange += speedB - speedA; - } + //This is the accumulated speed change at this stage, not the average yet. + averageSpeedChange += speedB - speedA; + } - //Now this is the average speed change. - averageSpeedChange /= rotationRegister.Length - 2; + //Now this is the average speed change. + averageSpeedChange /= rotationRegister.Length - 2; - //Get the total time difference. - float deltaTimeTotal = rotTimeRegister[rotTimeRegister.Length - 1] - rotTimeRegister[0]; + //Get the total time difference. + float deltaTimeTotal = rotTimeRegister[rotTimeRegister.Length - 1] - rotTimeRegister[0]; - //Now calculate the acceleration, which is an average over the amount of samples taken. - vector = averageSpeedChange / deltaTimeTotal; + //Now calculate the acceleration, which is an average over the amount of samples taken. + vector = averageSpeedChange / deltaTimeTotal; - return true; - } + return true; + } - else - { + else + { - return false; - } - } + return false; + } + } - //Get y from a linear function, with x as an input. The linear function goes through points - //0,0 on the left ,and Qxy on the right. - public static float LinearFunction2DBasic(float x, float Qx, float Qy) - { + //Get y from a linear function, with x as an input. The linear function goes through points + //0,0 on the left ,and Qxy on the right. + public static float LinearFunction2DBasic(float x, float Qx, float Qy) + { - float y = x * (Qy / Qx); + float y = x * (Qy / Qx); - return y; - } + return y; + } - //Get y from a linear function, with x as an input. The linear function goes through points - //Pxy on the left ,and Qxy on the right. - public static float LinearFunction2DFull(float x, float Px, float Py, float Qx, float Qy) - { + //Get y from a linear function, with x as an input. The linear function goes through points + //Pxy on the left ,and Qxy on the right. + public static float LinearFunction2DFull(float x, float Px, float Py, float Qx, float Qy) + { - float y = 0f; + float y = 0f; - float A = Qy - Py; - float B = Qx - Px; - float C = A / B; + float A = Qy - Py; + float B = Qx - Px; + float C = A / B; - y = Py + (C * (x - Px)); + y = Py + (C * (x - Px)); - return y; - } + return y; + } - //Convert a rotation difference to a speed vector. - //For internal use only. - private static Vector3 RotDiffToSpeedVec(Quaternion rotation, float deltaTime) - { + //Convert a rotation difference to a speed vector. + //For internal use only. + private static Vector3 RotDiffToSpeedVec(Quaternion rotation, float deltaTime) + { - float x; - float y; - float z; + float x; + float y; + float z; - if (rotation.eulerAngles.x <= 180.0f) - { + if (rotation.eulerAngles.x <= 180.0f) + { - x = rotation.eulerAngles.x; - } + x = rotation.eulerAngles.x; + } - else - { + else + { - x = rotation.eulerAngles.x - 360.0f; - } + x = rotation.eulerAngles.x - 360.0f; + } - if (rotation.eulerAngles.y <= 180.0f) - { + if (rotation.eulerAngles.y <= 180.0f) + { - y = rotation.eulerAngles.y; - } + y = rotation.eulerAngles.y; + } - else - { + else + { - y = rotation.eulerAngles.y - 360.0f; - } + y = rotation.eulerAngles.y - 360.0f; + } - if (rotation.eulerAngles.z <= 180.0f) - { + if (rotation.eulerAngles.z <= 180.0f) + { - z = rotation.eulerAngles.z; - } + z = rotation.eulerAngles.z; + } - else - { + else + { - z = rotation.eulerAngles.z - 360.0f; - } + z = rotation.eulerAngles.z - 360.0f; + } - return new Vector3(x / deltaTime, y / deltaTime, z / deltaTime); - } + return new Vector3(x / deltaTime, y / deltaTime, z / deltaTime); + } } \ No newline at end of file diff --git a/Assets/Scripts/Restart.cs b/Assets/Scripts/Restart.cs index 830a318b001f1691c439555d070a77a502b99082..f2fb7c4c16e046e9f1d5491d453ee156da0f5ea7 100644 --- a/Assets/Scripts/Restart.cs +++ b/Assets/Scripts/Restart.cs @@ -7,7 +7,8 @@ public void LoadStartScreen() { process.Kill(); Level.solved = false; - CommunicationEvents.Facts.Clear(); + //TODO: CommunicationEvents.Facts2.Clear(); + CommunicationEvents.Facts.hardreset(); UnityEngine.SceneManagement.SceneManager.LoadScene(0); } diff --git a/Assets/Scripts/StartServer.cs b/Assets/Scripts/StartServer.cs index f7ede0500236a8d4b3d23106a5b9411ee8056b9d..dcb7d8426be089c5445b0848aed31d466d72e95f 100644 --- a/Assets/Scripts/StartServer.cs +++ b/Assets/Scripts/StartServer.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections; using System.Diagnostics; using UnityEngine; using UnityEngine.Networking; @@ -8,7 +6,7 @@ public class StartServer : MonoBehaviour { - [SerializeField] + [SerializeField] TMPro.TextMeshProUGUI WaitingText; public static Process process; @@ -24,7 +22,7 @@ void Start() void PrepareGame() { WaitingText.text = "Press any key to start the game"; - CommunicationEvents.ServerRunning= true; + CommunicationEvents.ServerRunning = true; UnityEngine.Debug.Log("server fin"); } @@ -32,7 +30,7 @@ void PrepareGame() IEnumerator ServerRoutine1() { - string command = "\"" + Application.streamingAssetsPath + "\"/start.BAT "+ "\"" + Application.streamingAssetsPath + "\"" ; + string command = "\"" + Application.streamingAssetsPath + "\"/start.BAT " + "\"" + Application.streamingAssetsPath + "\""; command = command.Replace("/", @"\"); command = "\"" + command + "\""; UnityEngine.Debug.Log(command); @@ -44,15 +42,16 @@ IEnumerator ServerRoutine1() if (cmd) { processInfo = new ProcessStartInfo("cmd.exe", "/C " + command); - // processInfo.CreateNoWindow = false; - // processInfo.UseShellExecute = true; + // processInfo.CreateNoWindow = false; + // processInfo.UseShellExecute = true; process = Process.Start(processInfo); - }else - /* - */ - Process.Start("powershell.exe", command); - + } + else + /* + */ + Process.Start("powershell.exe", command); + @@ -80,18 +79,18 @@ IEnumerator ServerRoutine1() IEnumerator ServerRoutine() { - UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress+"/scroll/list"); + UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list"); yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { - UnityEngine.Debug.Log("no running server "+ request.error); + UnityEngine.Debug.Log("no running server " + request.error); + +#if !UNITY_WEBGL -#if!UNITY_WEBGL - -//#if UNITY_STANDALONE_LINUX -//#elif UNITY_STANDALONE_OSX -//#else + //#if UNITY_STANDALONE_LINUX + //#elif UNITY_STANDALONE_OSX + //#else processInfo = new ProcessStartInfo(); processInfo.FileName = "java"; processInfo.Arguments = @"-jar " + Application.streamingAssetsPath + "/frameit.jar" + " -bind :8085 -archive-root " + Application.streamingAssetsPath + "/archives"; @@ -100,16 +99,16 @@ IEnumerator ServerRoutine() processInfo.CreateNoWindow = true; process = Process.Start(processInfo); -//#endif + //#endif yield return null; #endif while (true) { - request = UnityWebRequest.Get(CommunicationEvents.ServerAdress+"/scroll/list"); + request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list"); yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { - // UnityEngine.Debug.Log("no running server"); + // UnityEngine.Debug.Log("no running server"); } else { @@ -141,9 +140,9 @@ IEnumerator ServerRoutine() // Update is called once per frame void Update() { - if(CommunicationEvents.ServerRunning && Input.anyKey) + if (CommunicationEvents.ServerRunning && Input.anyKey) { - SceneManager.LoadScene(1); + SceneManager.LoadScene(1); } //if(!ServerRunning) UnityEngine.Debug.Log("waiting " + ServerRunning); diff --git a/Assets/Scripts/TestScripts/ScrollUIManager.cs b/Assets/Scripts/TestScripts/ScrollUIManager.cs index 9fa10f5317f5d445578e4f6e49fd809cf1e70bf7..a2686fbf918893f8a6be5b13577f28e9485494ec 100644 --- a/Assets/Scripts/TestScripts/ScrollUIManager.cs +++ b/Assets/Scripts/TestScripts/ScrollUIManager.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class ScrollUIManager : MonoBehaviour { diff --git a/Assets/Scripts/ToolModeSelector.cs b/Assets/Scripts/ToolModeSelector.cs index b32cd9965bf3e1e4f84faa4d94b0951346cd03d8..6edc8c6abc3aa6d967a24bc47368b9b174d259a2 100644 --- a/Assets/Scripts/ToolModeSelector.cs +++ b/Assets/Scripts/ToolModeSelector.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections; using System.Linq; using UnityEngine; using UnityEngine.UI; @@ -21,15 +19,15 @@ void Start() var buttons = GetComponentsInChildren<Button>(); Buttons = buttons.OrderBy(x => x.transform.position.x).ToArray(); ParentCanvas = GetComponentInParent<Canvas>(); - for(int i = 0; i< Buttons.Length;++i) + for (int i = 0; i < Buttons.Length; ++i) { int copiedIndex = i; //this is important var button = Buttons[i]; - button.onClick.AddListener(()=> Select(copiedIndex)); - + button.onClick.AddListener(() => Select(copiedIndex)); + } - + Buttons[GadgetManager.activeGadget.id].transform.localScale *= activeGadgetScaleFactor; UIManager = GetComponentInParent<HideUI>(); @@ -39,7 +37,7 @@ public void Select(int id) { ParentCanvas.enabled = true; - + Buttons[GadgetManager.activeGadget.id].transform.localScale /= activeGadgetScaleFactor; CommunicationEvents.ToolModeChangedEvent.Invoke(id); Buttons[GadgetManager.activeGadget.id].transform.localScale *= activeGadgetScaleFactor; @@ -49,7 +47,7 @@ public void Select(int id) IEnumerator HideRoutine() { - + yield return new WaitForSeconds(2); if (!Showing) { @@ -62,9 +60,9 @@ IEnumerator HideRoutine() // Update is called once per frame void Update() { //Check if the ToolMode was switched - if(!UIManager.UICanvas.enabled) + if (!UIManager.UICanvas.enabled) CheckToolModeSelection(); - + } @@ -77,15 +75,16 @@ void CheckToolModeSelection() int id = (tempActiveGadget.id + 1) % GadgetManager.gadgets.Length; Select(id); } - else if(Input.GetAxis("Mouse ScrollWheel") !=0){ + else if (Input.GetAxis("Mouse ScrollWheel") != 0) + { - int move = (int) Mathf.Sign(Input.GetAxis("Mouse ScrollWheel")); + int move = (int)Mathf.Sign(Input.GetAxis("Mouse ScrollWheel")); Gadget tempActiveGadget = GadgetManager.activeGadget; int id = (tempActiveGadget.id + move) % Buttons.Length;// GadgetManager.gadgets.Length; if (id < 0) id = Buttons.Length - 1;// GadgetManager.gadgets.Length-1; Select(id); } - + } } diff --git a/Assets/Standard Assets/2D/Scripts/Camera2DFollow.cs b/Assets/Standard Assets/2D/Scripts/Camera2DFollow.cs index 93c902100da4c87933fb630818cd2cc9760a0187..7ec98d3280662d257e756db832389938a9df3699 100644 --- a/Assets/Standard Assets/2D/Scripts/Camera2DFollow.cs +++ b/Assets/Standard Assets/2D/Scripts/Camera2DFollow.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets._2D @@ -35,14 +34,14 @@ private void Update() if (updateLookAheadTarget) { - m_LookAheadPos = lookAheadFactor*Vector3.right*Mathf.Sign(xMoveDelta); + m_LookAheadPos = lookAheadFactor * Vector3.right * Mathf.Sign(xMoveDelta); } else { - m_LookAheadPos = Vector3.MoveTowards(m_LookAheadPos, Vector3.zero, Time.deltaTime*lookAheadReturnSpeed); + m_LookAheadPos = Vector3.MoveTowards(m_LookAheadPos, Vector3.zero, Time.deltaTime * lookAheadReturnSpeed); } - Vector3 aheadTargetPos = target.position + m_LookAheadPos + Vector3.forward*m_OffsetZ; + Vector3 aheadTargetPos = target.position + m_LookAheadPos + Vector3.forward * m_OffsetZ; Vector3 newPos = Vector3.SmoothDamp(transform.position, aheadTargetPos, ref m_CurrentVelocity, damping); transform.position = newPos; diff --git a/Assets/Standard Assets/2D/Scripts/CameraFollow.cs b/Assets/Standard Assets/2D/Scripts/CameraFollow.cs index e87de97c52c8b59533a3054441986caa7c2df4dc..db5d0f466fc8777183516885d1e13f47d696d536 100644 --- a/Assets/Standard Assets/2D/Scripts/CameraFollow.cs +++ b/Assets/Standard Assets/2D/Scripts/CameraFollow.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; @@ -53,14 +52,14 @@ private void TrackPlayer() if (CheckXMargin()) { // ... the target x coordinate should be a Lerp between the camera's current x position and the player's current x position. - targetX = Mathf.Lerp(transform.position.x, m_Player.position.x, xSmooth*Time.deltaTime); + targetX = Mathf.Lerp(transform.position.x, m_Player.position.x, xSmooth * Time.deltaTime); } // If the player has moved beyond the y margin... if (CheckYMargin()) { // ... the target y coordinate should be a Lerp between the camera's current y position and the player's current y position. - targetY = Mathf.Lerp(transform.position.y, m_Player.position.y, ySmooth*Time.deltaTime); + targetY = Mathf.Lerp(transform.position.y, m_Player.position.y, ySmooth * Time.deltaTime); } // The target x and y coordinates should not be larger than the maximum or smaller than the minimum. diff --git a/Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs b/Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs index a142d312ef738c06825454a23d2ef7b564531feb..04f6f93f530083cf5c9a56baa0be66852932d3e4 100644 --- a/Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs +++ b/Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; namespace UnityStandardAssets._2D { - [RequireComponent(typeof (PlatformerCharacter2D))] + [RequireComponent(typeof(PlatformerCharacter2D))] public class Platformer2DUserControl : MonoBehaviour { private PlatformerCharacter2D m_Character; diff --git a/Assets/Standard Assets/2D/Scripts/PlatformerCharacter2D.cs b/Assets/Standard Assets/2D/Scripts/PlatformerCharacter2D.cs index 1e1faa66385e6c400e075f93d027811f7c611937..20f6371d92e6848a61204500dc61d76509aa7060 100644 --- a/Assets/Standard Assets/2D/Scripts/PlatformerCharacter2D.cs +++ b/Assets/Standard Assets/2D/Scripts/PlatformerCharacter2D.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets._2D @@ -68,13 +67,13 @@ public void Move(float move, bool crouch, bool jump) if (m_Grounded || m_AirControl) { // Reduce the speed if crouching by the crouchSpeed multiplier - move = (crouch ? move*m_CrouchSpeed : move); + move = (crouch ? move * m_CrouchSpeed : move); // The Speed animator parameter is set to the absolute value of the horizontal input. m_Anim.SetFloat("Speed", Mathf.Abs(move)); // Move the character - m_Rigidbody2D.velocity = new Vector2(move*m_MaxSpeed, m_Rigidbody2D.velocity.y); + m_Rigidbody2D.velocity = new Vector2(move * m_MaxSpeed, m_Rigidbody2D.velocity.y); // If the input is moving the player right and the player is facing left... if (move > 0 && !m_FacingRight) @@ -82,7 +81,7 @@ public void Move(float move, bool crouch, bool jump) // ... flip the player. Flip(); } - // Otherwise if the input is moving the player left and the player is facing right... + // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && m_FacingRight) { // ... flip the player. diff --git a/Assets/Standard Assets/2D/Scripts/Restarter.cs b/Assets/Standard Assets/2D/Scripts/Restarter.cs index 52cfe456ac1471b80b72f79256fce9ae6186ffa4..346ac7b4e036543a9f4437fec96ee81bebfdb0e8 100644 --- a/Assets/Standard Assets/2D/Scripts/Restarter.cs +++ b/Assets/Standard Assets/2D/Scripts/Restarter.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityEngine.SceneManagement; diff --git a/Assets/Standard Assets/Cameras/Scripts/AbstractTargetFollower.cs b/Assets/Standard Assets/Cameras/Scripts/AbstractTargetFollower.cs index 092bbb2868fa4582deeddfb480d523e402dc90fa..01b02d3df7d8de0b0281d5586df8f4c90aa253ef 100644 --- a/Assets/Standard Assets/Cameras/Scripts/AbstractTargetFollower.cs +++ b/Assets/Standard Assets/Cameras/Scripts/AbstractTargetFollower.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Cameras diff --git a/Assets/Standard Assets/Cameras/Scripts/AutoCam.cs b/Assets/Standard Assets/Cameras/Scripts/AutoCam.cs index 906ae0f5958158ca08e1ededc68770c87aae592f..8b2c0b129a8bbd142dd3d340ee492c639c120568 100644 --- a/Assets/Standard Assets/Cameras/Scripts/AutoCam.cs +++ b/Assets/Standard Assets/Cameras/Scripts/AutoCam.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; #if UNITY_EDITOR @@ -60,11 +59,11 @@ protected override void FollowTarget(float deltaTime) // This section allows the camera to stop following the target's rotation when the target is spinning too fast. // eg when a car has been knocked into a spin. The camera will resume following the rotation // of the target when the target's angular velocity slows below the threshold. - var currentFlatAngle = Mathf.Atan2(targetForward.x, targetForward.z)*Mathf.Rad2Deg; + var currentFlatAngle = Mathf.Atan2(targetForward.x, targetForward.z) * Mathf.Rad2Deg; if (m_SpinTurnLimit > 0) { - var targetSpinSpeed = Mathf.Abs(Mathf.DeltaAngle(m_LastFlatAngle, currentFlatAngle))/deltaTime; - var desiredTurnAmount = Mathf.InverseLerp(m_SpinTurnLimit, m_SpinTurnLimit*0.75f, targetSpinSpeed); + var targetSpinSpeed = Mathf.Abs(Mathf.DeltaAngle(m_LastFlatAngle, currentFlatAngle)) / deltaTime; + var desiredTurnAmount = Mathf.InverseLerp(m_SpinTurnLimit, m_SpinTurnLimit * 0.75f, targetSpinSpeed); var turnReactSpeed = (m_CurrentTurnAmount > desiredTurnAmount ? .1f : 1f); if (Application.isPlaying) { @@ -85,7 +84,7 @@ protected override void FollowTarget(float deltaTime) } // camera position moves towards target position: - transform.position = Vector3.Lerp(transform.position, m_Target.position, deltaTime*m_MoveSpeed); + transform.position = Vector3.Lerp(transform.position, m_Target.position, deltaTime * m_MoveSpeed); // camera's rotation is split into two parts, which can have independend speed settings: // rotating towards the target's forward direction (which encompasses its 'yaw' and 'pitch') @@ -100,8 +99,8 @@ protected override void FollowTarget(float deltaTime) var rollRotation = Quaternion.LookRotation(targetForward, m_RollUp); // and aligning with the target object's up direction (i.e. its 'roll') - m_RollUp = m_RollSpeed > 0 ? Vector3.Slerp(m_RollUp, targetUp, m_RollSpeed*deltaTime) : Vector3.up; - transform.rotation = Quaternion.Lerp(transform.rotation, rollRotation, m_TurnSpeed*m_CurrentTurnAmount*deltaTime); + m_RollUp = m_RollSpeed > 0 ? Vector3.Slerp(m_RollUp, targetUp, m_RollSpeed * deltaTime) : Vector3.up; + transform.rotation = Quaternion.Lerp(transform.rotation, rollRotation, m_TurnSpeed * m_CurrentTurnAmount * deltaTime); } } } diff --git a/Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs b/Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs index cf3485c5611c6151adde585bb7798658aa960e09..8f4b0be8f4ffd84cd0f8a4c440404a2b6f7cf4e6 100644 --- a/Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs +++ b/Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; @@ -24,9 +23,9 @@ public class FreeLookCam : PivotBasedCameraRig private float m_LookAngle; // The rig's y axis rotation. private float m_TiltAngle; // The pivot's x axis rotation. private const float k_LookDistance = 100f; // How far in front of the pivot the character's look target is. - private Vector3 m_PivotEulers; - private Quaternion m_PivotTargetRot; - private Quaternion m_TransformTargetRot; + private Vector3 m_PivotEulers; + private Quaternion m_PivotTargetRot; + private Quaternion m_TransformTargetRot; protected override void Awake() { @@ -34,10 +33,10 @@ protected override void Awake() // Lock or unlock the cursor. Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None; Cursor.visible = !m_LockCursor; - m_PivotEulers = m_Pivot.rotation.eulerAngles; + m_PivotEulers = m_Pivot.rotation.eulerAngles; - m_PivotTargetRot = m_Pivot.transform.localRotation; - m_TransformTargetRot = transform.localRotation; + m_PivotTargetRot = m_Pivot.transform.localRotation; + m_TransformTargetRot = transform.localRotation; } @@ -63,21 +62,21 @@ protected override void FollowTarget(float deltaTime) { if (m_Target == null) return; // Move the rig towards target position. - transform.position = Vector3.Lerp(transform.position, m_Target.position, deltaTime*m_MoveSpeed); + transform.position = Vector3.Lerp(transform.position, m_Target.position, deltaTime * m_MoveSpeed); } private void HandleRotationMovement() { - if(Time.timeScale < float.Epsilon) - return; + if (Time.timeScale < float.Epsilon) + return; // Read the user input var x = CrossPlatformInputManager.GetAxis("Mouse X"); var y = CrossPlatformInputManager.GetAxis("Mouse Y"); // Adjust the look angle by an amount proportional to the turn speed and horizontal input. - m_LookAngle += x*m_TurnSpeed; + m_LookAngle += x * m_TurnSpeed; // Rotate the rig (the root object) around Y axis only: m_TransformTargetRot = Quaternion.Euler(0f, m_LookAngle, 0f); @@ -92,24 +91,24 @@ private void HandleRotationMovement() else { // on platforms with a mouse, we adjust the current angle based on Y mouse input and turn speed - m_TiltAngle -= y*m_TurnSpeed; + m_TiltAngle -= y * m_TurnSpeed; // and make sure the new value is within the tilt range m_TiltAngle = Mathf.Clamp(m_TiltAngle, -m_TiltMin, m_TiltMax); } // Tilt input around X is applied to the pivot (the child of this object) - m_PivotTargetRot = Quaternion.Euler(m_TiltAngle, m_PivotEulers.y , m_PivotEulers.z); - - if (m_TurnSmoothing > 0) - { - m_Pivot.localRotation = Quaternion.Slerp(m_Pivot.localRotation, m_PivotTargetRot, m_TurnSmoothing * Time.deltaTime); - transform.localRotation = Quaternion.Slerp(transform.localRotation, m_TransformTargetRot, m_TurnSmoothing * Time.deltaTime); - } - else - { - m_Pivot.localRotation = m_PivotTargetRot; - transform.localRotation = m_TransformTargetRot; - } + m_PivotTargetRot = Quaternion.Euler(m_TiltAngle, m_PivotEulers.y, m_PivotEulers.z); + + if (m_TurnSmoothing > 0) + { + m_Pivot.localRotation = Quaternion.Slerp(m_Pivot.localRotation, m_PivotTargetRot, m_TurnSmoothing * Time.deltaTime); + transform.localRotation = Quaternion.Slerp(transform.localRotation, m_TransformTargetRot, m_TurnSmoothing * Time.deltaTime); + } + else + { + m_Pivot.localRotation = m_PivotTargetRot; + transform.localRotation = m_TransformTargetRot; + } } } } diff --git a/Assets/Standard Assets/Cameras/Scripts/HandHeldCam.cs b/Assets/Standard Assets/Cameras/Scripts/HandHeldCam.cs index 837cf5c777280814504612662445ce50836b511e..712fa030b53c3f39e3df2b163fa13a60cb90056d 100644 --- a/Assets/Standard Assets/Cameras/Scripts/HandHeldCam.cs +++ b/Assets/Standard Assets/Cameras/Scripts/HandHeldCam.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Cameras @@ -15,17 +14,17 @@ protected override void FollowTarget(float deltaTime) { base.FollowTarget(deltaTime); - float bx = (Mathf.PerlinNoise(0, Time.time*m_SwaySpeed) - 0.5f); - float by = (Mathf.PerlinNoise(0, (Time.time*m_SwaySpeed) + 100)) - 0.5f; + float bx = (Mathf.PerlinNoise(0, Time.time * m_SwaySpeed) - 0.5f); + float by = (Mathf.PerlinNoise(0, (Time.time * m_SwaySpeed) + 100)) - 0.5f; bx *= m_BaseSwayAmount; by *= m_BaseSwayAmount; - float tx = (Mathf.PerlinNoise(0, Time.time*m_SwaySpeed) - 0.5f) + m_TrackingBias; - float ty = ((Mathf.PerlinNoise(0, (Time.time*m_SwaySpeed) + 100)) - 0.5f) + m_TrackingBias; + float tx = (Mathf.PerlinNoise(0, Time.time * m_SwaySpeed) - 0.5f) + m_TrackingBias; + float ty = ((Mathf.PerlinNoise(0, (Time.time * m_SwaySpeed) + 100)) - 0.5f) + m_TrackingBias; - tx *= -m_TrackingSwayAmount*m_FollowVelocity.x; - ty *= m_TrackingSwayAmount*m_FollowVelocity.y; + tx *= -m_TrackingSwayAmount * m_FollowVelocity.x; + ty *= m_TrackingSwayAmount * m_FollowVelocity.y; transform.Rotate(bx + tx, by + ty, 0); } diff --git a/Assets/Standard Assets/Cameras/Scripts/LookatTarget.cs b/Assets/Standard Assets/Cameras/Scripts/LookatTarget.cs index a33b3a6f990716aa83021d3bf4e657a1204d8875..5f04c95e035786423d4b2c5d8cb1c9ceb68fe064 100644 --- a/Assets/Standard Assets/Cameras/Scripts/LookatTarget.cs +++ b/Assets/Standard Assets/Cameras/Scripts/LookatTarget.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Cameras @@ -43,15 +42,15 @@ protected override void FollowTarget(float deltaTime) // tackle rotation around Y first Vector3 localTarget = transform.InverseTransformPoint(m_Target.position); - float yAngle = Mathf.Atan2(localTarget.x, localTarget.z)*Mathf.Rad2Deg; + float yAngle = Mathf.Atan2(localTarget.x, localTarget.z) * Mathf.Rad2Deg; - yAngle = Mathf.Clamp(yAngle, -m_RotationRange.y*0.5f, m_RotationRange.y*0.5f); - transform.localRotation = m_OriginalRotation*Quaternion.Euler(0, yAngle, 0); + yAngle = Mathf.Clamp(yAngle, -m_RotationRange.y * 0.5f, m_RotationRange.y * 0.5f); + transform.localRotation = m_OriginalRotation * Quaternion.Euler(0, yAngle, 0); // then recalculate new local target position for rotation around X localTarget = transform.InverseTransformPoint(m_Target.position); - float xAngle = Mathf.Atan2(localTarget.y, localTarget.z)*Mathf.Rad2Deg; - xAngle = Mathf.Clamp(xAngle, -m_RotationRange.x*0.5f, m_RotationRange.x*0.5f); + float xAngle = Mathf.Atan2(localTarget.y, localTarget.z) * Mathf.Rad2Deg; + xAngle = Mathf.Clamp(xAngle, -m_RotationRange.x * 0.5f, m_RotationRange.x * 0.5f); var targetAngles = new Vector3(m_FollowAngles.x + Mathf.DeltaAngle(m_FollowAngles.x, xAngle), m_FollowAngles.y + Mathf.DeltaAngle(m_FollowAngles.y, yAngle)); @@ -60,7 +59,7 @@ protected override void FollowTarget(float deltaTime) // and update the gameobject itself - transform.localRotation = m_OriginalRotation*Quaternion.Euler(-m_FollowAngles.x, m_FollowAngles.y, 0); + transform.localRotation = m_OriginalRotation * Quaternion.Euler(-m_FollowAngles.x, m_FollowAngles.y, 0); } } } diff --git a/Assets/Standard Assets/Cameras/Scripts/PivotBasedCameraRig.cs b/Assets/Standard Assets/Cameras/Scripts/PivotBasedCameraRig.cs index cc76a6a736eac2e0cdf563bba22d92ea976d2877..056b1e796338822997b5c9c3c14924b20a057bc7 100644 --- a/Assets/Standard Assets/Cameras/Scripts/PivotBasedCameraRig.cs +++ b/Assets/Standard Assets/Cameras/Scripts/PivotBasedCameraRig.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; diff --git a/Assets/Standard Assets/Cameras/Scripts/ProtectCameraFromWallClip.cs b/Assets/Standard Assets/Cameras/Scripts/ProtectCameraFromWallClip.cs index 03129f8c91a76c8c49f3b9419d075007ff1a50a6..792284ec73f60c44ffefbf593dd01862ed22fed7 100644 --- a/Assets/Standard Assets/Cameras/Scripts/ProtectCameraFromWallClip.cs +++ b/Assets/Standard Assets/Cameras/Scripts/ProtectCameraFromWallClip.cs @@ -42,7 +42,7 @@ private void LateUpdate() // initially set the target distance float targetDist = m_OriginalDist; - m_Ray.origin = m_Pivot.position + m_Pivot.forward*sphereCastRadius; + m_Ray.origin = m_Pivot.position + m_Pivot.forward * sphereCastRadius; m_Ray.direction = -m_Pivot.forward; // initial check to see if start of spherecast intersects anything @@ -65,7 +65,7 @@ private void LateUpdate() // if there is a collision if (initialIntersect) { - m_Ray.origin += m_Pivot.forward*sphereCastRadius; + m_Ray.origin += m_Pivot.forward * sphereCastRadius; // do a raycast and gather all the intersections m_Hits = Physics.RaycastAll(m_Ray, m_OriginalDist - sphereCastRadius); @@ -100,7 +100,7 @@ private void LateUpdate() // visualise the cam clip effect in the editor if (hitSomething) { - Debug.DrawRay(m_Ray.origin, -m_Pivot.forward*(targetDist + sphereCastRadius), Color.red); + Debug.DrawRay(m_Ray.origin, -m_Pivot.forward * (targetDist + sphereCastRadius), Color.red); } // hit something so move the camera to a better position @@ -108,7 +108,7 @@ private void LateUpdate() m_CurrentDist = Mathf.SmoothDamp(m_CurrentDist, targetDist, ref m_MoveVelocity, m_CurrentDist > targetDist ? clipMoveTime : returnTime); m_CurrentDist = Mathf.Clamp(m_CurrentDist, closestDistance, m_OriginalDist); - m_Cam.localPosition = -Vector3.forward*m_CurrentDist; + m_Cam.localPosition = -Vector3.forward * m_CurrentDist; } @@ -117,7 +117,7 @@ public class RayHitComparer : IComparer { public int Compare(object x, object y) { - return ((RaycastHit) x).distance.CompareTo(((RaycastHit) y).distance); + return ((RaycastHit)x).distance.CompareTo(((RaycastHit)y).distance); } } } diff --git a/Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs b/Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs index a5aedefda1ba1fa516c3ade1ecd5aaefcd591560..ae961598f5ca9018eb660d73c5f9d349666c0089 100644 --- a/Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs +++ b/Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; @@ -35,7 +34,7 @@ protected override void FollowTarget(float deltaTime) { // calculate the correct field of view to fit the bounds size at the current distance float dist = (m_Target.position - transform.position).magnitude; - float requiredFOV = Mathf.Atan2(m_BoundSize, dist)*Mathf.Rad2Deg*m_ZoomAmountMultiplier; + float requiredFOV = Mathf.Atan2(m_BoundSize, dist) * Mathf.Rad2Deg * m_ZoomAmountMultiplier; m_Cam.fieldOfView = Mathf.SmoothDamp(m_Cam.fieldOfView, requiredFOV, ref m_FovAdjustVelocity, m_FovAdjustTime); } diff --git a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs index 51f282e6f8ff88c15a3489c440172aa113ef8b1c..6292ab1fa695ebded401f23151a185c991947144 100644 --- a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs +++ b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; using UnityStandardAssets.Utility; @@ -6,8 +5,8 @@ namespace UnityStandardAssets.Characters.FirstPerson { - [RequireComponent(typeof (CharacterController))] - [RequireComponent(typeof (AudioSource))] + [RequireComponent(typeof(CharacterController))] + [RequireComponent(typeof(AudioSource))] public class FirstPersonController : MonoBehaviour { [SerializeField] private bool m_IsWalking; @@ -51,10 +50,10 @@ private void Start() m_FovKick.Setup(m_Camera); m_HeadBob.Setup(m_Camera, m_StepInterval); m_StepCycle = 0f; - m_NextStep = m_StepCycle/2f; + m_NextStep = m_StepCycle / 2f; m_Jumping = false; m_AudioSource = GetComponent<AudioSource>(); - m_MouseLook.Init(transform , m_Camera.transform); + m_MouseLook.Init(transform, m_Camera.transform); } @@ -97,16 +96,16 @@ private void FixedUpdate() float speed; GetInput(out speed); // always move along the camera forward as it is the direction that it being aimed at - Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.x; + Vector3 desiredMove = transform.forward * m_Input.y + transform.right * m_Input.x; // get a normal for the surface that is being touched to move along it RaycastHit hitInfo; Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo, - m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInteraction.Ignore); + m_CharacterController.height / 2f, Physics.AllLayers, QueryTriggerInteraction.Ignore); desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized; - m_MoveDir.x = desiredMove.x*speed; - m_MoveDir.z = desiredMove.z*speed; + m_MoveDir.x = desiredMove.x * speed; + m_MoveDir.z = desiredMove.z * speed; if (m_CharacterController.isGrounded) @@ -123,9 +122,9 @@ private void FixedUpdate() } else { - m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime; + m_MoveDir += Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime; } - m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaTime); + m_CollisionFlags = m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime); ProgressStepCycle(speed); UpdateCameraPosition(speed); @@ -145,7 +144,7 @@ private void ProgressStepCycle(float speed) { if (m_CharacterController.velocity.sqrMagnitude > 0 && (m_Input.x != 0 || m_Input.y != 0)) { - m_StepCycle += (m_CharacterController.velocity.magnitude + (speed*(m_IsWalking ? 1f : m_RunstepLenghten)))* + m_StepCycle += (m_CharacterController.velocity.magnitude + (speed * (m_IsWalking ? 1f : m_RunstepLenghten))) * Time.fixedDeltaTime; } @@ -188,7 +187,7 @@ private void UpdateCameraPosition(float speed) { m_Camera.transform.localPosition = m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude + - (speed*(m_IsWalking ? 1f : m_RunstepLenghten))); + (speed * (m_IsWalking ? 1f : m_RunstepLenghten))); newCameraPosition = m_Camera.transform.localPosition; newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset(); } @@ -236,7 +235,7 @@ private void GetInput(out float speed) private void RotateView() { - m_MouseLook.LookRotation (transform, m_Camera.transform); + m_MouseLook.LookRotation(transform, m_Camera.transform); } @@ -253,7 +252,7 @@ private void OnControllerColliderHit(ControllerColliderHit hit) { return; } - body.AddForceAtPosition(m_CharacterController.velocity*0.1f, hit.point, ForceMode.Impulse); + body.AddForceAtPosition(m_CharacterController.velocity * 0.1f, hit.point, ForceMode.Impulse); } } } diff --git a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/HeadBob.cs b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/HeadBob.cs index 06ddecc548a16e927128a5e67c031c5b915815ae..11e826f5978c5594a3c96d6d8a4a65d74293c229 100644 --- a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/HeadBob.cs +++ b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/HeadBob.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityStandardAssets.Utility; @@ -13,7 +12,7 @@ public class HeadBob : MonoBehaviour public float StrideInterval; [Range(0f, 1f)] public float RunningStrideLengthen; - // private CameraRefocus m_CameraRefocus; + // private CameraRefocus m_CameraRefocus; private bool m_PreviouslyGrounded; private Vector3 m_OriginalCameraPosition; @@ -22,17 +21,17 @@ private void Start() { motionBob.Setup(Camera, StrideInterval); m_OriginalCameraPosition = Camera.transform.localPosition; - // m_CameraRefocus = new CameraRefocus(Camera, transform.root.transform, Camera.transform.localPosition); + // m_CameraRefocus = new CameraRefocus(Camera, transform.root.transform, Camera.transform.localPosition); } private void Update() { - // m_CameraRefocus.GetFocusPoint(); + // m_CameraRefocus.GetFocusPoint(); Vector3 newCameraPosition; if (rigidbodyFirstPersonController.Velocity.magnitude > 0 && rigidbodyFirstPersonController.Grounded) { - Camera.transform.localPosition = motionBob.DoHeadBob(rigidbodyFirstPersonController.Velocity.magnitude*(rigidbodyFirstPersonController.Running ? RunningStrideLengthen : 1f)); + Camera.transform.localPosition = motionBob.DoHeadBob(rigidbodyFirstPersonController.Velocity.magnitude * (rigidbodyFirstPersonController.Running ? RunningStrideLengthen : 1f)); newCameraPosition = Camera.transform.localPosition; newCameraPosition.y = Camera.transform.localPosition.y - jumpAndLandingBob.Offset(); } @@ -49,7 +48,7 @@ private void Update() } m_PreviouslyGrounded = rigidbodyFirstPersonController.Grounded; - // m_CameraRefocus.SetFocusPoint(); + // m_CameraRefocus.SetFocusPoint(); } } } diff --git a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/MouseLook.cs b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/MouseLook.cs index 79c3aa20016e101b17b9e1b56562b47110e0b09d..8b77c17a032d831032d0e54a7fe3ddc67c77de8e 100644 --- a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/MouseLook.cs +++ b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/MouseLook.cs @@ -33,17 +33,17 @@ public void LookRotation(Transform character, Transform camera) float yRot = CrossPlatformInputManager.GetAxis("Mouse X") * XSensitivity; float xRot = CrossPlatformInputManager.GetAxis("Mouse Y") * YSensitivity; - m_CharacterTargetRot *= Quaternion.Euler (0f, yRot, 0f); - m_CameraTargetRot *= Quaternion.Euler (-xRot, 0f, 0f); + m_CharacterTargetRot *= Quaternion.Euler(0f, yRot, 0f); + m_CameraTargetRot *= Quaternion.Euler(-xRot, 0f, 0f); - if(clampVerticalRotation) - m_CameraTargetRot = ClampRotationAroundXAxis (m_CameraTargetRot); + if (clampVerticalRotation) + m_CameraTargetRot = ClampRotationAroundXAxis(m_CameraTargetRot); - if(smooth) + if (smooth) { - character.localRotation = Quaternion.Slerp (character.localRotation, m_CharacterTargetRot, + character.localRotation = Quaternion.Slerp(character.localRotation, m_CharacterTargetRot, smoothTime * Time.deltaTime); - camera.localRotation = Quaternion.Slerp (camera.localRotation, m_CameraTargetRot, + camera.localRotation = Quaternion.Slerp(camera.localRotation, m_CameraTargetRot, smoothTime * Time.deltaTime); } else @@ -58,7 +58,7 @@ public void LookRotation(Transform character, Transform camera) public void SetCursorLock(bool value) { lockCursor = value; - if(!lockCursor) + if (!lockCursor) {//we force unlock the cursor if the user disable the cursor locking helper Cursor.lockState = CursorLockMode.None; Cursor.visible = true; @@ -74,11 +74,11 @@ public void UpdateCursorLock() private void InternalLockUpdate() { - if(Input.GetKeyUp(KeyCode.Escape)) + if (Input.GetKeyUp(KeyCode.Escape)) { m_cursorIsLocked = false; } - else if(Input.GetMouseButtonUp(0)) + else if (Input.GetMouseButtonUp(0)) { m_cursorIsLocked = true; } @@ -102,11 +102,11 @@ Quaternion ClampRotationAroundXAxis(Quaternion q) q.z /= q.w; q.w = 1.0f; - float angleX = 2.0f * Mathf.Rad2Deg * Mathf.Atan (q.x); + float angleX = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.x); - angleX = Mathf.Clamp (angleX, MinimumX, MaximumX); + angleX = Mathf.Clamp(angleX, MinimumX, MaximumX); - q.x = Mathf.Tan (0.5f * Mathf.Deg2Rad * angleX); + q.x = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleX); return q; } diff --git a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/RigidbodyFirstPersonController.cs b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/RigidbodyFirstPersonController.cs index 9caa5ef1fa5cfe19c093e442e152bd0fc17f11a0..bc02c61d849f589fa93069e9ef42fddbdc2fd21f 100644 --- a/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/RigidbodyFirstPersonController.cs +++ b/Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/RigidbodyFirstPersonController.cs @@ -4,8 +4,8 @@ namespace UnityStandardAssets.Characters.FirstPerson { - [RequireComponent(typeof (Rigidbody))] - [RequireComponent(typeof (CapsuleCollider))] + [RequireComponent(typeof(Rigidbody))] + [RequireComponent(typeof(CapsuleCollider))] public class RigidbodyFirstPersonController : MonoBehaviour { [Serializable] @@ -15,7 +15,7 @@ public class MovementSettings public float BackwardSpeed = 4.0f; // Speed when walking backwards public float StrafeSpeed = 4.0f; // Speed when walking sideways public float RunMultiplier = 2.0f; // Speed when sprinting - public KeyCode RunKey = KeyCode.LeftShift; + public KeyCode RunKey = KeyCode.LeftShift; public float JumpForce = 30f; public AnimationCurve SlopeCurveModifier = new AnimationCurve(new Keyframe(-90.0f, 1.0f), new Keyframe(0.0f, 1.0f), new Keyframe(90.0f, 0.0f)); [HideInInspector] public float CurrentTargetSpeed = 8f; @@ -26,33 +26,33 @@ public class MovementSettings public void UpdateDesiredTargetSpeed(Vector2 input) { - if (input == Vector2.zero) return; - if (input.x > 0 || input.x < 0) - { - //strafe - CurrentTargetSpeed = StrafeSpeed; - } - if (input.y < 0) - { - //backwards - CurrentTargetSpeed = BackwardSpeed; - } - if (input.y > 0) - { - //forwards - //handled last as if strafing and moving forward at the same time forwards speed should take precedence - CurrentTargetSpeed = ForwardSpeed; - } + if (input == Vector2.zero) return; + if (input.x > 0 || input.x < 0) + { + //strafe + CurrentTargetSpeed = StrafeSpeed; + } + if (input.y < 0) + { + //backwards + CurrentTargetSpeed = BackwardSpeed; + } + if (input.y > 0) + { + //forwards + //handled last as if strafing and moving forward at the same time forwards speed should take precedence + CurrentTargetSpeed = ForwardSpeed; + } #if !MOBILE_INPUT - if (Input.GetKey(RunKey)) - { - CurrentTargetSpeed *= RunMultiplier; - m_Running = true; - } - else - { - m_Running = false; - } + if (Input.GetKey(RunKey)) + { + CurrentTargetSpeed *= RunMultiplier; + m_Running = true; + } + else + { + m_Running = false; + } #endif } @@ -109,8 +109,8 @@ public bool Running { get { - #if !MOBILE_INPUT - return movementSettings.Running; +#if !MOBILE_INPUT + return movementSettings.Running; #else return false; #endif @@ -122,7 +122,7 @@ private void Start() { m_RigidBody = GetComponent<Rigidbody>(); m_Capsule = GetComponent<CapsuleCollider>(); - mouseLook.Init (transform, cam.transform); + mouseLook.Init(transform, cam.transform); } @@ -145,16 +145,16 @@ private void FixedUpdate() if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon) && (advancedSettings.airControl || m_IsGrounded)) { // always move along the camera forward as it is the direction that it being aimed at - Vector3 desiredMove = cam.transform.forward*input.y + cam.transform.right*input.x; + Vector3 desiredMove = cam.transform.forward * input.y + cam.transform.right * input.x; desiredMove = Vector3.ProjectOnPlane(desiredMove, m_GroundContactNormal).normalized; - desiredMove.x = desiredMove.x*movementSettings.CurrentTargetSpeed; - desiredMove.z = desiredMove.z*movementSettings.CurrentTargetSpeed; - desiredMove.y = desiredMove.y*movementSettings.CurrentTargetSpeed; + desiredMove.x = desiredMove.x * movementSettings.CurrentTargetSpeed; + desiredMove.z = desiredMove.z * movementSettings.CurrentTargetSpeed; + desiredMove.y = desiredMove.y * movementSettings.CurrentTargetSpeed; if (m_RigidBody.velocity.sqrMagnitude < - (movementSettings.CurrentTargetSpeed*movementSettings.CurrentTargetSpeed)) + (movementSettings.CurrentTargetSpeed * movementSettings.CurrentTargetSpeed)) { - m_RigidBody.AddForce(desiredMove*SlopeMultiplier(), ForceMode.Impulse); + m_RigidBody.AddForce(desiredMove * SlopeMultiplier(), ForceMode.Impulse); } } @@ -198,7 +198,7 @@ private void StickToGroundHelper() { RaycastHit hitInfo; if (Physics.SphereCast(transform.position, m_Capsule.radius * (1.0f - advancedSettings.shellOffset), Vector3.down, out hitInfo, - ((m_Capsule.height/2f) - m_Capsule.radius) + + ((m_Capsule.height / 2f) - m_Capsule.radius) + advancedSettings.stickToGroundHelperDistance, Physics.AllLayers, QueryTriggerInteraction.Ignore)) { if (Mathf.Abs(Vector3.Angle(hitInfo.normal, Vector3.up)) < 85f) @@ -211,13 +211,13 @@ private void StickToGroundHelper() private Vector2 GetInput() { - + Vector2 input = new Vector2 - { - x = CrossPlatformInputManager.GetAxis("Horizontal"), - y = CrossPlatformInputManager.GetAxis("Vertical") - }; - movementSettings.UpdateDesiredTargetSpeed(input); + { + x = CrossPlatformInputManager.GetAxis("Horizontal"), + y = CrossPlatformInputManager.GetAxis("Vertical") + }; + movementSettings.UpdateDesiredTargetSpeed(input); return input; } @@ -230,13 +230,13 @@ private void RotateView() // get the rotation before it's changed float oldYRotation = transform.eulerAngles.y; - mouseLook.LookRotation (transform, cam.transform); + mouseLook.LookRotation(transform, cam.transform); if (m_IsGrounded || advancedSettings.airControl) { // Rotate the rigidbody velocity to match the new direction that the character is looking Quaternion velRotation = Quaternion.AngleAxis(transform.eulerAngles.y - oldYRotation, Vector3.up); - m_RigidBody.velocity = velRotation*m_RigidBody.velocity; + m_RigidBody.velocity = velRotation * m_RigidBody.velocity; } } @@ -246,7 +246,7 @@ private void GroundCheck() m_PreviouslyGrounded = m_IsGrounded; RaycastHit hitInfo; if (Physics.SphereCast(transform.position, m_Capsule.radius * (1.0f - advancedSettings.shellOffset), Vector3.down, out hitInfo, - ((m_Capsule.height/2f) - m_Capsule.radius) + advancedSettings.groundCheckDistance, Physics.AllLayers, QueryTriggerInteraction.Ignore)) + ((m_Capsule.height / 2f) - m_Capsule.radius) + advancedSettings.groundCheckDistance, Physics.AllLayers, QueryTriggerInteraction.Ignore)) { m_IsGrounded = true; m_GroundContactNormal = hitInfo.normal; diff --git a/Assets/Standard Assets/Characters/RollerBall/Scripts/Ball.cs b/Assets/Standard Assets/Characters/RollerBall/Scripts/Ball.cs index 6d37fbd971397aa063d77bcc7ea41d3f8fcb22ea..550d60206d2c16c44a1c36924421fef1e2bdfce1 100644 --- a/Assets/Standard Assets/Characters/RollerBall/Scripts/Ball.cs +++ b/Assets/Standard Assets/Characters/RollerBall/Scripts/Ball.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Ball @@ -28,19 +27,19 @@ public void Move(Vector3 moveDirection, bool jump) if (m_UseTorque) { // ... add torque around the axis defined by the move direction. - m_Rigidbody.AddTorque(new Vector3(moveDirection.z, 0, -moveDirection.x)*m_MovePower); + m_Rigidbody.AddTorque(new Vector3(moveDirection.z, 0, -moveDirection.x) * m_MovePower); } else { // Otherwise add force in the move direction. - m_Rigidbody.AddForce(moveDirection*m_MovePower); + m_Rigidbody.AddForce(moveDirection * m_MovePower); } // If on the ground and jump is pressed... if (Physics.Raycast(transform.position, -Vector3.up, k_GroundRayLength) && jump) { // ... add force in upwards. - m_Rigidbody.AddForce(Vector3.up*m_JumpPower, ForceMode.Impulse); + m_Rigidbody.AddForce(Vector3.up * m_JumpPower, ForceMode.Impulse); } } } diff --git a/Assets/Standard Assets/Characters/RollerBall/Scripts/BallUserControl.cs b/Assets/Standard Assets/Characters/RollerBall/Scripts/BallUserControl.cs index e766c0f2ae13c8efbae5738e7310c641ffc15e0a..f86d65f72448ca4f95d40ae9767230ec14064e8a 100644 --- a/Assets/Standard Assets/Characters/RollerBall/Scripts/BallUserControl.cs +++ b/Assets/Standard Assets/Characters/RollerBall/Scripts/BallUserControl.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; @@ -49,12 +48,12 @@ private void Update() { // calculate camera relative direction to move: camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; - move = (v*camForward + h*cam.right).normalized; + move = (v * camForward + h * cam.right).normalized; } else { // we use world-relative directions in the case of no main camera - move = (v*Vector3.forward + h*Vector3.right).normalized; + move = (v * Vector3.forward + h * Vector3.right).normalized; } } diff --git a/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/AICharacterControl.cs b/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/AICharacterControl.cs index 846615a7fd5f8824b7b623f4b0b936358179cb7f..c82c4f350a1bff5c0e25326adb2b19c9df4fff70 100644 --- a/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/AICharacterControl.cs +++ b/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/AICharacterControl.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Characters.ThirdPerson { - [RequireComponent(typeof (UnityEngine.AI.NavMeshAgent))] - [RequireComponent(typeof (ThirdPersonCharacter))] + [RequireComponent(typeof(UnityEngine.AI.NavMeshAgent))] + [RequireComponent(typeof(ThirdPersonCharacter))] public class AICharacterControl : MonoBehaviour { public UnityEngine.AI.NavMeshAgent agent { get; private set; } // the navmesh agent required for the path finding @@ -18,8 +17,8 @@ private void Start() agent = GetComponentInChildren<UnityEngine.AI.NavMeshAgent>(); character = GetComponent<ThirdPersonCharacter>(); - agent.updateRotation = false; - agent.updatePosition = true; + agent.updateRotation = false; + agent.updatePosition = true; } diff --git a/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonCharacter.cs b/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonCharacter.cs index 5362b47007b6956bb514112853514e2dd4a168fb..51776e19400682f7f42ff0aa6edf2d0455cd17f6 100644 --- a/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonCharacter.cs +++ b/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonCharacter.cs @@ -2,224 +2,224 @@ namespace UnityStandardAssets.Characters.ThirdPerson { - [RequireComponent(typeof(Rigidbody))] - [RequireComponent(typeof(CapsuleCollider))] - [RequireComponent(typeof(Animator))] - public class ThirdPersonCharacter : MonoBehaviour - { - [SerializeField] float m_MovingTurnSpeed = 360; - [SerializeField] float m_StationaryTurnSpeed = 180; - [SerializeField] float m_JumpPower = 12f; - [Range(1f, 4f)][SerializeField] float m_GravityMultiplier = 2f; - [SerializeField] float m_RunCycleLegOffset = 0.2f; //specific to the character in sample assets, will need to be modified to work with others - [SerializeField] float m_MoveSpeedMultiplier = 1f; - [SerializeField] float m_AnimSpeedMultiplier = 1f; - [SerializeField] float m_GroundCheckDistance = 0.1f; - - Rigidbody m_Rigidbody; - Animator m_Animator; - bool m_IsGrounded; - float m_OrigGroundCheckDistance; - const float k_Half = 0.5f; - float m_TurnAmount; - float m_ForwardAmount; - Vector3 m_GroundNormal; - float m_CapsuleHeight; - Vector3 m_CapsuleCenter; - CapsuleCollider m_Capsule; - bool m_Crouching; - - - void Start() - { - m_Animator = GetComponent<Animator>(); - m_Rigidbody = GetComponent<Rigidbody>(); - m_Capsule = GetComponent<CapsuleCollider>(); - m_CapsuleHeight = m_Capsule.height; - m_CapsuleCenter = m_Capsule.center; - - m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ; - m_OrigGroundCheckDistance = m_GroundCheckDistance; - } - - - public void Move(Vector3 move, bool crouch, bool jump) - { - - // convert the world relative moveInput vector into a local-relative - // turn amount and forward amount required to head in the desired - // direction. - if (move.magnitude > 1f) move.Normalize(); - move = transform.InverseTransformDirection(move); - CheckGroundStatus(); - move = Vector3.ProjectOnPlane(move, m_GroundNormal); - m_TurnAmount = Mathf.Atan2(move.x, move.z); - m_ForwardAmount = move.z; - - ApplyExtraTurnRotation(); - - // control and velocity handling is different when grounded and airborne: - if (m_IsGrounded) - { - HandleGroundedMovement(crouch, jump); - } - else - { - HandleAirborneMovement(); - } - - ScaleCapsuleForCrouching(crouch); - PreventStandingInLowHeadroom(); - - // send input and other state parameters to the animator - UpdateAnimator(move); - } - - - void ScaleCapsuleForCrouching(bool crouch) - { - if (m_IsGrounded && crouch) - { - if (m_Crouching) return; - m_Capsule.height = m_Capsule.height / 2f; - m_Capsule.center = m_Capsule.center / 2f; - m_Crouching = true; - } - else - { - Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up); - float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half; - if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore)) - { - m_Crouching = true; - return; - } - m_Capsule.height = m_CapsuleHeight; - m_Capsule.center = m_CapsuleCenter; - m_Crouching = false; - } - } - - void PreventStandingInLowHeadroom() - { - // prevent standing up in crouch-only zones - if (!m_Crouching) - { - Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up); - float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half; - if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore)) - { - m_Crouching = true; - } - } - } - - - void UpdateAnimator(Vector3 move) - { - // update the animator parameters - m_Animator.SetFloat("Forward", m_ForwardAmount, 0.1f, Time.deltaTime); - m_Animator.SetFloat("Turn", m_TurnAmount, 0.1f, Time.deltaTime); - m_Animator.SetBool("Crouch", m_Crouching); - m_Animator.SetBool("OnGround", m_IsGrounded); - if (!m_IsGrounded) - { - m_Animator.SetFloat("Jump", m_Rigidbody.velocity.y); - } - - // calculate which leg is behind, so as to leave that leg trailing in the jump animation - // (This code is reliant on the specific run cycle offset in our animations, - // and assumes one leg passes the other at the normalized clip times of 0.0 and 0.5) - float runCycle = - Mathf.Repeat( - m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime + m_RunCycleLegOffset, 1); - float jumpLeg = (runCycle < k_Half ? 1 : -1) * m_ForwardAmount; - if (m_IsGrounded) - { - m_Animator.SetFloat("JumpLeg", jumpLeg); - } - - // the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector, - // which affects the movement speed because of the root motion. - if (m_IsGrounded && move.magnitude > 0) - { - m_Animator.speed = m_AnimSpeedMultiplier; - } - else - { - // don't use that while airborne - m_Animator.speed = 1; - } - } - - - void HandleAirborneMovement() - { - // apply extra gravity from multiplier: - Vector3 extraGravityForce = (Physics.gravity * m_GravityMultiplier) - Physics.gravity; - m_Rigidbody.AddForce(extraGravityForce); - - m_GroundCheckDistance = m_Rigidbody.velocity.y < 0 ? m_OrigGroundCheckDistance : 0.01f; - } - - - void HandleGroundedMovement(bool crouch, bool jump) - { - // check whether conditions are right to allow a jump: - if (jump && !crouch && m_Animator.GetCurrentAnimatorStateInfo(0).IsName("Grounded")) - { - // jump! - m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, m_JumpPower, m_Rigidbody.velocity.z); - m_IsGrounded = false; - m_Animator.applyRootMotion = false; - m_GroundCheckDistance = 0.1f; - } - } - - void ApplyExtraTurnRotation() - { - // help the character turn faster (this is in addition to root rotation in the animation) - float turnSpeed = Mathf.Lerp(m_StationaryTurnSpeed, m_MovingTurnSpeed, m_ForwardAmount); - transform.Rotate(0, m_TurnAmount * turnSpeed * Time.deltaTime, 0); - } - - - public void OnAnimatorMove() - { - // we implement this function to override the default root motion. - // this allows us to modify the positional speed before it's applied. - if (m_IsGrounded && Time.deltaTime > 0) - { - Vector3 v = (m_Animator.deltaPosition * m_MoveSpeedMultiplier) / Time.deltaTime; - - // we preserve the existing y part of the current velocity. - v.y = m_Rigidbody.velocity.y; - m_Rigidbody.velocity = v; - } - } - - - void CheckGroundStatus() - { - RaycastHit hitInfo; + [RequireComponent(typeof(Rigidbody))] + [RequireComponent(typeof(CapsuleCollider))] + [RequireComponent(typeof(Animator))] + public class ThirdPersonCharacter : MonoBehaviour + { + [SerializeField] float m_MovingTurnSpeed = 360; + [SerializeField] float m_StationaryTurnSpeed = 180; + [SerializeField] float m_JumpPower = 12f; + [Range(1f, 4f)] [SerializeField] float m_GravityMultiplier = 2f; + [SerializeField] float m_RunCycleLegOffset = 0.2f; //specific to the character in sample assets, will need to be modified to work with others + [SerializeField] float m_MoveSpeedMultiplier = 1f; + [SerializeField] float m_AnimSpeedMultiplier = 1f; + [SerializeField] float m_GroundCheckDistance = 0.1f; + + Rigidbody m_Rigidbody; + Animator m_Animator; + bool m_IsGrounded; + float m_OrigGroundCheckDistance; + const float k_Half = 0.5f; + float m_TurnAmount; + float m_ForwardAmount; + Vector3 m_GroundNormal; + float m_CapsuleHeight; + Vector3 m_CapsuleCenter; + CapsuleCollider m_Capsule; + bool m_Crouching; + + + void Start() + { + m_Animator = GetComponent<Animator>(); + m_Rigidbody = GetComponent<Rigidbody>(); + m_Capsule = GetComponent<CapsuleCollider>(); + m_CapsuleHeight = m_Capsule.height; + m_CapsuleCenter = m_Capsule.center; + + m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ; + m_OrigGroundCheckDistance = m_GroundCheckDistance; + } + + + public void Move(Vector3 move, bool crouch, bool jump) + { + + // convert the world relative moveInput vector into a local-relative + // turn amount and forward amount required to head in the desired + // direction. + if (move.magnitude > 1f) move.Normalize(); + move = transform.InverseTransformDirection(move); + CheckGroundStatus(); + move = Vector3.ProjectOnPlane(move, m_GroundNormal); + m_TurnAmount = Mathf.Atan2(move.x, move.z); + m_ForwardAmount = move.z; + + ApplyExtraTurnRotation(); + + // control and velocity handling is different when grounded and airborne: + if (m_IsGrounded) + { + HandleGroundedMovement(crouch, jump); + } + else + { + HandleAirborneMovement(); + } + + ScaleCapsuleForCrouching(crouch); + PreventStandingInLowHeadroom(); + + // send input and other state parameters to the animator + UpdateAnimator(move); + } + + + void ScaleCapsuleForCrouching(bool crouch) + { + if (m_IsGrounded && crouch) + { + if (m_Crouching) return; + m_Capsule.height = m_Capsule.height / 2f; + m_Capsule.center = m_Capsule.center / 2f; + m_Crouching = true; + } + else + { + Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up); + float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half; + if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore)) + { + m_Crouching = true; + return; + } + m_Capsule.height = m_CapsuleHeight; + m_Capsule.center = m_CapsuleCenter; + m_Crouching = false; + } + } + + void PreventStandingInLowHeadroom() + { + // prevent standing up in crouch-only zones + if (!m_Crouching) + { + Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up); + float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half; + if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore)) + { + m_Crouching = true; + } + } + } + + + void UpdateAnimator(Vector3 move) + { + // update the animator parameters + m_Animator.SetFloat("Forward", m_ForwardAmount, 0.1f, Time.deltaTime); + m_Animator.SetFloat("Turn", m_TurnAmount, 0.1f, Time.deltaTime); + m_Animator.SetBool("Crouch", m_Crouching); + m_Animator.SetBool("OnGround", m_IsGrounded); + if (!m_IsGrounded) + { + m_Animator.SetFloat("Jump", m_Rigidbody.velocity.y); + } + + // calculate which leg is behind, so as to leave that leg trailing in the jump animation + // (This code is reliant on the specific run cycle offset in our animations, + // and assumes one leg passes the other at the normalized clip times of 0.0 and 0.5) + float runCycle = + Mathf.Repeat( + m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime + m_RunCycleLegOffset, 1); + float jumpLeg = (runCycle < k_Half ? 1 : -1) * m_ForwardAmount; + if (m_IsGrounded) + { + m_Animator.SetFloat("JumpLeg", jumpLeg); + } + + // the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector, + // which affects the movement speed because of the root motion. + if (m_IsGrounded && move.magnitude > 0) + { + m_Animator.speed = m_AnimSpeedMultiplier; + } + else + { + // don't use that while airborne + m_Animator.speed = 1; + } + } + + + void HandleAirborneMovement() + { + // apply extra gravity from multiplier: + Vector3 extraGravityForce = (Physics.gravity * m_GravityMultiplier) - Physics.gravity; + m_Rigidbody.AddForce(extraGravityForce); + + m_GroundCheckDistance = m_Rigidbody.velocity.y < 0 ? m_OrigGroundCheckDistance : 0.01f; + } + + + void HandleGroundedMovement(bool crouch, bool jump) + { + // check whether conditions are right to allow a jump: + if (jump && !crouch && m_Animator.GetCurrentAnimatorStateInfo(0).IsName("Grounded")) + { + // jump! + m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, m_JumpPower, m_Rigidbody.velocity.z); + m_IsGrounded = false; + m_Animator.applyRootMotion = false; + m_GroundCheckDistance = 0.1f; + } + } + + void ApplyExtraTurnRotation() + { + // help the character turn faster (this is in addition to root rotation in the animation) + float turnSpeed = Mathf.Lerp(m_StationaryTurnSpeed, m_MovingTurnSpeed, m_ForwardAmount); + transform.Rotate(0, m_TurnAmount * turnSpeed * Time.deltaTime, 0); + } + + + public void OnAnimatorMove() + { + // we implement this function to override the default root motion. + // this allows us to modify the positional speed before it's applied. + if (m_IsGrounded && Time.deltaTime > 0) + { + Vector3 v = (m_Animator.deltaPosition * m_MoveSpeedMultiplier) / Time.deltaTime; + + // we preserve the existing y part of the current velocity. + v.y = m_Rigidbody.velocity.y; + m_Rigidbody.velocity = v; + } + } + + + void CheckGroundStatus() + { + RaycastHit hitInfo; #if UNITY_EDITOR - // helper to visualise the ground check ray in the scene view - Debug.DrawLine(transform.position + (Vector3.up * 0.1f), transform.position + (Vector3.up * 0.1f) + (Vector3.down * m_GroundCheckDistance)); + // helper to visualise the ground check ray in the scene view + Debug.DrawLine(transform.position + (Vector3.up * 0.1f), transform.position + (Vector3.up * 0.1f) + (Vector3.down * m_GroundCheckDistance)); #endif - // 0.1f is a small offset to start the ray from inside the character - // it is also good to note that the transform position in the sample assets is at the base of the character - if (Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, m_GroundCheckDistance)) - { - m_GroundNormal = hitInfo.normal; - m_IsGrounded = true; - m_Animator.applyRootMotion = true; - } - else - { - m_IsGrounded = false; - m_GroundNormal = Vector3.up; - m_Animator.applyRootMotion = false; - } - } - } + // 0.1f is a small offset to start the ray from inside the character + // it is also good to note that the transform position in the sample assets is at the base of the character + if (Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, m_GroundCheckDistance)) + { + m_GroundNormal = hitInfo.normal; + m_IsGrounded = true; + m_Animator.applyRootMotion = true; + } + else + { + m_IsGrounded = false; + m_GroundNormal = Vector3.up; + m_Animator.applyRootMotion = false; + } + } + } } diff --git a/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonUserControl.cs b/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonUserControl.cs index 875fffefee89f085b84619af3890b24cc3f4a8ac..dc4878103d64fc8ded3355423d0af7d1fad3f29d 100644 --- a/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonUserControl.cs +++ b/Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonUserControl.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; namespace UnityStandardAssets.Characters.ThirdPerson { - [RequireComponent(typeof (ThirdPersonCharacter))] + [RequireComponent(typeof(ThirdPersonCharacter))] public class ThirdPersonUserControl : MonoBehaviour { private ThirdPersonCharacter m_Character; // A reference to the ThirdPersonCharacter on the object @@ -13,7 +12,7 @@ public class ThirdPersonUserControl : MonoBehaviour private Vector3 m_Move; private bool m_Jump; // the world-relative desired move direction, calculated from the camForward and user input. - + private void Start() { // get the transform of the main camera @@ -55,16 +54,16 @@ private void FixedUpdate() { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; - m_Move = v*m_CamForward + h*m_Cam.right; + m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera - m_Move = v*Vector3.forward + h*Vector3.right; + m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT - // walk speed multiplier - if (Input.GetKey(KeyCode.LeftShift)) m_Move *= 0.5f; + // walk speed multiplier + if (Input.GetKey(KeyCode.LeftShift)) m_Move *= 0.5f; #endif // pass all parameters to the character control script diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs index 622138b362e4d2d4237ad42848135dfa80dc576f..37de91edb1c9657884c2995fc9d504f3ed077696 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs @@ -1,75 +1,74 @@ -using System; using UnityEngine; using UnityEngine.EventSystems; namespace UnityStandardAssets.CrossPlatformInput { - public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler - { - // designed to work in a pair with another axis touch button - // (typically with one having -1 and one having 1 axisValues) - public string axisName = "Horizontal"; // The name of the axis - public float axisValue = 1; // The axis that the value has - public float responseSpeed = 3; // The speed at which the axis touch button responds - public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre + public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler + { + // designed to work in a pair with another axis touch button + // (typically with one having -1 and one having 1 axisValues) + public string axisName = "Horizontal"; // The name of the axis + public float axisValue = 1; // The axis that the value has + public float responseSpeed = 3; // The speed at which the axis touch button responds + public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre - AxisTouchButton m_PairedWith; // Which button this one is paired with - CrossPlatformInputManager.VirtualAxis m_Axis; // A reference to the virtual axis as it is in the cross platform input + AxisTouchButton m_PairedWith; // Which button this one is paired with + CrossPlatformInputManager.VirtualAxis m_Axis; // A reference to the virtual axis as it is in the cross platform input - void OnEnable() - { - if (!CrossPlatformInputManager.AxisExists(axisName)) - { - // if the axis doesnt exist create a new one in cross platform input - m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName); - CrossPlatformInputManager.RegisterVirtualAxis(m_Axis); - } - else - { - m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName); - } - FindPairedButton(); - } + void OnEnable() + { + if (!CrossPlatformInputManager.AxisExists(axisName)) + { + // if the axis doesnt exist create a new one in cross platform input + m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_Axis); + } + else + { + m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName); + } + FindPairedButton(); + } - void FindPairedButton() - { - // find the other button witch which this button should be paired - // (it should have the same axisName) - var otherAxisButtons = FindObjectsOfType(typeof(AxisTouchButton)) as AxisTouchButton[]; + void FindPairedButton() + { + // find the other button witch which this button should be paired + // (it should have the same axisName) + var otherAxisButtons = FindObjectsOfType(typeof(AxisTouchButton)) as AxisTouchButton[]; - if (otherAxisButtons != null) - { - for (int i = 0; i < otherAxisButtons.Length; i++) - { - if (otherAxisButtons[i].axisName == axisName && otherAxisButtons[i] != this) - { - m_PairedWith = otherAxisButtons[i]; - } - } - } - } + if (otherAxisButtons != null) + { + for (int i = 0; i < otherAxisButtons.Length; i++) + { + if (otherAxisButtons[i].axisName == axisName && otherAxisButtons[i] != this) + { + m_PairedWith = otherAxisButtons[i]; + } + } + } + } - void OnDisable() - { - // The object is disabled so remove it from the cross platform input system - m_Axis.Remove(); - } + void OnDisable() + { + // The object is disabled so remove it from the cross platform input system + m_Axis.Remove(); + } - public void OnPointerDown(PointerEventData data) - { - if (m_PairedWith == null) - { - FindPairedButton(); - } - // update the axis and record that the button has been pressed this frame - m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, axisValue, responseSpeed * Time.deltaTime)); - } + public void OnPointerDown(PointerEventData data) + { + if (m_PairedWith == null) + { + FindPairedButton(); + } + // update the axis and record that the button has been pressed this frame + m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, axisValue, responseSpeed * Time.deltaTime)); + } - public void OnPointerUp(PointerEventData data) - { - m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, 0, responseSpeed * Time.deltaTime)); - } - } + public void OnPointerUp(PointerEventData data) + { + m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, 0, responseSpeed * Time.deltaTime)); + } + } } \ No newline at end of file diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/ButtonHandler.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/ButtonHandler.cs index 3b48f25bb82cacdac183ca87585cce1a09ac7824..a0970699bc43f2fd533bb9b8b0b5143c803a1d38 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/ButtonHandler.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/ButtonHandler.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.CrossPlatformInput diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/CrossPlatformInputManager.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/CrossPlatformInputManager.cs index 9d368c8ae6701282f8dcc32f23725f7c2b8c651f..7076d8e32510c1e64c1b49a0ce821cc492ea4972 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/CrossPlatformInputManager.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/CrossPlatformInputManager.cs @@ -4,315 +4,315 @@ namespace UnityStandardAssets.CrossPlatformInput { - public static class CrossPlatformInputManager - { - public enum ActiveInputMethod - { - Hardware, - Touch - } + public static class CrossPlatformInputManager + { + public enum ActiveInputMethod + { + Hardware, + Touch + } - private static VirtualInput activeInput; + private static VirtualInput activeInput; - private static VirtualInput s_TouchInput; - private static VirtualInput s_HardwareInput; + private static VirtualInput s_TouchInput; + private static VirtualInput s_HardwareInput; - static CrossPlatformInputManager() - { - s_TouchInput = new MobileInput(); - s_HardwareInput = new StandaloneInput(); + static CrossPlatformInputManager() + { + s_TouchInput = new MobileInput(); + s_HardwareInput = new StandaloneInput(); #if MOBILE_INPUT activeInput = s_TouchInput; #else - activeInput = s_HardwareInput; + activeInput = s_HardwareInput; #endif - } + } - public static void SwitchActiveInputMethod(ActiveInputMethod activeInputMethod) - { - switch (activeInputMethod) - { - case ActiveInputMethod.Hardware: - activeInput = s_HardwareInput; - break; + public static void SwitchActiveInputMethod(ActiveInputMethod activeInputMethod) + { + switch (activeInputMethod) + { + case ActiveInputMethod.Hardware: + activeInput = s_HardwareInput; + break; - case ActiveInputMethod.Touch: - activeInput = s_TouchInput; - break; - } - } + case ActiveInputMethod.Touch: + activeInput = s_TouchInput; + break; + } + } - public static bool AxisExists(string name) - { - return activeInput.AxisExists(name); - } + public static bool AxisExists(string name) + { + return activeInput.AxisExists(name); + } - public static bool ButtonExists(string name) - { - return activeInput.ButtonExists(name); - } + public static bool ButtonExists(string name) + { + return activeInput.ButtonExists(name); + } - public static void RegisterVirtualAxis(VirtualAxis axis) - { - activeInput.RegisterVirtualAxis(axis); - } + public static void RegisterVirtualAxis(VirtualAxis axis) + { + activeInput.RegisterVirtualAxis(axis); + } - public static void RegisterVirtualButton(VirtualButton button) - { - activeInput.RegisterVirtualButton(button); - } + public static void RegisterVirtualButton(VirtualButton button) + { + activeInput.RegisterVirtualButton(button); + } - public static void UnRegisterVirtualAxis(string name) - { - if (name == null) - { - throw new ArgumentNullException("name"); - } - activeInput.UnRegisterVirtualAxis(name); - } + public static void UnRegisterVirtualAxis(string name) + { + if (name == null) + { + throw new ArgumentNullException("name"); + } + activeInput.UnRegisterVirtualAxis(name); + } - public static void UnRegisterVirtualButton(string name) - { - activeInput.UnRegisterVirtualButton(name); - } + public static void UnRegisterVirtualButton(string name) + { + activeInput.UnRegisterVirtualButton(name); + } - // returns a reference to a named virtual axis if it exists otherwise null - public static VirtualAxis VirtualAxisReference(string name) - { - return activeInput.VirtualAxisReference(name); - } + // returns a reference to a named virtual axis if it exists otherwise null + public static VirtualAxis VirtualAxisReference(string name) + { + return activeInput.VirtualAxisReference(name); + } - // returns the platform appropriate axis for the given name - public static float GetAxis(string name) - { - return GetAxis(name, false); - } + // returns the platform appropriate axis for the given name + public static float GetAxis(string name) + { + return GetAxis(name, false); + } - public static float GetAxisRaw(string name) - { - return GetAxis(name, true); - } + public static float GetAxisRaw(string name) + { + return GetAxis(name, true); + } - // private function handles both types of axis (raw and not raw) - private static float GetAxis(string name, bool raw) - { - return activeInput.GetAxis(name, raw); - } + // private function handles both types of axis (raw and not raw) + private static float GetAxis(string name, bool raw) + { + return activeInput.GetAxis(name, raw); + } - // -- Button handling -- - public static bool GetButton(string name) - { - return activeInput.GetButton(name); - } + // -- Button handling -- + public static bool GetButton(string name) + { + return activeInput.GetButton(name); + } - public static bool GetButtonDown(string name) - { - return activeInput.GetButtonDown(name); - } + public static bool GetButtonDown(string name) + { + return activeInput.GetButtonDown(name); + } - public static bool GetButtonUp(string name) - { - return activeInput.GetButtonUp(name); - } + public static bool GetButtonUp(string name) + { + return activeInput.GetButtonUp(name); + } - public static void SetButtonDown(string name) - { - activeInput.SetButtonDown(name); - } + public static void SetButtonDown(string name) + { + activeInput.SetButtonDown(name); + } - public static void SetButtonUp(string name) - { - activeInput.SetButtonUp(name); - } + public static void SetButtonUp(string name) + { + activeInput.SetButtonUp(name); + } - public static void SetAxisPositive(string name) - { - activeInput.SetAxisPositive(name); - } + public static void SetAxisPositive(string name) + { + activeInput.SetAxisPositive(name); + } - public static void SetAxisNegative(string name) - { - activeInput.SetAxisNegative(name); - } + public static void SetAxisNegative(string name) + { + activeInput.SetAxisNegative(name); + } - public static void SetAxisZero(string name) - { - activeInput.SetAxisZero(name); - } + public static void SetAxisZero(string name) + { + activeInput.SetAxisZero(name); + } - public static void SetAxis(string name, float value) - { - activeInput.SetAxis(name, value); - } + public static void SetAxis(string name, float value) + { + activeInput.SetAxis(name, value); + } - public static Vector3 mousePosition - { - get { return activeInput.MousePosition(); } - } + public static Vector3 mousePosition + { + get { return activeInput.MousePosition(); } + } - public static void SetVirtualMousePositionX(float f) - { - activeInput.SetVirtualMousePositionX(f); - } + public static void SetVirtualMousePositionX(float f) + { + activeInput.SetVirtualMousePositionX(f); + } - public static void SetVirtualMousePositionY(float f) - { - activeInput.SetVirtualMousePositionY(f); - } + public static void SetVirtualMousePositionY(float f) + { + activeInput.SetVirtualMousePositionY(f); + } - public static void SetVirtualMousePositionZ(float f) - { - activeInput.SetVirtualMousePositionZ(f); - } + public static void SetVirtualMousePositionZ(float f) + { + activeInput.SetVirtualMousePositionZ(f); + } - // virtual axis and button classes - applies to mobile input - // Can be mapped to touch joysticks, tilt, gyro, etc, depending on desired implementation. - // Could also be implemented by other input devices - kinect, electronic sensors, etc - public class VirtualAxis - { - public string name { get; private set; } - private float m_Value; - public bool matchWithInputManager { get; private set; } + // virtual axis and button classes - applies to mobile input + // Can be mapped to touch joysticks, tilt, gyro, etc, depending on desired implementation. + // Could also be implemented by other input devices - kinect, electronic sensors, etc + public class VirtualAxis + { + public string name { get; private set; } + private float m_Value; + public bool matchWithInputManager { get; private set; } - public VirtualAxis(string name) - : this(name, true) - { - } + public VirtualAxis(string name) + : this(name, true) + { + } - public VirtualAxis(string name, bool matchToInputSettings) - { - this.name = name; - matchWithInputManager = matchToInputSettings; - } + public VirtualAxis(string name, bool matchToInputSettings) + { + this.name = name; + matchWithInputManager = matchToInputSettings; + } - // removes an axes from the cross platform input system - public void Remove() - { - UnRegisterVirtualAxis(name); - } + // removes an axes from the cross platform input system + public void Remove() + { + UnRegisterVirtualAxis(name); + } - // a controller gameobject (eg. a virtual thumbstick) should update this class - public void Update(float value) - { - m_Value = value; - } + // a controller gameobject (eg. a virtual thumbstick) should update this class + public void Update(float value) + { + m_Value = value; + } - public float GetValue - { - get { return m_Value; } - } + public float GetValue + { + get { return m_Value; } + } - public float GetValueRaw - { - get { return m_Value; } - } - } + public float GetValueRaw + { + get { return m_Value; } + } + } - // a controller gameobject (eg. a virtual GUI button) should call the - // 'pressed' function of this class. Other objects can then read the - // Get/Down/Up state of this button. - public class VirtualButton - { - public string name { get; private set; } - public bool matchWithInputManager { get; private set; } + // a controller gameobject (eg. a virtual GUI button) should call the + // 'pressed' function of this class. Other objects can then read the + // Get/Down/Up state of this button. + public class VirtualButton + { + public string name { get; private set; } + public bool matchWithInputManager { get; private set; } - private int m_LastPressedFrame = -5; - private int m_ReleasedFrame = -5; - private bool m_Pressed; + private int m_LastPressedFrame = -5; + private int m_ReleasedFrame = -5; + private bool m_Pressed; - public VirtualButton(string name) - : this(name, true) - { - } + public VirtualButton(string name) + : this(name, true) + { + } - public VirtualButton(string name, bool matchToInputSettings) - { - this.name = name; - matchWithInputManager = matchToInputSettings; - } + public VirtualButton(string name, bool matchToInputSettings) + { + this.name = name; + matchWithInputManager = matchToInputSettings; + } - // A controller gameobject should call this function when the button is pressed down - public void Pressed() - { - if (m_Pressed) - { - return; - } - m_Pressed = true; - m_LastPressedFrame = Time.frameCount; - } + // A controller gameobject should call this function when the button is pressed down + public void Pressed() + { + if (m_Pressed) + { + return; + } + m_Pressed = true; + m_LastPressedFrame = Time.frameCount; + } - // A controller gameobject should call this function when the button is released - public void Released() - { - m_Pressed = false; - m_ReleasedFrame = Time.frameCount; - } + // A controller gameobject should call this function when the button is released + public void Released() + { + m_Pressed = false; + m_ReleasedFrame = Time.frameCount; + } - - // the controller gameobject should call Remove when the button is destroyed or disabled - public void Remove() - { - UnRegisterVirtualButton(name); - } - - - // these are the states of the button which can be read via the cross platform input system - public bool GetButton - { - get { return m_Pressed; } - } + + // the controller gameobject should call Remove when the button is destroyed or disabled + public void Remove() + { + UnRegisterVirtualButton(name); + } + + + // these are the states of the button which can be read via the cross platform input system + public bool GetButton + { + get { return m_Pressed; } + } - public bool GetButtonDown - { - get - { - return m_LastPressedFrame - Time.frameCount == -1; - } - } - - - public bool GetButtonUp - { - get - { - return (m_ReleasedFrame == Time.frameCount - 1); - } - } - } - } + public bool GetButtonDown + { + get + { + return m_LastPressedFrame - Time.frameCount == -1; + } + } + + + public bool GetButtonUp + { + get + { + return (m_ReleasedFrame == Time.frameCount - 1); + } + } + } + } } diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/InputAxisScrollbar.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/InputAxisScrollbar.cs index c524fc25b725ebca855b6cc84ef002e8be20bb4c..7aa2bbd15d4b75109e11647be4942dc11b3c7f40 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/InputAxisScrollbar.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/InputAxisScrollbar.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.CrossPlatformInput @@ -7,11 +6,11 @@ public class InputAxisScrollbar : MonoBehaviour { public string axis; - void Update() { } + void Update() { } - public void HandleInput(float value) + public void HandleInput(float value) { - CrossPlatformInputManager.SetAxis(axis, (value*2f) - 1f); + CrossPlatformInputManager.SetAxis(axis, (value * 2f) - 1f); } } } diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs index b01f5ef8e03970c86df7bc6428e38df403494980..2cacf9ce342db35e848d6ab6780e7286bb67663f 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs @@ -1,118 +1,117 @@ -using System; using UnityEngine; using UnityEngine.EventSystems; namespace UnityStandardAssets.CrossPlatformInput { - public class Joystick : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler - { - public enum AxisOption - { - // Options for which axes to use - Both, // Use both - OnlyHorizontal, // Only horizontal - OnlyVertical // Only vertical - } - - public int MovementRange = 100; - public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use - public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input - public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input - - Vector3 m_StartPos; - bool m_UseX; // Toggle for using the x axis - bool m_UseY; // Toggle for using the Y axis - CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input - CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input - - void OnEnable() - { - CreateVirtualAxes(); - } + public class Joystick : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler + { + public enum AxisOption + { + // Options for which axes to use + Both, // Use both + OnlyHorizontal, // Only horizontal + OnlyVertical // Only vertical + } + + public int MovementRange = 100; + public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use + public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input + public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input + + Vector3 m_StartPos; + bool m_UseX; // Toggle for using the x axis + bool m_UseY; // Toggle for using the Y axis + CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input + CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input + + void OnEnable() + { + CreateVirtualAxes(); + } void Start() { m_StartPos = transform.position; } - void UpdateVirtualAxes(Vector3 value) - { - var delta = m_StartPos - value; - delta.y = -delta.y; - delta /= MovementRange; - if (m_UseX) - { - m_HorizontalVirtualAxis.Update(-delta.x); - } - - if (m_UseY) - { - m_VerticalVirtualAxis.Update(delta.y); - } - } - - void CreateVirtualAxes() - { - // set axes to use - m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); - m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); - - // create new axes based on axes to use - if (m_UseX) - { - m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); - CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); - } - if (m_UseY) - { - m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); - CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); - } - } - - - public void OnDrag(PointerEventData data) - { - Vector3 newPos = Vector3.zero; - - if (m_UseX) - { - int delta = (int)(data.position.x - m_StartPos.x); - delta = Mathf.Clamp(delta, - MovementRange, MovementRange); - newPos.x = delta; - } - - if (m_UseY) - { - int delta = (int)(data.position.y - m_StartPos.y); - delta = Mathf.Clamp(delta, -MovementRange, MovementRange); - newPos.y = delta; - } - transform.position = new Vector3(m_StartPos.x + newPos.x, m_StartPos.y + newPos.y, m_StartPos.z + newPos.z); - UpdateVirtualAxes(transform.position); - } - - - public void OnPointerUp(PointerEventData data) - { - transform.position = m_StartPos; - UpdateVirtualAxes(m_StartPos); - } - - - public void OnPointerDown(PointerEventData data) { } - - void OnDisable() - { - // remove the joysticks from the cross platform input - if (m_UseX) - { - m_HorizontalVirtualAxis.Remove(); - } - if (m_UseY) - { - m_VerticalVirtualAxis.Remove(); - } - } - } + void UpdateVirtualAxes(Vector3 value) + { + var delta = m_StartPos - value; + delta.y = -delta.y; + delta /= MovementRange; + if (m_UseX) + { + m_HorizontalVirtualAxis.Update(-delta.x); + } + + if (m_UseY) + { + m_VerticalVirtualAxis.Update(delta.y); + } + } + + void CreateVirtualAxes() + { + // set axes to use + m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); + m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); + + // create new axes based on axes to use + if (m_UseX) + { + m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); + } + if (m_UseY) + { + m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); + } + } + + + public void OnDrag(PointerEventData data) + { + Vector3 newPos = Vector3.zero; + + if (m_UseX) + { + int delta = (int)(data.position.x - m_StartPos.x); + delta = Mathf.Clamp(delta, -MovementRange, MovementRange); + newPos.x = delta; + } + + if (m_UseY) + { + int delta = (int)(data.position.y - m_StartPos.y); + delta = Mathf.Clamp(delta, -MovementRange, MovementRange); + newPos.y = delta; + } + transform.position = new Vector3(m_StartPos.x + newPos.x, m_StartPos.y + newPos.y, m_StartPos.z + newPos.z); + UpdateVirtualAxes(transform.position); + } + + + public void OnPointerUp(PointerEventData data) + { + transform.position = m_StartPos; + UpdateVirtualAxes(m_StartPos); + } + + + public void OnPointerDown(PointerEventData data) { } + + void OnDisable() + { + // remove the joysticks from the cross platform input + if (m_UseX) + { + m_HorizontalVirtualAxis.Remove(); + } + if (m_UseY) + { + m_VerticalVirtualAxis.Remove(); + } + } + } } \ No newline at end of file diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs index 638a0c2e2bbb0f836861ff306c1097fc2aa03747..d5ca4bf53e9112174838e3b62d8df0f532bb667d 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs @@ -1,4 +1,3 @@ -using System; #if UNITY_EDITOR using UnityEditor; #endif diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/MobileInput.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/MobileInput.cs index 0416715e346b8a81701a43761379e5144352ea28..34583248748e6e0781a7cb35409d7e88dab881b9 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/MobileInput.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/MobileInput.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.CrossPlatformInput.PlatformSpecific diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/TiltInput.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/TiltInput.cs index 658fddd83cb9e9b01501222c91e8c92d6f344dac..4b8dd76156d295741854609650f069a76ae32642 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/TiltInput.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/TiltInput.cs @@ -61,30 +61,30 @@ private void Update() switch (tiltAroundAxis) { case AxisOptions.ForwardAxis: - angle = Mathf.Atan2(Input.acceleration.x, -Input.acceleration.y)*Mathf.Rad2Deg + + angle = Mathf.Atan2(Input.acceleration.x, -Input.acceleration.y) * Mathf.Rad2Deg + centreAngleOffset; break; case AxisOptions.SidewaysAxis: - angle = Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y)*Mathf.Rad2Deg + + angle = Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y) * Mathf.Rad2Deg + centreAngleOffset; break; } } - float axisValue = Mathf.InverseLerp(-fullTiltAngle, fullTiltAngle, angle)*2 - 1; + float axisValue = Mathf.InverseLerp(-fullTiltAngle, fullTiltAngle, angle) * 2 - 1; switch (mapping.type) { case AxisMapping.MappingType.NamedAxis: m_SteerAxis.Update(axisValue); break; case AxisMapping.MappingType.MousePositionX: - CrossPlatformInputManager.SetVirtualMousePositionX(axisValue*Screen.width); + CrossPlatformInputManager.SetVirtualMousePositionX(axisValue * Screen.width); break; case AxisMapping.MappingType.MousePositionY: - CrossPlatformInputManager.SetVirtualMousePositionY(axisValue*Screen.width); + CrossPlatformInputManager.SetVirtualMousePositionY(axisValue * Screen.width); break; case AxisMapping.MappingType.MousePositionZ: - CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue*Screen.width); + CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue * Screen.width); break; } } @@ -101,7 +101,7 @@ private void OnDisable() namespace UnityStandardAssets.CrossPlatformInput.Inspector { #if UNITY_EDITOR - [CustomPropertyDrawer(typeof (TiltInput.AxisMapping))] + [CustomPropertyDrawer(typeof(TiltInput.AxisMapping))] public class TiltInputAxisStylePropertyDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) @@ -116,18 +116,18 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; - var props = new[] {"type", "axisName"}; - var widths = new[] {.4f, .6f}; + var props = new[] { "type", "axisName" }; + var widths = new[] { .4f, .6f }; if (property.FindPropertyRelative("type").enumValueIndex > 0) { // hide name if not a named axis - props = new[] {"type"}; - widths = new[] {1f}; + props = new[] { "type" }; + widths = new[] { 1f }; } const float lineHeight = 18; for (int n = 0; n < props.Length; ++n) { - float w = widths[n]*inspectorWidth; + float w = widths[n] * inspectorWidth; // Calculate rects Rect rect = new Rect(x, y, w, lineHeight); diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs index 4012331eaf6ee0e0f044c1df786b8ee9175f54c7..a45be28f115fd669858eb845f8e26bd0c90832df 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs @@ -1,60 +1,59 @@ -using System; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace UnityStandardAssets.CrossPlatformInput { - [RequireComponent(typeof(Image))] - public class TouchPad : MonoBehaviour, IPointerDownHandler, IPointerUpHandler - { - // Options for which axes to use - public enum AxisOption - { - Both, // Use both - OnlyHorizontal, // Only horizontal - OnlyVertical // Only vertical - } - - - public enum ControlStyle - { - Absolute, // operates from teh center of the image - Relative, // operates from the center of the initial touch - Swipe, // swipe to touch touch no maintained center - } - - - public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use - public ControlStyle controlStyle = ControlStyle.Absolute; // control style to use - public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input - public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input - public float Xsensitivity = 1f; - public float Ysensitivity = 1f; - - Vector3 m_StartPos; - Vector2 m_PreviousDelta; - Vector3 m_JoytickOutput; - bool m_UseX; // Toggle for using the x axis - bool m_UseY; // Toggle for using the Y axis - CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input - CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input - bool m_Dragging; - int m_Id = -1; - Vector2 m_PreviousTouchPos; // swipe style control touch + [RequireComponent(typeof(Image))] + public class TouchPad : MonoBehaviour, IPointerDownHandler, IPointerUpHandler + { + // Options for which axes to use + public enum AxisOption + { + Both, // Use both + OnlyHorizontal, // Only horizontal + OnlyVertical // Only vertical + } + + + public enum ControlStyle + { + Absolute, // operates from teh center of the image + Relative, // operates from the center of the initial touch + Swipe, // swipe to touch touch no maintained center + } + + + public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use + public ControlStyle controlStyle = ControlStyle.Absolute; // control style to use + public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input + public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input + public float Xsensitivity = 1f; + public float Ysensitivity = 1f; + + Vector3 m_StartPos; + Vector2 m_PreviousDelta; + Vector3 m_JoytickOutput; + bool m_UseX; // Toggle for using the x axis + bool m_UseY; // Toggle for using the Y axis + CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input + CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input + bool m_Dragging; + int m_Id = -1; + Vector2 m_PreviousTouchPos; // swipe style control touch #if !UNITY_EDITOR private Vector3 m_Center; private Image m_Image; #else - Vector3 m_PreviousMouse; + Vector3 m_PreviousMouse; #endif - void OnEnable() - { - CreateVirtualAxes(); - } + void OnEnable() + { + CreateVirtualAxes(); + } void Start() { @@ -64,58 +63,58 @@ void Start() #endif } - void CreateVirtualAxes() - { - // set axes to use - m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); - m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); - - // create new axes based on axes to use - if (m_UseX) - { - m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); - CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); - } - if (m_UseY) - { - m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); - CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); - } - } - - void UpdateVirtualAxes(Vector3 value) - { - value = value.normalized; - if (m_UseX) - { - m_HorizontalVirtualAxis.Update(value.x); - } - - if (m_UseY) - { - m_VerticalVirtualAxis.Update(value.y); - } - } - - - public void OnPointerDown(PointerEventData data) - { - m_Dragging = true; - m_Id = data.pointerId; + void CreateVirtualAxes() + { + // set axes to use + m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); + m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); + + // create new axes based on axes to use + if (m_UseX) + { + m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); + } + if (m_UseY) + { + m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); + } + } + + void UpdateVirtualAxes(Vector3 value) + { + value = value.normalized; + if (m_UseX) + { + m_HorizontalVirtualAxis.Update(value.x); + } + + if (m_UseY) + { + m_VerticalVirtualAxis.Update(value.y); + } + } + + + public void OnPointerDown(PointerEventData data) + { + m_Dragging = true; + m_Id = data.pointerId; #if !UNITY_EDITOR if (controlStyle != ControlStyle.Absolute ) m_Center = data.position; #endif - } - - void Update() - { - if (!m_Dragging) - { - return; - } - if (Input.touchCount >= m_Id + 1 && m_Id != -1) - { + } + + void Update() + { + if (!m_Dragging) + { + return; + } + if (Input.touchCount >= m_Id + 1 && m_Id != -1) + { #if !UNITY_EDITOR if (controlStyle == ControlStyle.Swipe) @@ -127,30 +126,30 @@ void Update() pointerDelta.x *= Xsensitivity; pointerDelta.y *= Ysensitivity; #else - Vector2 pointerDelta; - pointerDelta.x = Input.mousePosition.x - m_PreviousMouse.x; - pointerDelta.y = Input.mousePosition.y - m_PreviousMouse.y; - m_PreviousMouse = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f); + Vector2 pointerDelta; + pointerDelta.x = Input.mousePosition.x - m_PreviousMouse.x; + pointerDelta.y = Input.mousePosition.y - m_PreviousMouse.y; + m_PreviousMouse = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f); #endif - UpdateVirtualAxes(new Vector3(pointerDelta.x, pointerDelta.y, 0)); - } - } - - - public void OnPointerUp(PointerEventData data) - { - m_Dragging = false; - m_Id = -1; - UpdateVirtualAxes(Vector3.zero); - } - - void OnDisable() - { - if (CrossPlatformInputManager.AxisExists(horizontalAxisName)) - CrossPlatformInputManager.UnRegisterVirtualAxis(horizontalAxisName); - - if (CrossPlatformInputManager.AxisExists(verticalAxisName)) - CrossPlatformInputManager.UnRegisterVirtualAxis(verticalAxisName); - } - } + UpdateVirtualAxes(new Vector3(pointerDelta.x, pointerDelta.y, 0)); + } + } + + + public void OnPointerUp(PointerEventData data) + { + m_Dragging = false; + m_Id = -1; + UpdateVirtualAxes(Vector3.zero); + } + + void OnDisable() + { + if (CrossPlatformInputManager.AxisExists(horizontalAxisName)) + CrossPlatformInputManager.UnRegisterVirtualAxis(horizontalAxisName); + + if (CrossPlatformInputManager.AxisExists(verticalAxisName)) + CrossPlatformInputManager.UnRegisterVirtualAxis(verticalAxisName); + } + } } \ No newline at end of file diff --git a/Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs b/Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs index 5ffec5a48c249474f27ceb0ba785a5ed63943af7..a432f598613b8a82d59e7eef9c0425fbfadd27cc 100644 --- a/Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs +++ b/Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using UnityEngine; @@ -8,16 +7,16 @@ namespace UnityStandardAssets.CrossPlatformInput public abstract class VirtualInput { public Vector3 virtualMousePosition { get; private set; } - - + + protected Dictionary<string, CrossPlatformInputManager.VirtualAxis> m_VirtualAxes = new Dictionary<string, CrossPlatformInputManager.VirtualAxis>(); - // Dictionary to store the name relating to the virtual axes + // Dictionary to store the name relating to the virtual axes protected Dictionary<string, CrossPlatformInputManager.VirtualButton> m_VirtualButtons = new Dictionary<string, CrossPlatformInputManager.VirtualButton>(); protected List<string> m_AlwaysUseVirtual = new List<string>(); - // list of the axis and button names that have been flagged to always use a virtual axis or button - + // list of the axis and button names that have been flagged to always use a virtual axis or button + public bool AxisExists(string name) { @@ -118,7 +117,7 @@ public void SetVirtualMousePositionZ(float f) public abstract float GetAxis(string name, bool raw); - + public abstract bool GetButton(string name); public abstract bool GetButtonDown(string name); public abstract bool GetButtonUp(string name); diff --git a/Assets/Standard Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs b/Assets/Standard Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs index a830a67a7f4c2cccfb02d3aa46edb2d46414576a..721d16c3f2b5718045c9910bf43ca5a7d4d2db10 100644 --- a/Assets/Standard Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs +++ b/Assets/Standard Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using UnityEditor; @@ -32,9 +31,9 @@ private static void Enable() { case BuildTarget.Android: case BuildTarget.iOS: - case BuildTarget.PSM: - case BuildTarget.Tizen: - case BuildTarget.WSAPlayer: + case BuildTarget.PSM: + case BuildTarget.Tizen: + case BuildTarget.WSAPlayer: EditorUtility.DisplayDialog("Mobile Input", "You have enabled Mobile Input. You'll need to use the Unity Remote app on a connected device to control your game in the Editor.", "OK"); @@ -92,9 +91,9 @@ private static bool DisableValidate() { BuildTargetGroup.Android, BuildTargetGroup.iOS, - BuildTargetGroup.PSM, + BuildTargetGroup.PSM, BuildTargetGroup.Tizen, - BuildTargetGroup.WSA + BuildTargetGroup.WSA }; diff --git a/Assets/Standard Assets/Editor/Water/Water4/GerstnerDisplaceEditor.cs b/Assets/Standard Assets/Editor/Water/Water4/GerstnerDisplaceEditor.cs index 50b0bd2c2e792e7e63920e2558095f7daca4fac8..63b96f5620475726a298ea68fe80130e217ae315 100644 --- a/Assets/Standard Assets/Editor/Water/Water4/GerstnerDisplaceEditor.cs +++ b/Assets/Standard Assets/Editor/Water/Water4/GerstnerDisplaceEditor.cs @@ -1,6 +1,5 @@ -using UnityEngine; -using System; using UnityEditor; +using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Editor/Water/Water4/PlanarReflectionEditor.cs b/Assets/Standard Assets/Editor/Water/Water4/PlanarReflectionEditor.cs index e7e3720da92269e161b11ab84ec6ec7be80f9157..316dfd04df8b1f540595e8c53188c6b10c39c946 100644 --- a/Assets/Standard Assets/Editor/Water/Water4/PlanarReflectionEditor.cs +++ b/Assets/Standard Assets/Editor/Water/Water4/PlanarReflectionEditor.cs @@ -1,5 +1,5 @@ -using UnityEngine; using UnityEditor; +using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Editor/Water/Water4/SpecularLightingEditor.cs b/Assets/Standard Assets/Editor/Water/Water4/SpecularLightingEditor.cs index 5a69b03ffa18c146a7ad8ed00a79919421527b71..07c12f7a04530247ce7d55c8367a066589edb411 100644 --- a/Assets/Standard Assets/Editor/Water/Water4/SpecularLightingEditor.cs +++ b/Assets/Standard Assets/Editor/Water/Water4/SpecularLightingEditor.cs @@ -1,5 +1,5 @@ -using UnityEngine; using UnityEditor; +using UnityEngine; namespace UnityStandardAssets.Water { diff --git a/Assets/Standard Assets/Editor/Water/Water4/WaterBaseEditor.cs b/Assets/Standard Assets/Editor/Water/Water4/WaterBaseEditor.cs index bdda0c9f578d4c834d7b2baf19cad6ff8d22d1ea..c483d9e0ec4ac5541319c2507febc76c25d3469f 100644 --- a/Assets/Standard Assets/Editor/Water/Water4/WaterBaseEditor.cs +++ b/Assets/Standard Assets/Editor/Water/Water4/WaterBaseEditor.cs @@ -1,5 +1,5 @@ -using UnityEngine; using UnityEditor; +using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Editor/Water/Water4/WaterEditorUtility.cs b/Assets/Standard Assets/Editor/Water/Water4/WaterEditorUtility.cs index eff3267ab6d79df09d4764efbe1d2464bb6bca3a..fdd1846e9aa893569549aa0667001d0c819ec270 100644 --- a/Assets/Standard Assets/Editor/Water/Water4/WaterEditorUtility.cs +++ b/Assets/Standard Assets/Editor/Water/Water4/WaterEditorUtility.cs @@ -1,59 +1,67 @@ -using UnityEngine; using UnityEditor; +using UnityEngine; class WaterEditorUtility { - // helper functions to retrieve & set material values + // helper functions to retrieve & set material values - public static float GetMaterialFloat(System.String name, Material mat) { - return mat.GetFloat(name); - } - public static void SetMaterialFloat(System.String name, float f, Material mat) { - mat.SetFloat(name, f); - } + public static float GetMaterialFloat(System.String name, Material mat) + { + return mat.GetFloat(name); + } + public static void SetMaterialFloat(System.String name, float f, Material mat) + { + mat.SetFloat(name, f); + } - public static Color GetMaterialColor(System.String name, Material mat) { - return mat.GetColor(name); - } - public static void SetMaterialColor(System.String name, Color color, Material mat) { - mat.SetColor(name, color); - } - public static Vector4 GetMaterialVector(System.String name, Material mat) { - return mat.GetVector(name); - } - public static void SetMaterialVector(System.String name, Vector4 vector, Material mat) { - mat.SetVector(name, vector); - } - public static Texture GetMaterialTexture(System.String theName, Material mat) { - return mat.GetTexture(theName); - } - public static void SetMaterialTexture(System.String theName, Texture parameter, Material mat) { - mat.SetTexture(theName, parameter); - } - - public static Material LocateValidWaterMaterial(Transform parent) - { - if(parent.GetComponent<Renderer>() && parent.GetComponent<Renderer>().sharedMaterial) - return parent.GetComponent<Renderer>().sharedMaterial; - foreach( Transform t in parent) - { - if(t.GetComponent<Renderer>() && t.GetComponent<Renderer>().sharedMaterial) - return t.GetComponent<Renderer>().sharedMaterial; - } - return null; - } - - public static void CurveGui (System.String name, SerializedObject serObj, Color color) - { - AnimationCurve curve = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f), new Keyframe(1, 1.0f, 1.0f, 1.0f)); - curve = EditorGUILayout.CurveField(new GUIContent (name), curve, color, new Rect (0.0f,0.0f,1.0f,1.0f)); + public static Color GetMaterialColor(System.String name, Material mat) + { + return mat.GetColor(name); + } + public static void SetMaterialColor(System.String name, Color color, Material mat) + { + mat.SetColor(name, color); + } + public static Vector4 GetMaterialVector(System.String name, Material mat) + { + return mat.GetVector(name); + } + public static void SetMaterialVector(System.String name, Vector4 vector, Material mat) + { + mat.SetVector(name, vector); + } + public static Texture GetMaterialTexture(System.String theName, Material mat) + { + return mat.GetTexture(theName); + } + public static void SetMaterialTexture(System.String theName, Texture parameter, Material mat) + { + mat.SetTexture(theName, parameter); + } + + public static Material LocateValidWaterMaterial(Transform parent) + { + if (parent.GetComponent<Renderer>() && parent.GetComponent<Renderer>().sharedMaterial) + return parent.GetComponent<Renderer>().sharedMaterial; + foreach (Transform t in parent) + { + if (t.GetComponent<Renderer>() && t.GetComponent<Renderer>().sharedMaterial) + return t.GetComponent<Renderer>().sharedMaterial; + } + return null; + } + + public static void CurveGui(System.String name, SerializedObject serObj, Color color) + { + AnimationCurve curve = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f), new Keyframe(1, 1.0f, 1.0f, 1.0f)); + curve = EditorGUILayout.CurveField(new GUIContent(name), curve, color, new Rect(0.0f, 0.0f, 1.0f, 1.0f)); - //if (GUI.changed) { - // AnimationCurveChanged(((WaterBase)serObj.targetObject).sharedMaterial, curve); - //((WaterBase)serObj.targetObject).gameObject.SendMessage ("AnimationCurveChanged", SendMessageOptions.DontRequireReceiver); - //} - } - /* + //if (GUI.changed) { + // AnimationCurveChanged(((WaterBase)serObj.targetObject).sharedMaterial, curve); + //((WaterBase)serObj.targetObject).gameObject.SendMessage ("AnimationCurveChanged", SendMessageOptions.DontRequireReceiver); + //} + } + /* public static void AnimationCurveChanged(Material sharedMaterial, AnimationCurve fresnelCurve) { Debug.Log("AnimationCurveChanged"); diff --git a/Assets/Standard Assets/Environment/Water (Basic)/Scripts/WaterBasic.cs b/Assets/Standard Assets/Environment/Water (Basic)/Scripts/WaterBasic.cs index b1eb861a57cd67b66102c316bbb8eabecf96c028..6c8f6e8cdfc6f274216f8ed7e9a8a4f3e32ebd39 100644 --- a/Assets/Standard Assets/Environment/Water (Basic)/Scripts/WaterBasic.cs +++ b/Assets/Standard Assets/Environment/Water (Basic)/Scripts/WaterBasic.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/Displace.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/Displace.cs index 24e06cdb9a6827c3276f35c1730963859bb32b73..43aa2fe3b24d58b16b91f1de6f866f33b6010b90 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/Displace.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/Displace.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/GerstnerDisplace.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/GerstnerDisplace.cs index b64fb63589e55510e731d5edb6e835762a4d0c8e..b07eb5c4f82d554936bfcc6db105d6ae072e5e92 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/GerstnerDisplace.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/GerstnerDisplace.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/MeshContainer.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/MeshContainer.cs index d584fc2019befeaa5cc211d7d84a0a3231d72e12..bd70aa7ab9475618e6a10eca56ed9f02a78ec931 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/MeshContainer.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/MeshContainer.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/PlanarReflection.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/PlanarReflection.cs index f470cab2763cbb69336020fcdb151149e0b366f9..e2159f62f39904b67b6d9508b8a17c188c3403a3 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/PlanarReflection.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/PlanarReflection.cs @@ -234,19 +234,19 @@ static Matrix4x4 CalculateObliqueMatrix(Matrix4x4 projection, Vector4 clipPlane) static Matrix4x4 CalculateReflectionMatrix(Matrix4x4 reflectionMat, Vector4 plane) { reflectionMat.m00 = (1.0F - 2.0F * plane[0] * plane[0]); - reflectionMat.m01 = (- 2.0F * plane[0] * plane[1]); - reflectionMat.m02 = (- 2.0F * plane[0] * plane[2]); - reflectionMat.m03 = (- 2.0F * plane[3] * plane[0]); + reflectionMat.m01 = (-2.0F * plane[0] * plane[1]); + reflectionMat.m02 = (-2.0F * plane[0] * plane[2]); + reflectionMat.m03 = (-2.0F * plane[3] * plane[0]); - reflectionMat.m10 = (- 2.0F * plane[1] * plane[0]); + reflectionMat.m10 = (-2.0F * plane[1] * plane[0]); reflectionMat.m11 = (1.0F - 2.0F * plane[1] * plane[1]); - reflectionMat.m12 = (- 2.0F * plane[1] * plane[2]); - reflectionMat.m13 = (- 2.0F * plane[3] * plane[1]); + reflectionMat.m12 = (-2.0F * plane[1] * plane[2]); + reflectionMat.m13 = (-2.0F * plane[3] * plane[1]); - reflectionMat.m20 = (- 2.0F * plane[2] * plane[0]); - reflectionMat.m21 = (- 2.0F * plane[2] * plane[1]); + reflectionMat.m20 = (-2.0F * plane[2] * plane[0]); + reflectionMat.m21 = (-2.0F * plane[2] * plane[1]); reflectionMat.m22 = (1.0F - 2.0F * plane[2] * plane[2]); - reflectionMat.m23 = (- 2.0F * plane[3] * plane[2]); + reflectionMat.m23 = (-2.0F * plane[3] * plane[2]); reflectionMat.m30 = 0.0F; reflectionMat.m31 = 0.0F; diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/SpecularLighting.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/SpecularLighting.cs index 4bcfb0c0c0a237286104720b34c230d4178f35a1..141aeed523a50d980a8945a091899950bbb60ba7 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/SpecularLighting.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/SpecularLighting.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/Water.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/Water.cs index 98ebe168423eef42cd074c3e5f39799875223986..4592a3d72269caac047adde0c3502063d7bbc956 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/Water.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/Water.cs @@ -99,10 +99,10 @@ public void OnWillRenderObject() Vector4 clipPlane = CameraSpacePlane(reflectionCamera, pos, normal, 1.0f); reflectionCamera.projectionMatrix = cam.CalculateObliqueMatrix(clipPlane); - // Set custom culling matrix from the current camera - reflectionCamera.cullingMatrix = cam.projectionMatrix * cam.worldToCameraMatrix; + // Set custom culling matrix from the current camera + reflectionCamera.cullingMatrix = cam.projectionMatrix * cam.worldToCameraMatrix; - reflectionCamera.cullingMask = ~(1 << 4) & reflectLayers.value; // never render water layer + reflectionCamera.cullingMask = ~(1 << 4) & reflectLayers.value; // never render water layer reflectionCamera.targetTexture = m_ReflectionTexture; bool oldCulling = GL.invertCulling; GL.invertCulling = !oldCulling; @@ -125,10 +125,10 @@ public void OnWillRenderObject() Vector4 clipPlane = CameraSpacePlane(refractionCamera, pos, normal, -1.0f); refractionCamera.projectionMatrix = cam.CalculateObliqueMatrix(clipPlane); - // Set custom culling matrix from the current camera - refractionCamera.cullingMatrix = cam.projectionMatrix * cam.worldToCameraMatrix; + // Set custom culling matrix from the current camera + refractionCamera.cullingMatrix = cam.projectionMatrix * cam.worldToCameraMatrix; - refractionCamera.cullingMask = ~(1 << 4) & refractLayers.value; // never render water layer + refractionCamera.cullingMask = ~(1 << 4) & refractLayers.value; // never render water layer refractionCamera.targetTexture = m_RefractionTexture; refractionCamera.transform.position = cam.transform.position; refractionCamera.transform.rotation = cam.transform.rotation; @@ -380,19 +380,19 @@ Vector4 CameraSpacePlane(Camera cam, Vector3 pos, Vector3 normal, float sideSign static void CalculateReflectionMatrix(ref Matrix4x4 reflectionMat, Vector4 plane) { reflectionMat.m00 = (1F - 2F * plane[0] * plane[0]); - reflectionMat.m01 = (- 2F * plane[0] * plane[1]); - reflectionMat.m02 = (- 2F * plane[0] * plane[2]); - reflectionMat.m03 = (- 2F * plane[3] * plane[0]); + reflectionMat.m01 = (-2F * plane[0] * plane[1]); + reflectionMat.m02 = (-2F * plane[0] * plane[2]); + reflectionMat.m03 = (-2F * plane[3] * plane[0]); - reflectionMat.m10 = (- 2F * plane[1] * plane[0]); + reflectionMat.m10 = (-2F * plane[1] * plane[0]); reflectionMat.m11 = (1F - 2F * plane[1] * plane[1]); - reflectionMat.m12 = (- 2F * plane[1] * plane[2]); - reflectionMat.m13 = (- 2F * plane[3] * plane[1]); + reflectionMat.m12 = (-2F * plane[1] * plane[2]); + reflectionMat.m13 = (-2F * plane[3] * plane[1]); - reflectionMat.m20 = (- 2F * plane[2] * plane[0]); - reflectionMat.m21 = (- 2F * plane[2] * plane[1]); + reflectionMat.m20 = (-2F * plane[2] * plane[0]); + reflectionMat.m21 = (-2F * plane[2] * plane[1]); reflectionMat.m22 = (1F - 2F * plane[2] * plane[2]); - reflectionMat.m23 = (- 2F * plane[3] * plane[2]); + reflectionMat.m23 = (-2F * plane[3] * plane[2]); reflectionMat.m30 = 0F; reflectionMat.m31 = 0F; diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterBase.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterBase.cs index bc5afcfcac58eb0fd9644a65f40996a84ead23a7..7b48ca99b1c72dbc4bc1f6b5fb65fadadf7ae1b0 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterBase.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterBase.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterTile.cs b/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterTile.cs index 65a61244b3ab405403e2f0ed5bfdbb3ec716cd1d..9a05b35316402c0a278a4e382a50af8b10c87b12 100644 --- a/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterTile.cs +++ b/Assets/Standard Assets/Environment/Water/Water/Scripts/WaterTile.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Water diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/AfterburnerPhysicsForce.cs b/Assets/Standard Assets/ParticleSystems/Scripts/AfterburnerPhysicsForce.cs index 0fa5cb9bd0ce1fef68687038ae5f3f5b35c63a9e..4902ad15c7b1816f05cd4c9adf7a283649d76822 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/AfterburnerPhysicsForce.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/AfterburnerPhysicsForce.cs @@ -1,9 +1,8 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Effects { - [RequireComponent(typeof (SphereCollider))] + [RequireComponent(typeof(SphereCollider))] public class AfterburnerPhysicsForce : MonoBehaviour { public float effectAngle = 15; @@ -29,12 +28,12 @@ private void FixedUpdate() if (m_Cols[n].attachedRigidbody != null) { Vector3 localPos = transform.InverseTransformPoint(m_Cols[n].transform.position); - localPos = Vector3.MoveTowards(localPos, new Vector3(0, 0, localPos.z), effectWidth*0.5f); - float angle = Mathf.Abs(Mathf.Atan2(localPos.x, localPos.z)*Mathf.Rad2Deg); + localPos = Vector3.MoveTowards(localPos, new Vector3(0, 0, localPos.z), effectWidth * 0.5f); + float angle = Mathf.Abs(Mathf.Atan2(localPos.x, localPos.z) * Mathf.Rad2Deg); float falloff = Mathf.InverseLerp(effectDistance, 0, localPos.magnitude); falloff *= Mathf.InverseLerp(effectAngle, 0, angle); Vector3 delta = m_Cols[n].transform.position - transform.position; - m_Cols[n].attachedRigidbody.AddForceAtPosition(delta.normalized*force*falloff, + m_Cols[n].attachedRigidbody.AddForceAtPosition(delta.normalized * force * falloff, Vector3.Lerp(m_Cols[n].transform.position, transform.TransformPoint(0, 0, localPos.z), 0.1f)); @@ -46,22 +45,22 @@ private void FixedUpdate() private void OnDrawGizmosSelected() { //check for editor time simulation to avoid null ref - if(m_Sphere == null) + if (m_Sphere == null) m_Sphere = (GetComponent<Collider>() as SphereCollider); - m_Sphere.radius = effectDistance*.5f; - m_Sphere.center = new Vector3(0, 0, effectDistance*.5f); - var directions = new Vector3[] {Vector3.up, -Vector3.up, Vector3.right, -Vector3.right}; - var perpDirections = new Vector3[] {-Vector3.right, Vector3.right, Vector3.up, -Vector3.up}; + m_Sphere.radius = effectDistance * .5f; + m_Sphere.center = new Vector3(0, 0, effectDistance * .5f); + var directions = new Vector3[] { Vector3.up, -Vector3.up, Vector3.right, -Vector3.right }; + var perpDirections = new Vector3[] { -Vector3.right, Vector3.right, Vector3.up, -Vector3.up }; Gizmos.color = new Color(0, 1, 0, 0.5f); for (int n = 0; n < 4; ++n) { - Vector3 origin = transform.position + transform.rotation*directions[n]*effectWidth*0.5f; + Vector3 origin = transform.position + transform.rotation * directions[n] * effectWidth * 0.5f; Vector3 direction = - transform.TransformDirection(Quaternion.AngleAxis(effectAngle, perpDirections[n])*Vector3.forward); + transform.TransformDirection(Quaternion.AngleAxis(effectAngle, perpDirections[n]) * Vector3.forward); - Gizmos.DrawLine(origin, origin + direction*m_Sphere.radius*2); + Gizmos.DrawLine(origin, origin + direction * m_Sphere.radius * 2); } } } diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionFireAndDebris.cs b/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionFireAndDebris.cs index 6bae19725594756d5a1e77ec8d624a4daabb97a6..0a65beccf0fcd0320a58d967b2d23dec226a6bcb 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionFireAndDebris.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionFireAndDebris.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using UnityEngine; using Random = UnityEngine.Random; @@ -17,10 +16,10 @@ private IEnumerator Start() { float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier; - for (int n = 0; n < numDebrisPieces*multiplier; ++n) + for (int n = 0; n < numDebrisPieces * multiplier; ++n) { var prefab = debrisPrefabs[Random.Range(0, debrisPrefabs.Length)]; - Vector3 pos = transform.position + Random.insideUnitSphere*3*multiplier; + Vector3 pos = transform.position + Random.insideUnitSphere * 3 * multiplier; Quaternion rot = Random.rotation; Instantiate(prefab, pos, rot); } @@ -28,7 +27,7 @@ private IEnumerator Start() // wait one frame so these new objects can be picked up in the overlapsphere function yield return null; - float r = 10*multiplier; + float r = 10 * multiplier; var cols = Physics.OverlapSphere(transform.position, r); foreach (var col in cols) { @@ -54,15 +53,15 @@ private IEnumerator Start() AddFire(null, fireHit.point, fireHit.normal); numFires--; } - testR += r*.1f; + testR += r * .1f; } } private void AddFire(Transform t, Vector3 pos, Vector3 normal) { - pos += normal*0.5f; - Transform fire = (Transform) Instantiate(firePrefab, pos, Quaternion.identity); + pos += normal * 0.5f; + Transform fire = (Transform)Instantiate(firePrefab, pos, Quaternion.identity); fire.parent = t; } } diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionPhysicsForce.cs b/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionPhysicsForce.cs index f7760f4f088923a3033103b2128de9c0e5e39602..73e8b796daab0bdbf33783ee451f2189f61ed3dc 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionPhysicsForce.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/ExplosionPhysicsForce.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -18,7 +17,7 @@ private IEnumerator Start() float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier; - float r = 10*multiplier; + float r = 10 * multiplier; var cols = Physics.OverlapSphere(transform.position, r); var rigidbodies = new List<Rigidbody>(); foreach (var col in cols) @@ -30,7 +29,7 @@ private IEnumerator Start() } foreach (var rb in rigidbodies) { - rb.AddExplosionForce(explosionForce*multiplier, transform.position, r, 1*multiplier, ForceMode.Impulse); + rb.AddExplosionForce(explosionForce * multiplier, transform.position, r, 1 * multiplier, ForceMode.Impulse); } } } diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs b/Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs index 23ec5a686182646c7df2757cc62843ff3a5fd9e3..488d3614733769b49d76fd69907e6697c9c92ccd 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/Explosive.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using UnityEngine; using UnityStandardAssets.Utility; diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/ExtinguishableParticleSystem.cs b/Assets/Standard Assets/ParticleSystems/Scripts/ExtinguishableParticleSystem.cs index 6e84e93820bb4f0071778bf5c5234128a8706790..28274db5e926df15f3ff0913454f5ba9cd963e16 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/ExtinguishableParticleSystem.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/ExtinguishableParticleSystem.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs b/Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs index 550b68c162ef04a56c35880210d0d19435999897..8a11d9fd670ce292665456866366728154367e5f 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/FireLight.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using Random = UnityEngine.Random; @@ -13,7 +12,7 @@ public class FireLight : MonoBehaviour private void Start() { - m_Rnd = Random.value*100; + m_Rnd = Random.value * 100; m_Light = GetComponent<Light>(); } @@ -22,11 +21,11 @@ private void Update() { if (m_Burning) { - m_Light.intensity = 2*Mathf.PerlinNoise(m_Rnd + Time.time, m_Rnd + 1 + Time.time*1); - float x = Mathf.PerlinNoise(m_Rnd + 0 + Time.time*2, m_Rnd + 1 + Time.time*2) - 0.5f; - float y = Mathf.PerlinNoise(m_Rnd + 2 + Time.time*2, m_Rnd + 3 + Time.time*2) - 0.5f; - float z = Mathf.PerlinNoise(m_Rnd + 4 + Time.time*2, m_Rnd + 5 + Time.time*2) - 0.5f; - transform.localPosition = Vector3.up + new Vector3(x, y, z)*1; + m_Light.intensity = 2 * Mathf.PerlinNoise(m_Rnd + Time.time, m_Rnd + 1 + Time.time * 1); + float x = Mathf.PerlinNoise(m_Rnd + 0 + Time.time * 2, m_Rnd + 1 + Time.time * 2) - 0.5f; + float y = Mathf.PerlinNoise(m_Rnd + 2 + Time.time * 2, m_Rnd + 3 + Time.time * 2) - 0.5f; + float z = Mathf.PerlinNoise(m_Rnd + 4 + Time.time * 2, m_Rnd + 5 + Time.time * 2) - 0.5f; + transform.localPosition = Vector3.up + new Vector3(x, y, z) * 1; } } diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs b/Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs index 3d17324b52e427904090d4fdcfdf5eb79b6d5e64..b3148d5f5db20257a245ecbcacc62a4ac122408a 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/Hose.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; @@ -18,7 +17,7 @@ public class Hose : MonoBehaviour // Update is called once per frame private void Update() { - m_Power = Mathf.Lerp(m_Power, Input.GetMouseButton(0) ? maxPower : minPower, Time.deltaTime*changeSpeed); + m_Power = Mathf.Lerp(m_Power, Input.GetMouseButton(0) ? maxPower : minPower, Time.deltaTime * changeSpeed); if (Input.GetKeyDown(KeyCode.Alpha1)) { @@ -27,10 +26,10 @@ private void Update() foreach (var system in hoseWaterSystems) { - ParticleSystem.MainModule mainModule = system.main; + ParticleSystem.MainModule mainModule = system.main; mainModule.startSpeed = m_Power; var emission = system.emission; - emission.enabled = (m_Power > minPower*1.1f); + emission.enabled = (m_Power > minPower * 1.1f); } } } diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/ParticleSystemMultiplier.cs b/Assets/Standard Assets/ParticleSystems/Scripts/ParticleSystemMultiplier.cs index c77eceea6fff078e4d0264816f33034a63eb2804..fb6624a85046b28834e1f0401a3894b5183fa8a1 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/ParticleSystemMultiplier.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/ParticleSystemMultiplier.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Effects @@ -15,8 +14,8 @@ private void Start() var systems = GetComponentsInChildren<ParticleSystem>(); foreach (ParticleSystem system in systems) { - ParticleSystem.MainModule mainModule = system.main; - mainModule.startSizeMultiplier *= multiplier; + ParticleSystem.MainModule mainModule = system.main; + mainModule.startSizeMultiplier *= multiplier; mainModule.startSpeedMultiplier *= multiplier; mainModule.startLifetimeMultiplier *= Mathf.Lerp(multiplier, 1, 0.5f); system.Clear(); diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/SmokeParticles.cs b/Assets/Standard Assets/ParticleSystems/Scripts/SmokeParticles.cs index 0d4e15664f1ef6e2ded8708082b944665433863c..2c08a48ffb1fa942242e2a9bfc648db2b2b084c2 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/SmokeParticles.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/SmokeParticles.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using Random = UnityEngine.Random; diff --git a/Assets/Standard Assets/ParticleSystems/Scripts/WaterHoseParticles.cs b/Assets/Standard Assets/ParticleSystems/Scripts/WaterHoseParticles.cs index 92c75169c6644ca3927b4cc5028e4ed917a1f79d..215db622782de1fa0c8e48c2551244a68d9a915d 100644 --- a/Assets/Standard Assets/ParticleSystems/Scripts/WaterHoseParticles.cs +++ b/Assets/Standard Assets/ParticleSystems/Scripts/WaterHoseParticles.cs @@ -1,6 +1,5 @@ -using System; -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace UnityStandardAssets.Effects { @@ -37,7 +36,7 @@ private void OnParticleCollision(GameObject other) if (attachedRigidbody != null) { Vector3 vel = m_CollisionEvents[i].velocity; - attachedRigidbody.AddForce(vel*force, ForceMode.Impulse); + attachedRigidbody.AddForce(vel * force, ForceMode.Impulse); } other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver); diff --git a/Assets/Standard Assets/Utility/ActivateTrigger.cs b/Assets/Standard Assets/Utility/ActivateTrigger.cs index 16875335ea7dde2e4889370883c55d1ec6415d40..c83f5404de679fdd137f384104319fbed8ecc834 100644 --- a/Assets/Standard Assets/Utility/ActivateTrigger.cs +++ b/Assets/Standard Assets/Utility/ActivateTrigger.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using Object = UnityEngine.Object; diff --git a/Assets/Standard Assets/Utility/AlphaButtonClickMask.cs b/Assets/Standard Assets/Utility/AlphaButtonClickMask.cs index fb9fc00c4d3db73df7e7283b32ec4b9b20da1181..0e0fb1d911f4e0e4dc1749ad48d7ffda41db4df9 100644 --- a/Assets/Standard Assets/Utility/AlphaButtonClickMask.cs +++ b/Assets/Standard Assets/Utility/AlphaButtonClickMask.cs @@ -1,8 +1,7 @@ using UnityEngine; using UnityEngine.UI; -using System.Collections; -public class AlphaButtonClickMask : MonoBehaviour, ICanvasRaycastFilter +public class AlphaButtonClickMask : MonoBehaviour, ICanvasRaycastFilter { protected Image _image; @@ -41,11 +40,11 @@ public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) Vector2 localPoint; RectTransformUtility.ScreenPointToLocalPointInRectangle(_image.rectTransform, sp, eventCamera, out localPoint); - Vector2 pivot = _image.rectTransform.pivot; - Vector2 normalizedLocal = new Vector2(pivot.x + localPoint.x / _image.rectTransform.rect.width, pivot.y + localPoint.y / _image.rectTransform.rect.height); + Vector2 pivot = _image.rectTransform.pivot; + Vector2 normalizedLocal = new Vector2(pivot.x + localPoint.x / _image.rectTransform.rect.width, pivot.y + localPoint.y / _image.rectTransform.rect.height); Vector2 uv = new Vector2( - _image.sprite.rect.x + normalizedLocal.x * _image.sprite.rect.width, - _image.sprite.rect.y + normalizedLocal.y * _image.sprite.rect.height ); + _image.sprite.rect.x + normalizedLocal.x * _image.sprite.rect.width, + _image.sprite.rect.y + normalizedLocal.y * _image.sprite.rect.height); uv.x /= _image.sprite.texture.width; uv.y /= _image.sprite.texture.height; @@ -53,6 +52,6 @@ public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) //uv are inversed, as 0,0 or the rect transform seem to be upper right, then going negativ toward lower left... Color c = _image.sprite.texture.GetPixelBilinear(uv.x, uv.y); - return c.a> 0.1f; + return c.a > 0.1f; } } diff --git a/Assets/Standard Assets/Utility/AutoMobileShaderSwitch.cs b/Assets/Standard Assets/Utility/AutoMobileShaderSwitch.cs index e101b8ca0da77a952a35296eef53b535f6dd1e2a..e430a2d455510cee4ef301713157d624957ac468 100644 --- a/Assets/Standard Assets/Utility/AutoMobileShaderSwitch.cs +++ b/Assets/Standard Assets/Utility/AutoMobileShaderSwitch.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using UnityEngine; #if UNITY_EDITOR using UnityEditor; @@ -84,7 +83,7 @@ public class ReplacementList namespace UnityStandardAssets.Utility.Inspector { #if UNITY_EDITOR - [CustomPropertyDrawer(typeof (AutoMobileShaderSwitch.ReplacementList))] + [CustomPropertyDrawer(typeof(AutoMobileShaderSwitch.ReplacementList))] public class ReplacementListDrawer : PropertyDrawer { const float k_LineHeight = 18; @@ -103,9 +102,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.indentLevel = 0; var items = property.FindPropertyRelative("items"); - var titles = new string[] {"Original", "Replacement", ""}; - var props = new string[] {"original", "replacement", "-"}; - var widths = new float[] {.45f, .45f, .1f}; + var titles = new string[] { "Original", "Replacement", "" }; + var props = new string[] { "original", "replacement", "-" }; + var widths = new float[] { .45f, .45f, .1f }; const float lineHeight = 18; bool changedLength = false; if (items.arraySize > 0) @@ -117,7 +116,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten float rowX = x; for (int n = 0; n < props.Length; ++n) { - float w = widths[n]*inspectorWidth; + float w = widths[n] * inspectorWidth; // Calculate rects Rect rect = new Rect(rowX, y, w, lineHeight); @@ -173,8 +172,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } // add button - var addButtonRect = new Rect((x + position.width) - widths[widths.Length - 1]*inspectorWidth, y, - widths[widths.Length - 1]*inspectorWidth, lineHeight); + var addButtonRect = new Rect((x + position.width) - widths[widths.Length - 1] * inspectorWidth, y, + widths[widths.Length - 1] * inspectorWidth, lineHeight); if (GUI.Button(addButtonRect, "+")) { items.InsertArrayElementAtIndex(items.arraySize); @@ -192,7 +191,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent { SerializedProperty items = property.FindPropertyRelative("items"); float lineAndSpace = k_LineHeight + k_Spacing; - return 40 + (items.arraySize*lineAndSpace) + lineAndSpace; + return 40 + (items.arraySize * lineAndSpace) + lineAndSpace; } } #endif diff --git a/Assets/Standard Assets/Utility/AutoMoveAndRotate.cs b/Assets/Standard Assets/Utility/AutoMoveAndRotate.cs index edbce0e39407f063ea000dbfdb0c7a6a3d7f2567..ae4817304f2674daa9fae87376ffd5b4a8968404 100644 --- a/Assets/Standard Assets/Utility/AutoMoveAndRotate.cs +++ b/Assets/Standard Assets/Utility/AutoMoveAndRotate.cs @@ -26,8 +26,8 @@ private void Update() deltaTime = (Time.realtimeSinceStartup - m_LastRealTime); m_LastRealTime = Time.realtimeSinceStartup; } - transform.Translate(moveUnitsPerSecond.value*deltaTime, moveUnitsPerSecond.space); - transform.Rotate(rotateDegreesPerSecond.value*deltaTime, moveUnitsPerSecond.space); + transform.Translate(moveUnitsPerSecond.value * deltaTime, moveUnitsPerSecond.space); + transform.Rotate(rotateDegreesPerSecond.value * deltaTime, moveUnitsPerSecond.space); } diff --git a/Assets/Standard Assets/Utility/CameraRefocus.cs b/Assets/Standard Assets/Utility/CameraRefocus.cs index 26f1c9be3298b4e3aafa9ff2a2f7af6a71520fac..f9753f8cc76cb6f5b995e775d121a1695e4e3edd 100644 --- a/Assets/Standard Assets/Utility/CameraRefocus.cs +++ b/Assets/Standard Assets/Utility/CameraRefocus.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Utility diff --git a/Assets/Standard Assets/Utility/CurveControlledBob.cs b/Assets/Standard Assets/Utility/CurveControlledBob.cs index b3951b72ceb9510007c54096267d254b1dbcee11..5b628301ab26b593e90fd3652df33c18558d8a2a 100644 --- a/Assets/Standard Assets/Utility/CurveControlledBob.cs +++ b/Assets/Standard Assets/Utility/CurveControlledBob.cs @@ -33,11 +33,11 @@ public void Setup(Camera camera, float bobBaseInterval) public Vector3 DoHeadBob(float speed) { - float xPos = m_OriginalCameraPosition.x + (Bobcurve.Evaluate(m_CyclePositionX)*HorizontalBobRange); - float yPos = m_OriginalCameraPosition.y + (Bobcurve.Evaluate(m_CyclePositionY)*VerticalBobRange); + float xPos = m_OriginalCameraPosition.x + (Bobcurve.Evaluate(m_CyclePositionX) * HorizontalBobRange); + float yPos = m_OriginalCameraPosition.y + (Bobcurve.Evaluate(m_CyclePositionY) * VerticalBobRange); - m_CyclePositionX += (speed*Time.deltaTime)/m_BobBaseInterval; - m_CyclePositionY += ((speed*Time.deltaTime)/m_BobBaseInterval)*VerticaltoHorizontalRatio; + m_CyclePositionX += (speed * Time.deltaTime) / m_BobBaseInterval; + m_CyclePositionY += ((speed * Time.deltaTime) / m_BobBaseInterval) * VerticaltoHorizontalRatio; if (m_CyclePositionX > m_Time) { diff --git a/Assets/Standard Assets/Utility/DragRigidbody.cs b/Assets/Standard Assets/Utility/DragRigidbody.cs index b0f5c35e8f8ddc1c1b8dbd0590201296ab3c4cd5..3d30beefad78f8b3a49dce7f54d7760206dda07f 100644 --- a/Assets/Standard Assets/Utility/DragRigidbody.cs +++ b/Assets/Standard Assets/Utility/DragRigidbody.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using UnityEngine; diff --git a/Assets/Standard Assets/Utility/DynamicShadowSettings.cs b/Assets/Standard Assets/Utility/DynamicShadowSettings.cs index bedb5685b56414d59af8fc89e88ac34768fd448d..e34a1c667d101cf1a375e16de0159fbb67bba3c2 100644 --- a/Assets/Standard Assets/Utility/DynamicShadowSettings.cs +++ b/Assets/Standard Assets/Utility/DynamicShadowSettings.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Utility @@ -44,7 +43,7 @@ private void Update() float i = Mathf.InverseLerp(minHeight, maxHeight, m_SmoothHeight); QualitySettings.shadowDistance = Mathf.Lerp(minShadowDistance, maxShadowDistance, i); - sunLight.shadowBias = Mathf.Lerp(minShadowBias, maxShadowBias, 1 - ((1 - i)*(1 - i))); + sunLight.shadowBias = Mathf.Lerp(minShadowBias, maxShadowBias, 1 - ((1 - i) * (1 - i))); sunLight.shadowStrength = Mathf.Lerp(m_OriginalStrength, 0, i); } } diff --git a/Assets/Standard Assets/Utility/EventSystemChecker.cs b/Assets/Standard Assets/Utility/EventSystemChecker.cs index 0401d319e82893bff1feb87a0d8b68e678f2fab8..a384db6338519060fcba753cb2bfe9fe3dc339ee 100644 --- a/Assets/Standard Assets/Utility/EventSystemChecker.cs +++ b/Assets/Standard Assets/Utility/EventSystemChecker.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections; using UnityEngine; using UnityEngine.EventSystems; @@ -7,15 +5,15 @@ public class EventSystemChecker : MonoBehaviour { //public GameObject eventSystem; - // Use this for initialization - void Awake () - { - if(!FindObjectOfType<EventSystem>()) + // Use this for initialization + void Awake() + { + if (!FindObjectOfType<EventSystem>()) { - //Instantiate(eventSystem); + //Instantiate(eventSystem); GameObject obj = new GameObject("EventSystem"); obj.AddComponent<EventSystem>(); obj.AddComponent<StandaloneInputModule>().forceModuleActive = true; } - } + } } diff --git a/Assets/Standard Assets/Utility/FOVKick.cs b/Assets/Standard Assets/Utility/FOVKick.cs index fbfab585e89a5fabb80e536f69b505fa133b667c..e14d6dfa522a88dc321fac05f2f467038641fde9 100644 --- a/Assets/Standard Assets/Utility/FOVKick.cs +++ b/Assets/Standard Assets/Utility/FOVKick.cs @@ -47,10 +47,10 @@ public void ChangeCamera(Camera camera) public IEnumerator FOVKickUp() { - float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease); + float t = Mathf.Abs((Camera.fieldOfView - originalFov) / FOVIncrease); while (t < TimeToIncrease) { - Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToIncrease)*FOVIncrease); + Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t / TimeToIncrease) * FOVIncrease); t += Time.deltaTime; yield return new WaitForEndOfFrame(); } @@ -59,10 +59,10 @@ public IEnumerator FOVKickUp() public IEnumerator FOVKickDown() { - float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease); + float t = Mathf.Abs((Camera.fieldOfView - originalFov) / FOVIncrease); while (t > 0) { - Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToDecrease)*FOVIncrease); + Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t / TimeToDecrease) * FOVIncrease); t -= Time.deltaTime; yield return new WaitForEndOfFrame(); } diff --git a/Assets/Standard Assets/Utility/FPSCounter.cs b/Assets/Standard Assets/Utility/FPSCounter.cs index 6f9bc54164ca2a3e55f7f3b5553f21b495cd5eec..066a5d05bef4c750c5bc2a82318b8105cda29000 100644 --- a/Assets/Standard Assets/Utility/FPSCounter.cs +++ b/Assets/Standard Assets/Utility/FPSCounter.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using UnityEngine.UI; namespace UnityStandardAssets.Utility { - [RequireComponent(typeof (Text))] + [RequireComponent(typeof(Text))] public class FPSCounter : MonoBehaviour { const float fpsMeasurePeriod = 0.5f; @@ -28,7 +27,7 @@ private void Update() m_FpsAccumulator++; if (Time.realtimeSinceStartup > m_FpsNextPeriod) { - m_CurrentFps = (int) (m_FpsAccumulator/fpsMeasurePeriod); + m_CurrentFps = (int)(m_FpsAccumulator / fpsMeasurePeriod); m_FpsAccumulator = 0; m_FpsNextPeriod += fpsMeasurePeriod; m_Text.text = string.Format(display, m_CurrentFps); diff --git a/Assets/Standard Assets/Utility/FollowTarget.cs b/Assets/Standard Assets/Utility/FollowTarget.cs index e7b91d99ec684a518d64818a41dbd2890fbfc7e8..bd902769ed16ae02c1ac257b62250d580a65fd48 100644 --- a/Assets/Standard Assets/Utility/FollowTarget.cs +++ b/Assets/Standard Assets/Utility/FollowTarget.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; diff --git a/Assets/Standard Assets/Utility/ForcedReset.cs b/Assets/Standard Assets/Utility/ForcedReset.cs index c667ec7020fb02869798c92397315cfe5a19464b..4171ecd2fee87f3c40ac36895842e77f981c5cc4 100644 --- a/Assets/Standard Assets/Utility/ForcedReset.cs +++ b/Assets/Standard Assets/Utility/ForcedReset.cs @@ -1,10 +1,8 @@ -using System; using UnityEngine; -using UnityEngine.UI; using UnityEngine.SceneManagement; using UnityStandardAssets.CrossPlatformInput; -[RequireComponent(typeof (Texture))] +[RequireComponent(typeof(Texture))] public class ForcedReset : MonoBehaviour { private void Update() diff --git a/Assets/Standard Assets/Utility/LerpControlledBob.cs b/Assets/Standard Assets/Utility/LerpControlledBob.cs index 8d6b92cb70a3b990f6083f43c03a256eb5556493..f992e299588436ddc1b116bcbdff8cfaedb54ca1 100644 --- a/Assets/Standard Assets/Utility/LerpControlledBob.cs +++ b/Assets/Standard Assets/Utility/LerpControlledBob.cs @@ -26,7 +26,7 @@ public IEnumerator DoBobCycle() float t = 0f; while (t < BobDuration) { - m_Offset = Mathf.Lerp(0f, BobAmount, t/BobDuration); + m_Offset = Mathf.Lerp(0f, BobAmount, t / BobDuration); t += Time.deltaTime; yield return new WaitForFixedUpdate(); } @@ -35,7 +35,7 @@ public IEnumerator DoBobCycle() t = 0f; while (t < BobDuration) { - m_Offset = Mathf.Lerp(BobAmount, 0f, t/BobDuration); + m_Offset = Mathf.Lerp(BobAmount, 0f, t / BobDuration); t += Time.deltaTime; yield return new WaitForFixedUpdate(); } diff --git a/Assets/Standard Assets/Utility/ObjectResetter.cs b/Assets/Standard Assets/Utility/ObjectResetter.cs index d019fa6a32b24330aba3921684f9fd2ee2dd59a2..1a78e97d474f8d6949aaa274b84fdcc4a1925139 100644 --- a/Assets/Standard Assets/Utility/ObjectResetter.cs +++ b/Assets/Standard Assets/Utility/ObjectResetter.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using System.Collections.Generic; using UnityEngine; diff --git a/Assets/Standard Assets/Utility/ParticleSystemDestroyer.cs b/Assets/Standard Assets/Utility/ParticleSystemDestroyer.cs index 22f66f6b104e2129627f02c369396949f0844c89..5af51e5132c0df0afdd904fef08f4cdc5b30819a 100644 --- a/Assets/Standard Assets/Utility/ParticleSystemDestroyer.cs +++ b/Assets/Standard Assets/Utility/ParticleSystemDestroyer.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using UnityEngine; using Random = UnityEngine.Random; diff --git a/Assets/Standard Assets/Utility/PlatformSpecificContent.cs b/Assets/Standard Assets/Utility/PlatformSpecificContent.cs index 0ac159f71919b089748539c7b3fa794f1a7b2a27..71734bd936b893962c493100390f7a75967d0ffd 100644 --- a/Assets/Standard Assets/Utility/PlatformSpecificContent.cs +++ b/Assets/Standard Assets/Utility/PlatformSpecificContent.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; #if UNITY_EDITOR using UnityEditor; diff --git a/Assets/Standard Assets/Utility/SimpleActivatorMenu.cs b/Assets/Standard Assets/Utility/SimpleActivatorMenu.cs index 593a10243fbef51b6e5557953b1db4f0257e6b24..13a83b53e6e5091a7b7a9398375fc094dff25349 100644 --- a/Assets/Standard Assets/Utility/SimpleActivatorMenu.cs +++ b/Assets/Standard Assets/Utility/SimpleActivatorMenu.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityEngine.UI; diff --git a/Assets/Standard Assets/Utility/SimpleMouseRotator.cs b/Assets/Standard Assets/Utility/SimpleMouseRotator.cs index 5b1ef5ae9009ff1d4e5792a4211b5bbe6b5c1efa..c1d9453c3cdc1e44f2023c53fc5e4f6f7b536f69 100644 --- a/Assets/Standard Assets/Utility/SimpleMouseRotator.cs +++ b/Assets/Standard Assets/Utility/SimpleMouseRotator.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; @@ -21,8 +20,8 @@ public class SimpleMouseRotator : MonoBehaviour public bool autoZeroVerticalOnMobile = true; public bool autoZeroHorizontalOnMobile = false; public bool relative = true; - - + + private Vector3 m_TargetAngles; private Vector3 m_FollowAngles; private Vector3 m_FollowVelocity; @@ -85,13 +84,13 @@ private void Update() } #else // with mouse input, we have direct control with no springback required. - m_TargetAngles.y += inputH*rotationSpeed; - m_TargetAngles.x += inputV*rotationSpeed; + m_TargetAngles.y += inputH * rotationSpeed; + m_TargetAngles.x += inputV * rotationSpeed; #endif // clamp values to allowed range - m_TargetAngles.y = Mathf.Clamp(m_TargetAngles.y, -rotationRange.y*0.5f, rotationRange.y*0.5f); - m_TargetAngles.x = Mathf.Clamp(m_TargetAngles.x, -rotationRange.x*0.5f, rotationRange.x*0.5f); + m_TargetAngles.y = Mathf.Clamp(m_TargetAngles.y, -rotationRange.y * 0.5f, rotationRange.y * 0.5f); + m_TargetAngles.x = Mathf.Clamp(m_TargetAngles.x, -rotationRange.x * 0.5f, rotationRange.x * 0.5f); } else { @@ -99,15 +98,15 @@ private void Update() inputV = Input.mousePosition.y; // set values to allowed range - m_TargetAngles.y = Mathf.Lerp(-rotationRange.y*0.5f, rotationRange.y*0.5f, inputH/Screen.width); - m_TargetAngles.x = Mathf.Lerp(-rotationRange.x*0.5f, rotationRange.x*0.5f, inputV/Screen.height); + m_TargetAngles.y = Mathf.Lerp(-rotationRange.y * 0.5f, rotationRange.y * 0.5f, inputH / Screen.width); + m_TargetAngles.x = Mathf.Lerp(-rotationRange.x * 0.5f, rotationRange.x * 0.5f, inputV / Screen.height); } // smoothly interpolate current values to target angles m_FollowAngles = Vector3.SmoothDamp(m_FollowAngles, m_TargetAngles, ref m_FollowVelocity, dampingTime); // update the actual gameobject's rotation - transform.localRotation = m_OriginalRotation*Quaternion.Euler(-m_FollowAngles.x, m_FollowAngles.y, 0); + transform.localRotation = m_OriginalRotation * Quaternion.Euler(-m_FollowAngles.x, m_FollowAngles.y, 0); } } } diff --git a/Assets/Standard Assets/Utility/SmoothFollow.cs b/Assets/Standard Assets/Utility/SmoothFollow.cs index 01881dc930a6dde5192d08a0e022b127e4251990..68843b58d648a5fd97578e7e26da3a922241924b 100644 --- a/Assets/Standard Assets/Utility/SmoothFollow.cs +++ b/Assets/Standard Assets/Utility/SmoothFollow.cs @@ -2,60 +2,60 @@ namespace UnityStandardAssets.Utility { - public class SmoothFollow : MonoBehaviour - { - - // The target we are following - [SerializeField] - private Transform target; - // The distance in the x-z plane to the target - [SerializeField] - private float distance = 10.0f; - // the height we want the camera to be above the target - [SerializeField] - private float height = 5.0f; - - [SerializeField] - private float rotationDamping; - [SerializeField] - private float heightDamping; - - // Use this for initialization - void Start() { } - - // Update is called once per frame - void LateUpdate() - { - // Early out if we don't have a target - if (!target) - return; - - // Calculate the current rotation angles - var wantedRotationAngle = target.eulerAngles.y; - var wantedHeight = target.position.y + height; - - var currentRotationAngle = transform.eulerAngles.y; - var currentHeight = transform.position.y; - - // Damp the rotation around the y-axis - currentRotationAngle = Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime); - - // Damp the height - currentHeight = Mathf.Lerp(currentHeight, wantedHeight, heightDamping * Time.deltaTime); - - // Convert the angle into a rotation - var currentRotation = Quaternion.Euler(0, currentRotationAngle, 0); - - // Set the position of the camera on the x-z plane to: - // distance meters behind the target - transform.position = target.position; - transform.position -= currentRotation * Vector3.forward * distance; - - // Set the height of the camera - transform.position = new Vector3(transform.position.x ,currentHeight , transform.position.z); - - // Always look at the target - transform.LookAt(target); - } - } + public class SmoothFollow : MonoBehaviour + { + + // The target we are following + [SerializeField] + private Transform target; + // The distance in the x-z plane to the target + [SerializeField] + private float distance = 10.0f; + // the height we want the camera to be above the target + [SerializeField] + private float height = 5.0f; + + [SerializeField] + private float rotationDamping; + [SerializeField] + private float heightDamping; + + // Use this for initialization + void Start() { } + + // Update is called once per frame + void LateUpdate() + { + // Early out if we don't have a target + if (!target) + return; + + // Calculate the current rotation angles + var wantedRotationAngle = target.eulerAngles.y; + var wantedHeight = target.position.y + height; + + var currentRotationAngle = transform.eulerAngles.y; + var currentHeight = transform.position.y; + + // Damp the rotation around the y-axis + currentRotationAngle = Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime); + + // Damp the height + currentHeight = Mathf.Lerp(currentHeight, wantedHeight, heightDamping * Time.deltaTime); + + // Convert the angle into a rotation + var currentRotation = Quaternion.Euler(0, currentRotationAngle, 0); + + // Set the position of the camera on the x-z plane to: + // distance meters behind the target + transform.position = target.position; + transform.position -= currentRotation * Vector3.forward * distance; + + // Set the height of the camera + transform.position = new Vector3(transform.position.x, currentHeight, transform.position.z); + + // Always look at the target + transform.LookAt(target); + } + } } \ No newline at end of file diff --git a/Assets/Standard Assets/Utility/TimedObjectActivator.cs b/Assets/Standard Assets/Utility/TimedObjectActivator.cs index 7c0b13be62178a19fac413af21d3b839be1aa97d..b610bc1c7a6a3626d6234949f9287bae3337bf12 100644 --- a/Assets/Standard Assets/Utility/TimedObjectActivator.cs +++ b/Assets/Standard Assets/Utility/TimedObjectActivator.cs @@ -34,11 +34,11 @@ public class Entries { public Entry[] entries; } - - + + public Entries entries = new Entries(); - + private void Awake() { foreach (Entry entry in entries.entries) @@ -89,7 +89,7 @@ private IEnumerator ReloadLevel(Entry entry) namespace UnityStandardAssets.Utility.Inspector { #if UNITY_EDITOR - [CustomPropertyDrawer(typeof (TimedObjectActivator.Entries))] + [CustomPropertyDrawer(typeof(TimedObjectActivator.Entries))] public class EntriesDrawer : PropertyDrawer { private const float k_LineHeight = 18; @@ -115,10 +115,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten if (entries.arraySize > 0) { - float actionWidth = .25f*width; - float targetWidth = .6f*width; - float delayWidth = .1f*width; - float buttonWidth = .05f*width; + float actionWidth = .25f * width; + float targetWidth = .6f * width; + float delayWidth = .1f * width; + float buttonWidth = .05f * width; for (int i = 0; i < entries.arraySize; ++i) { @@ -144,7 +144,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten // Draw fields - passs GUIContent.none to each so they are drawn without labels if (entry.FindPropertyRelative("action").enumValueIndex != - (int) TimedObjectActivator.Action.ReloadLevel) + (int)TimedObjectActivator.Action.ReloadLevel) { EditorGUI.PropertyField(actionRect, entry.FindPropertyRelative("action"), GUIContent.none); EditorGUI.PropertyField(targetRect, entry.FindPropertyRelative("target"), GUIContent.none); @@ -163,7 +163,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } } } - + // add & sort buttons y += k_LineHeight + k_Spacing; @@ -209,7 +209,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent { SerializedProperty entries = property.FindPropertyRelative("entries"); float lineAndSpace = k_LineHeight + k_Spacing; - return 40 + (entries.arraySize*lineAndSpace) + lineAndSpace; + return 40 + (entries.arraySize * lineAndSpace) + lineAndSpace; } } #endif diff --git a/Assets/Standard Assets/Utility/TimedObjectDestructor.cs b/Assets/Standard Assets/Utility/TimedObjectDestructor.cs index fdf5e078fcc9099fe0b618526fd7739ff8277a05..ff681d6d1bc9cb791e1e3065c903001d4b847063 100644 --- a/Assets/Standard Assets/Utility/TimedObjectDestructor.cs +++ b/Assets/Standard Assets/Utility/TimedObjectDestructor.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Utility diff --git a/Assets/Standard Assets/Utility/WaypointCircuit.cs b/Assets/Standard Assets/Utility/WaypointCircuit.cs index 4f483fa3513c0c53b2d3302c96f911bfbbdbf249..ae1872c9b16422f0562ae3407b3896c9273a1be5 100644 --- a/Assets/Standard Assets/Utility/WaypointCircuit.cs +++ b/Assets/Standard Assets/Utility/WaypointCircuit.cs @@ -75,7 +75,7 @@ public Vector3 GetRoutePosition(float dist) // get nearest two points, ensuring points wrap-around start & end of circuit - p1n = ((point - 1) + numPoints)%numPoints; + p1n = ((point - 1) + numPoints) % numPoints; p2n = point; // found point numbers, now find interpolation value between the two middle points @@ -89,13 +89,13 @@ public Vector3 GetRoutePosition(float dist) // get indices for the surrounding 2 points, because // four points are required by the catmull-rom function - p0n = ((point - 2) + numPoints)%numPoints; - p3n = (point + 1)%numPoints; + p0n = ((point - 2) + numPoints) % numPoints; + p3n = (point + 1) % numPoints; // 2nd point may have been the 'last' point - a dupe of the first, // (to give a value of max track distance instead of zero) // but now it must be wrapped back to zero if that was the case. - p2n = p2n%numPoints; + p2n = p2n % numPoints; P0 = points[p0n]; P1 = points[p1n]; @@ -108,7 +108,7 @@ public Vector3 GetRoutePosition(float dist) { // simple linear lerp between the two points: - p1n = ((point - 1) + numPoints)%numPoints; + p1n = ((point - 1) + numPoints) % numPoints; p2n = point; return Vector3.Lerp(points[p1n], points[p2n], i); @@ -120,9 +120,9 @@ private Vector3 CatmullRom(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float { // comments are no use here... it's the catmull-rom equation. // Un-magic this, lord vector! - return 0.5f* - ((2*p1) + (-p0 + p2)*i + (2*p0 - 5*p1 + 4*p2 - p3)*i*i + - (-p0 + 3*p1 - 3*p2 + p3)*i*i*i); + return 0.5f * + ((2 * p1) + (-p0 + p2) * i + (2 * p0 - 5 * p1 + 4 * p2 - p3) * i * i + + (-p0 + 3 * p1 - 3 * p2 + p3) * i * i * i); } @@ -136,13 +136,13 @@ private void CachePositionsAndDistances() float accumulateDistance = 0; for (int i = 0; i < points.Length; ++i) { - var t1 = Waypoints[(i)%Waypoints.Length]; - var t2 = Waypoints[(i + 1)%Waypoints.Length]; + var t1 = Waypoints[(i) % Waypoints.Length]; + var t2 = Waypoints[(i + 1) % Waypoints.Length]; if (t1 != null && t2 != null) { Vector3 p1 = t1.position; Vector3 p2 = t2.position; - points[i] = Waypoints[i%Waypoints.Length].position; + points[i] = Waypoints[i % Waypoints.Length].position; distances[i] = accumulateDistance; accumulateDistance += (p1 - p2).magnitude; } @@ -176,7 +176,7 @@ private void DrawGizmos(bool selected) Vector3 prev = Waypoints[0].position; if (smoothRoute) { - for (float dist = 0; dist < Length; dist += Length/editorVisualisationSubsteps) + for (float dist = 0; dist < Length; dist += Length / editorVisualisationSubsteps) { Vector3 next = GetRoutePosition(dist + 1); Gizmos.DrawLine(prev, next); @@ -188,7 +188,7 @@ private void DrawGizmos(bool selected) { for (int n = 0; n < Waypoints.Length; ++n) { - Vector3 next = Waypoints[(n + 1)%Waypoints.Length].position; + Vector3 next = Waypoints[(n + 1) % Waypoints.Length].position; Gizmos.DrawLine(prev, next); prev = next; } @@ -222,7 +222,7 @@ public RoutePoint(Vector3 position, Vector3 direction) namespace UnityStandardAssets.Utility.Inspector { #if UNITY_EDITOR - [CustomPropertyDrawer(typeof (WaypointCircuit.WaypointList))] + [CustomPropertyDrawer(typeof(WaypointCircuit.WaypointList))] public class WaypointListDrawer : PropertyDrawer { private float lineHeight = 18; @@ -245,9 +245,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.indentLevel = 0; var items = property.FindPropertyRelative("items"); - var titles = new string[] {"Transform", "", "", ""}; - var props = new string[] {"transform", "^", "v", "-"}; - var widths = new float[] {.7f, .1f, .1f, .1f}; + var titles = new string[] { "Transform", "", "", "" }; + var props = new string[] { "transform", "^", "v", "-" }; + var widths = new float[] { .7f, .1f, .1f, .1f }; float lineHeight = 18; bool changedLength = false; if (items.arraySize > 0) @@ -259,7 +259,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten float rowX = x; for (int n = 0; n < props.Length; ++n) { - float w = widths[n]*inspectorWidth; + float w = widths[n] * inspectorWidth; // Calculate rects Rect rect = new Rect(rowX, y, w, lineHeight); @@ -273,7 +273,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { if (n == 0) { - EditorGUI.ObjectField(rect, item.objectReferenceValue, typeof (Transform), true); + EditorGUI.ObjectField(rect, item.objectReferenceValue, typeof(Transform), true); } else { @@ -314,8 +314,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten else { // add button - var addButtonRect = new Rect((x + position.width) - widths[widths.Length - 1]*inspectorWidth, y, - widths[widths.Length - 1]*inspectorWidth, lineHeight); + var addButtonRect = new Rect((x + position.width) - widths[widths.Length - 1] * inspectorWidth, y, + widths[widths.Length - 1] * inspectorWidth, lineHeight); if (GUI.Button(addButtonRect, "+")) { items.InsertArrayElementAtIndex(items.arraySize); @@ -367,7 +367,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent { SerializedProperty items = property.FindPropertyRelative("items"); float lineAndSpace = lineHeight + spacing; - return 40 + (items.arraySize*lineAndSpace) + lineAndSpace; + return 40 + (items.arraySize * lineAndSpace) + lineAndSpace; } @@ -376,7 +376,7 @@ public class TransformNameComparer : IComparer { public int Compare(object x, object y) { - return ((Transform) x).name.CompareTo(((Transform) y).name); + return ((Transform)x).name.CompareTo(((Transform)y).name); } } } diff --git a/Assets/Standard Assets/Utility/WaypointProgressTracker.cs b/Assets/Standard Assets/Utility/WaypointProgressTracker.cs index 750b779f7ca4fffc53b5d5529ad8db3172e8c407..a1c7d61882891b3590449b66a8fcee7689d6392f 100644 --- a/Assets/Standard Assets/Utility/WaypointProgressTracker.cs +++ b/Assets/Standard Assets/Utility/WaypointProgressTracker.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Utility @@ -89,15 +88,15 @@ private void Update() // we use lerp as a simple way of smoothing out the speed over time. if (Time.deltaTime > 0) { - speed = Mathf.Lerp(speed, (lastPosition - transform.position).magnitude/Time.deltaTime, + speed = Mathf.Lerp(speed, (lastPosition - transform.position).magnitude / Time.deltaTime, Time.deltaTime); } target.position = - circuit.GetRoutePoint(progressDistance + lookAheadForTargetOffset + lookAheadForTargetFactor*speed) + circuit.GetRoutePoint(progressDistance + lookAheadForTargetOffset + lookAheadForTargetFactor * speed) .position; target.rotation = Quaternion.LookRotation( - circuit.GetRoutePoint(progressDistance + lookAheadForSpeedOffset + lookAheadForSpeedFactor*speed) + circuit.GetRoutePoint(progressDistance + lookAheadForSpeedOffset + lookAheadForSpeedFactor * speed) .direction); @@ -106,7 +105,7 @@ private void Update() Vector3 progressDelta = progressPoint.position - transform.position; if (Vector3.Dot(progressDelta, progressPoint.direction) < 0) { - progressDistance += progressDelta.magnitude*0.5f; + progressDistance += progressDelta.magnitude * 0.5f; } lastPosition = transform.position; @@ -118,7 +117,7 @@ private void Update() Vector3 targetDelta = target.position - transform.position; if (targetDelta.magnitude < pointToPointThreshold) { - progressNum = (progressNum + 1)%circuit.Waypoints.Length; + progressNum = (progressNum + 1) % circuit.Waypoints.Length; } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAiControl.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAiControl.cs index 5c41a3f705a943c104322bdad64e1b5893e1ebe8..63099627cde2d0adcdc953e498b56ae65e0e0300 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAiControl.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAiControl.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using Random = UnityEngine.Random; namespace UnityStandardAssets.Vehicles.Aeroplane { - [RequireComponent(typeof (AeroplaneController))] + [RequireComponent(typeof(AeroplaneController))] public class AeroplaneAiControl : MonoBehaviour { // This script represents an AI 'pilot' capable of flying the plane towards a designated target. @@ -49,8 +48,8 @@ private void FixedUpdate() { // make the plane wander from the path, useful for making the AI seem more human, less robotic. Vector3 targetPos = m_Target.position + - transform.right* - (Mathf.PerlinNoise(Time.time*m_LateralWanderSpeed, m_RandomPerlin)*2 - 1)* + transform.right * + (Mathf.PerlinNoise(Time.time * m_LateralWanderSpeed, m_RandomPerlin) * 2 - 1) * m_LateralWanderDistance; // adjust the yaw and pitch towards the target @@ -60,8 +59,8 @@ private void FixedUpdate() // Set the target for the planes pitch, we check later that this has not passed the maximum threshold - targetAnglePitch = Mathf.Clamp(targetAnglePitch, -m_MaxClimbAngle*Mathf.Deg2Rad, - m_MaxClimbAngle*Mathf.Deg2Rad); + targetAnglePitch = Mathf.Clamp(targetAnglePitch, -m_MaxClimbAngle * Mathf.Deg2Rad, + m_MaxClimbAngle * Mathf.Deg2Rad); // calculate the difference between current pitch and desired pitch float changePitch = targetAnglePitch - m_AeroplaneController.PitchAngle; @@ -70,10 +69,10 @@ private void FixedUpdate() const float throttleInput = 0.5f; // AI applies elevator control (pitch, rotation around x) to reach the target angle - float pitchInput = changePitch*m_PitchSensitivity; + float pitchInput = changePitch * m_PitchSensitivity; // clamp the planes roll - float desiredRoll = Mathf.Clamp(targetAngleYaw, -m_MaxRollAngle*Mathf.Deg2Rad, m_MaxRollAngle*Mathf.Deg2Rad); + float desiredRoll = Mathf.Clamp(targetAngleYaw, -m_MaxRollAngle * Mathf.Deg2Rad, m_MaxRollAngle * Mathf.Deg2Rad); float yawInput = 0; float rollInput = 0; if (!m_TakenOff) @@ -88,11 +87,11 @@ private void FixedUpdate() { // now we have taken off to a safe height, we can use the rudder and ailerons to yaw and roll yawInput = targetAngleYaw; - rollInput = -(m_AeroplaneController.RollAngle - desiredRoll)*m_RollSensitivity; + rollInput = -(m_AeroplaneController.RollAngle - desiredRoll) * m_RollSensitivity; } // adjust how fast the AI is changing the controls based on the speed. Faster speed = faster on the controls. - float currentSpeedEffect = 1 + (m_AeroplaneController.ForwardSpeed*m_SpeedEffect); + float currentSpeedEffect = 1 + (m_AeroplaneController.ForwardSpeed * m_SpeedEffect); rollInput *= currentSpeedEffect; pitchInput *= currentSpeedEffect; yawInput *= currentSpeedEffect; diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAudio.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAudio.cs index 5db83e4432926c01d471cd96aa4aea1c686e60bd..0c3cd49b0cbedaa2d3a13b590dcdd53f7fab9abe 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAudio.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneAudio.cs @@ -82,16 +82,16 @@ private void Update() // Increase the engine's pitch by an amount proportional to the aeroplane's forward speed. // (this makes the pitch increase when going into a dive!) - m_EngineSoundSource.pitch += m_Plane.ForwardSpeed*m_EngineFwdSpeedMultiplier; + m_EngineSoundSource.pitch += m_Plane.ForwardSpeed * m_EngineFwdSpeedMultiplier; // Set the engine's volume to be proportional to the engine's current power. - m_EngineSoundSource.volume = Mathf.InverseLerp(0, m_Plane.MaxEnginePower*m_AdvancedSetttings.engineMasterVolume, + m_EngineSoundSource.volume = Mathf.InverseLerp(0, m_Plane.MaxEnginePower * m_AdvancedSetttings.engineMasterVolume, m_Plane.EnginePower); // Set the wind's pitch and volume to be proportional to the aeroplane's forward speed. float planeSpeed = m_Rigidbody.velocity.magnitude; - m_WindSoundSource.pitch = m_WindBasePitch + planeSpeed*m_WindSpeedPitchFactor; - m_WindSoundSource.volume = Mathf.InverseLerp(0, m_WindMaxSpeedVolume, planeSpeed)*m_AdvancedSetttings.windMasterVolume; + m_WindSoundSource.pitch = m_WindBasePitch + planeSpeed * m_WindSpeedPitchFactor; + m_WindSoundSource.volume = Mathf.InverseLerp(0, m_WindMaxSpeedVolume, planeSpeed) * m_AdvancedSetttings.windMasterVolume; } } } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneControlSurfaceAnimator.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneControlSurfaceAnimator.cs index 6e84dcfa02d7b8242a76c63cfe17580f942d68eb..d7128c57a36e65f66fc994d253acfdec25f03865 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneControlSurfaceAnimator.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneControlSurfaceAnimator.cs @@ -33,21 +33,21 @@ private void Update() case ControlSurface.Type.Aileron: { // Ailerons rotate around the x axis, according to the plane's roll input - Quaternion rotation = Quaternion.Euler(surface.amount*m_Plane.RollInput, 0f, 0f); + Quaternion rotation = Quaternion.Euler(surface.amount * m_Plane.RollInput, 0f, 0f); RotateSurface(surface, rotation); break; } case ControlSurface.Type.Elevator: { // Elevators rotate negatively around the x axis, according to the plane's pitch input - Quaternion rotation = Quaternion.Euler(surface.amount*-m_Plane.PitchInput, 0f, 0f); + Quaternion rotation = Quaternion.Euler(surface.amount * -m_Plane.PitchInput, 0f, 0f); RotateSurface(surface, rotation); break; } case ControlSurface.Type.Rudder: { // Rudders rotate around their y axis, according to the plane's yaw input - Quaternion rotation = Quaternion.Euler(0f, surface.amount*m_Plane.YawInput, 0f); + Quaternion rotation = Quaternion.Euler(0f, surface.amount * m_Plane.YawInput, 0f); RotateSurface(surface, rotation); break; } @@ -56,7 +56,7 @@ private void Update() // Ruddervators are a combination of rudder and elevator, and rotate // around their z axis by a combination of the yaw and pitch input float r = m_Plane.YawInput + m_Plane.PitchInput; - Quaternion rotation = Quaternion.Euler(0f, 0f, surface.amount*r); + Quaternion rotation = Quaternion.Euler(0f, 0f, surface.amount * r); RotateSurface(surface, rotation); break; } @@ -64,7 +64,7 @@ private void Update() { // ... and because ruddervators are "special", we need a negative version too. >_< float r = m_Plane.YawInput - m_Plane.PitchInput; - Quaternion rotation = Quaternion.Euler(0f, 0f, surface.amount*r); + Quaternion rotation = Quaternion.Euler(0f, 0f, surface.amount * r); RotateSurface(surface, rotation); break; } @@ -76,11 +76,11 @@ private void Update() private void RotateSurface(ControlSurface surface, Quaternion rotation) { // Create a target which is the surface's original rotation, rotated by the input. - Quaternion target = surface.originalLocalRotation*rotation; + Quaternion target = surface.originalLocalRotation * rotation; // Slerp the surface's rotation towards the target rotation. surface.transform.localRotation = Quaternion.Slerp(surface.transform.localRotation, target, - m_Smoothing*Time.deltaTime); + m_Smoothing * Time.deltaTime); } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneController.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneController.cs index 4148752c8311f3153133c6496b1d4123f917c04e..619f75158418dc8cbdb1519b5e296f006eb306d2 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneController.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneController.cs @@ -1,9 +1,8 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Aeroplane { - [RequireComponent(typeof (Rigidbody))] + [RequireComponent(typeof(Rigidbody))] public class AeroplaneController : MonoBehaviour { [SerializeField] private float m_MaxEnginePower = 40f; // The maximum output of the engine. @@ -26,7 +25,7 @@ public class AeroplaneController : MonoBehaviour public bool AirBrakes { get; private set; } // Whether or not the air brakes are being applied. public float ForwardSpeed { get; private set; } // How fast the aeroplane is traveling in it's forward direction. public float EnginePower { get; private set; } // How much power the engine is being given. - public float MaxEnginePower{ get { return m_MaxEnginePower; }} // The maximum output of the engine. + public float MaxEnginePower { get { return m_MaxEnginePower; } } // The maximum output of the engine. public float RollAngle { get; private set; } public float PitchAngle { get; private set; } public float RollInput { get; private set; } @@ -40,7 +39,7 @@ public class AeroplaneController : MonoBehaviour private bool m_Immobilized = false; // used for making the plane uncontrollable, i.e. if it has been hit or crashed. private float m_BankedTurnAmount; private Rigidbody m_Rigidbody; - WheelCollider[] m_WheelColliders; + WheelCollider[] m_WheelColliders; private void Start() @@ -50,13 +49,13 @@ private void Start() m_OriginalDrag = m_Rigidbody.drag; m_OriginalAngularDrag = m_Rigidbody.angularDrag; - for (int i = 0; i < transform.childCount; i++ ) - { - foreach (var componentsInChild in transform.GetChild(i).GetComponentsInChildren<WheelCollider>()) - { - componentsInChild.motorTorque = 0.18f; - } - } + for (int i = 0; i < transform.childCount; i++) + { + foreach (var componentsInChild in transform.GetChild(i).GetComponentsInChildren<WheelCollider>()) + { + componentsInChild.motorTorque = 0.18f; + } + } } @@ -131,13 +130,13 @@ private void AutoLevel() // auto level roll, if there's no roll input: if (RollInput == 0f) { - RollInput = -RollAngle*m_AutoRollLevel; + RollInput = -RollAngle * m_AutoRollLevel; } // auto correct pitch, if no pitch input (but also apply the banked turn amount) if (PitchInput == 0f) { - PitchInput = -PitchAngle*m_AutoPitchLevel; - PitchInput -= Mathf.Abs(m_BankedTurnAmount*m_BankedTurnAmount*m_AutoTurnPitch); + PitchInput = -PitchAngle * m_AutoPitchLevel; + PitchInput -= Mathf.Abs(m_BankedTurnAmount * m_BankedTurnAmount * m_AutoTurnPitch); } } @@ -159,21 +158,21 @@ private void ControlThrottle() } // Adjust throttle based on throttle input (or immobilized state) - Throttle = Mathf.Clamp01(Throttle + ThrottleInput*Time.deltaTime*m_ThrottleChangeSpeed); + Throttle = Mathf.Clamp01(Throttle + ThrottleInput * Time.deltaTime * m_ThrottleChangeSpeed); // current engine power is just: - EnginePower = Throttle*m_MaxEnginePower; + EnginePower = Throttle * m_MaxEnginePower; } private void CalculateDrag() { // increase the drag based on speed, since a constant drag doesn't seem "Real" (tm) enough - float extraDrag = m_Rigidbody.velocity.magnitude*m_DragIncreaseFactor; + float extraDrag = m_Rigidbody.velocity.magnitude * m_DragIncreaseFactor; // Air brakes work by directly modifying drag. This part is actually pretty realistic! - m_Rigidbody.drag = (AirBrakes ? (m_OriginalDrag + extraDrag)*m_AirBrakesEffect : m_OriginalDrag + extraDrag); + m_Rigidbody.drag = (AirBrakes ? (m_OriginalDrag + extraDrag) * m_AirBrakesEffect : m_OriginalDrag + extraDrag); // Forward speed affects angular drag - at high forward speed, it's much harder for the plane to spin - m_Rigidbody.angularDrag = m_OriginalAngularDrag*ForwardSpeed; + m_Rigidbody.angularDrag = m_OriginalAngularDrag * ForwardSpeed; } @@ -190,15 +189,15 @@ private void CaluclateAerodynamicEffect() m_AeroFactor *= m_AeroFactor; // Finally we calculate a new velocity by bending the current velocity direction towards // the the direction the plane is facing, by an amount based on this aeroFactor - var newVelocity = Vector3.Lerp(m_Rigidbody.velocity, transform.forward*ForwardSpeed, - m_AeroFactor*ForwardSpeed*m_AerodynamicEffect*Time.deltaTime); + var newVelocity = Vector3.Lerp(m_Rigidbody.velocity, transform.forward * ForwardSpeed, + m_AeroFactor * ForwardSpeed * m_AerodynamicEffect * Time.deltaTime); m_Rigidbody.velocity = newVelocity; // also rotate the plane towards the direction of movement - this should be a very small effect, but means the plane ends up // pointing downwards in a stall m_Rigidbody.rotation = Quaternion.Slerp(m_Rigidbody.rotation, Quaternion.LookRotation(m_Rigidbody.velocity, transform.up), - m_AerodynamicEffect*Time.deltaTime); + m_AerodynamicEffect * Time.deltaTime); } } @@ -209,7 +208,7 @@ private void CalculateLinearForces() // we accumulate forces into this variable: var forces = Vector3.zero; // Add the engine power in the forward direction - forces += EnginePower*transform.forward; + forces += EnginePower * transform.forward; // The direction that the lift force is applied is at right angles to the plane's velocity (usually, this is 'up'!) var liftDirection = Vector3.Cross(m_Rigidbody.velocity, transform.right).normalized; // The amount of lift drops off as the plane increases speed - in reality this occurs as the pilot retracts the flaps @@ -217,8 +216,8 @@ private void CalculateLinearForces() // a simple way of doing it automatically: var zeroLiftFactor = Mathf.InverseLerp(m_ZeroLiftSpeed, 0, ForwardSpeed); // Calculate and add the lift power - var liftPower = ForwardSpeed*ForwardSpeed*m_Lift*zeroLiftFactor*m_AeroFactor; - forces += liftPower*liftDirection; + var liftPower = ForwardSpeed * ForwardSpeed * m_Lift * zeroLiftFactor * m_AeroFactor; + forces += liftPower * liftDirection; // Apply the calculated forces to the the Rigidbody m_Rigidbody.AddForce(forces); } @@ -229,17 +228,17 @@ private void CalculateTorque() // We accumulate torque forces into this variable: var torque = Vector3.zero; // Add torque for the pitch based on the pitch input. - torque += PitchInput*m_PitchEffect*transform.right; + torque += PitchInput * m_PitchEffect * transform.right; // Add torque for the yaw based on the yaw input. - torque += YawInput*m_YawEffect*transform.up; + torque += YawInput * m_YawEffect * transform.up; // Add torque for the roll based on the roll input. - torque += -RollInput*m_RollEffect*transform.forward; + torque += -RollInput * m_RollEffect * transform.forward; // Add torque for banked turning. - torque += m_BankedTurnAmount*m_BankedTurnEffect*transform.up; + torque += m_BankedTurnAmount * m_BankedTurnEffect * transform.up; // The total torque is multiplied by the forward speed, so the controls have more effect at high speed, // and little effect at low speed, or when not moving in the direction of the nose of the plane // (i.e. falling while stalled) - m_Rigidbody.AddTorque(torque*ForwardSpeed*m_AeroFactor); + m_Rigidbody.AddTorque(torque * ForwardSpeed * m_AeroFactor); } @@ -247,7 +246,7 @@ private void CalculateAltitude() { // Altitude calculations - we raycast downwards from the aeroplane // starting a safe distance below the plane to avoid colliding with any of the plane's own colliders - var ray = new Ray(transform.position - Vector3.up*10, -Vector3.up); + var ray = new Ray(transform.position - Vector3.up * 10, -Vector3.up); RaycastHit hit; Altitude = Physics.Raycast(ray, out hit) ? hit.distance + 10 : transform.position.y; } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplanePropellerAnimator.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplanePropellerAnimator.cs index 77e122bec29518413b16dbc6e7d96ee17979ac5b..4965f150dd6eea3e3348355ba1df7556ff5d786e 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplanePropellerAnimator.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplanePropellerAnimator.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Aeroplane @@ -35,7 +34,7 @@ private void Awake() private void Update() { // Rotate the propellor model at a rate proportional to the throttle. - m_PropellorModel.Rotate(0, m_MaxRpm*m_Plane.Throttle*Time.deltaTime*k_RpmToDps, 0); + m_PropellorModel.Rotate(0, m_MaxRpm * m_Plane.Throttle * Time.deltaTime * k_RpmToDps, 0); // Create an integer for the new state of the blur textures. var newBlurState = 0; @@ -44,7 +43,7 @@ private void Update() if (m_Plane.Throttle > m_ThrottleBlurStart) { var throttleBlurProportion = Mathf.InverseLerp(m_ThrottleBlurStart, m_ThrottleBlurEnd, m_Plane.Throttle); - newBlurState = Mathf.FloorToInt(throttleBlurProportion*(m_PropellorBlurTextures.Length - 1)); + newBlurState = Mathf.FloorToInt(throttleBlurProportion * (m_PropellorBlurTextures.Length - 1)); } // If the blur state has changed diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl2Axis.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl2Axis.cs index fa4b12b29023e33a83df59759623b3be93c8cf56..c563d1fa4168ba37e438c87a84ba2a51ec3108cb 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl2Axis.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl2Axis.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; namespace UnityStandardAssets.Vehicles.Aeroplane { - [RequireComponent(typeof (AeroplaneController))] + [RequireComponent(typeof(AeroplaneController))] public class AeroplaneUserControl2Axis : MonoBehaviour { // these max angles are only used on mobile, due to the way pitch and roll input are handled @@ -49,13 +48,13 @@ private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref f // and the roll input is calculated to achieve that. // whereas on non-mobile, the input directly controls the roll of the aeroplane. - float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad; - float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad; + float intendedRollAngle = roll * maxRollAngle * Mathf.Deg2Rad; + float intendedPitchAngle = pitch * maxPitchAngle * Mathf.Deg2Rad; roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1); pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1); // similarly, the throttle axis input is considered to be the desired absolute value, not a relative change to current throttle. - float intendedThrottle = throttle*0.5f + 0.5f; + float intendedThrottle = throttle * 0.5f + 0.5f; throttle = Mathf.Clamp(intendedThrottle - m_Aeroplane.Throttle, -1, 1); } } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl4Axis.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl4Axis.cs index f469570a0efc6b3cd6f8d5d81df49af5dbf8ff5f..15b8272db4be834a1087c70b0202098880814185 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl4Axis.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/AeroplaneUserControl4Axis.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; namespace UnityStandardAssets.Vehicles.Aeroplane { - [RequireComponent(typeof (AeroplaneController))] + [RequireComponent(typeof(AeroplaneController))] public class AeroplaneUserControl4Axis : MonoBehaviour { // these max angles are only used on mobile, due to the way pitch and roll input are handled @@ -51,8 +50,8 @@ private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref f // and the roll input is calculated to achieve that. // whereas on non-mobile, the input directly controls the roll of the aeroplane. - float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad; - float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad; + float intendedRollAngle = roll * maxRollAngle * Mathf.Deg2Rad; + float intendedPitchAngle = pitch * maxPitchAngle * Mathf.Deg2Rad; roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1); pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1); } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/JetParticleEffect.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/JetParticleEffect.cs index 41d81fe7173e082dea8d7eef4c046d70bcba1722..1c9db50747661155d894eee484e3f4325049fa5e 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/JetParticleEffect.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/JetParticleEffect.cs @@ -3,7 +3,7 @@ namespace UnityStandardAssets.Vehicles.Aeroplane { - [RequireComponent(typeof (ParticleSystem))] + [RequireComponent(typeof(ParticleSystem))] public class JetParticleEffect : MonoBehaviour { // this script controls the jet's exhaust particle system, controlling the @@ -35,11 +35,11 @@ private void Start() // Update is called once per frame private void Update() { - ParticleSystem.MainModule mainModule = m_System.main; - // update the particle system based on the jets throttle - mainModule.startLifetime = Mathf.Lerp(0.0f, m_OriginalLifetime, m_Jet.Throttle); - mainModule.startSize = Mathf.Lerp(m_OriginalStartSize*.3f, m_OriginalStartSize, m_Jet.Throttle); - mainModule.startColor = Color.Lerp(minColour, m_OriginalStartColor, m_Jet.Throttle); + ParticleSystem.MainModule mainModule = m_System.main; + // update the particle system based on the jets throttle + mainModule.startLifetime = Mathf.Lerp(0.0f, m_OriginalLifetime, m_Jet.Throttle); + mainModule.startSize = Mathf.Lerp(m_OriginalStartSize * .3f, m_OriginalStartSize, m_Jet.Throttle); + mainModule.startColor = Color.Lerp(minColour, m_OriginalStartColor, m_Jet.Throttle); } diff --git a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/LandingGear.cs b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/LandingGear.cs index 934705679706a9ba0d674996cf46121d932dc3ac..978248abf3229c757018773a3f14b22972e50d96 100644 --- a/Assets/Standard Assets/Vehicles/Aircraft/Scripts/LandingGear.cs +++ b/Assets/Standard Assets/Vehicles/Aircraft/Scripts/LandingGear.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Aeroplane @@ -49,7 +48,7 @@ private void Update() } // set the parameter on the animator controller to trigger the appropriate animation - m_Animator.SetInteger("GearState", (int) m_State); + m_Animator.SetInteger("GearState", (int)m_State); } } } diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/BrakeLight.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/BrakeLight.cs index 34a4ea04943ea4299651eeb1c91fad9a25709691..796f08053982312e3edda296abe62215e944a691 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/BrakeLight.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/BrakeLight.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Car diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/CarAIControl.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/CarAIControl.cs index dc7b8d6561481c37733a9b2bf7c99e8af17fa464..34f0c565d812b16de801e2f5476e31aa57a664e9 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/CarAIControl.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/CarAIControl.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using Random = UnityEngine.Random; namespace UnityStandardAssets.Vehicles.Car { - [RequireComponent(typeof (CarController))] + [RequireComponent(typeof(CarController))] public class CarAIControl : MonoBehaviour { public enum BrakeCondition @@ -52,7 +51,7 @@ private void Awake() m_CarController = GetComponent<CarController>(); // give the random perlin a random value - m_RandomPerlin = Random.value*100; + m_RandomPerlin = Random.value * 100; m_Rigidbody = GetComponent<Rigidbody>(); } @@ -69,7 +68,7 @@ private void FixedUpdate() else { Vector3 fwd = transform.forward; - if (m_Rigidbody.velocity.magnitude > m_CarController.MaxSpeed*0.1f) + if (m_Rigidbody.velocity.magnitude > m_CarController.MaxSpeed * 0.1f) { fwd = m_Rigidbody.velocity; } @@ -87,13 +86,13 @@ private void FixedUpdate() float approachingCornerAngle = Vector3.Angle(m_Target.forward, fwd); // also consider the current amount we're turning, multiplied up and then compared in the same way as an upcoming corner angle - float spinningAngle = m_Rigidbody.angularVelocity.magnitude*m_CautiousAngularVelocityFactor; + float spinningAngle = m_Rigidbody.angularVelocity.magnitude * m_CautiousAngularVelocityFactor; // if it's different to our current angle, we need to be cautious (i.e. slow down) a certain amount float cautiousnessRequired = Mathf.InverseLerp(0, m_CautiousMaxAngle, Mathf.Max(spinningAngle, approachingCornerAngle)); - desiredSpeed = Mathf.Lerp(m_CarController.MaxSpeed, m_CarController.MaxSpeed*m_CautiousSpeedFactor, + desiredSpeed = Mathf.Lerp(m_CarController.MaxSpeed, m_CarController.MaxSpeed * m_CautiousSpeedFactor, cautiousnessRequired); break; } @@ -108,12 +107,12 @@ private void FixedUpdate() float distanceCautiousFactor = Mathf.InverseLerp(m_CautiousMaxDistance, 0, delta.magnitude); // also consider the current amount we're turning, multiplied up and then compared in the same way as an upcoming corner angle - float spinningAngle = m_Rigidbody.angularVelocity.magnitude*m_CautiousAngularVelocityFactor; + float spinningAngle = m_Rigidbody.angularVelocity.magnitude * m_CautiousAngularVelocityFactor; // if it's different to our current angle, we need to be cautious (i.e. slow down) a certain amount float cautiousnessRequired = Mathf.Max( Mathf.InverseLerp(0, m_CautiousMaxAngle, spinningAngle), distanceCautiousFactor); - desiredSpeed = Mathf.Lerp(m_CarController.MaxSpeed, m_CarController.MaxSpeed*m_CautiousSpeedFactor, + desiredSpeed = Mathf.Lerp(m_CarController.MaxSpeed, m_CarController.MaxSpeed * m_CautiousSpeedFactor, cautiousnessRequired); break; } @@ -134,14 +133,14 @@ private void FixedUpdate() desiredSpeed *= m_AvoidOtherCarSlowdown; // and veer towards the side of our path-to-target that is away from the other car - offsetTargetPos += m_Target.right*m_AvoidPathOffset; + offsetTargetPos += m_Target.right * m_AvoidPathOffset; } else { // no need for evasive action, we can just wander across the path-to-target in a random way, // which can help prevent AI from seeming too uniform and robotic in their driving - offsetTargetPos += m_Target.right* - (Mathf.PerlinNoise(Time.time*m_LateralWanderSpeed, m_RandomPerlin)*2 - 1)* + offsetTargetPos += m_Target.right * + (Mathf.PerlinNoise(Time.time * m_LateralWanderSpeed, m_RandomPerlin) * 2 - 1) * m_LateralWanderDistance; } @@ -151,21 +150,21 @@ private void FixedUpdate() : m_AccelSensitivity; // decide the actual amount of accel/brake input to achieve desired speed. - float accel = Mathf.Clamp((desiredSpeed - m_CarController.CurrentSpeed)*accelBrakeSensitivity, -1, 1); + float accel = Mathf.Clamp((desiredSpeed - m_CarController.CurrentSpeed) * accelBrakeSensitivity, -1, 1); // add acceleration 'wander', which also prevents AI from seeming too uniform and robotic in their driving // i.e. increasing the accel wander amount can introduce jostling and bumps between AI cars in a race accel *= (1 - m_AccelWanderAmount) + - (Mathf.PerlinNoise(Time.time*m_AccelWanderSpeed, m_RandomPerlin)*m_AccelWanderAmount); + (Mathf.PerlinNoise(Time.time * m_AccelWanderSpeed, m_RandomPerlin) * m_AccelWanderAmount); // calculate the local-relative position of the target, to steer towards Vector3 localTarget = transform.InverseTransformPoint(offsetTargetPos); // work out the local angle towards the target - float targetAngle = Mathf.Atan2(localTarget.x, localTarget.z)*Mathf.Rad2Deg; + float targetAngle = Mathf.Atan2(localTarget.x, localTarget.z) * Mathf.Rad2Deg; // get the amount of steering needed to aim the car towards the target - float steer = Mathf.Clamp(targetAngle*m_SteerSensitivity, -1, 1)*Mathf.Sign(m_CarController.CurrentSpeed); + float steer = Mathf.Clamp(targetAngle * m_SteerSensitivity, -1, 1) * Mathf.Sign(m_CarController.CurrentSpeed); // feed input to the car controller. m_CarController.Move(steer, accel, accel, 0f); @@ -206,7 +205,7 @@ private void OnCollisionStay(Collision col) // away from the other car var otherCarLocalDelta = transform.InverseTransformPoint(otherAI.transform.position); float otherCarAngle = Mathf.Atan2(otherCarLocalDelta.x, otherCarLocalDelta.z); - m_AvoidPathOffset = m_LateralWanderDistance*-Mathf.Sign(otherCarAngle); + m_AvoidPathOffset = m_LateralWanderDistance * -Mathf.Sign(otherCarAngle); } } } diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/CarAudio.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/CarAudio.cs index 550149c73d88385a231eb03c6c9f5f58869da4f3..a17d0564f0f4f3115fb06565ba9b105eef37f869 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/CarAudio.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/CarAudio.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using Random = UnityEngine.Random; namespace UnityStandardAssets.Vehicles.Car { - [RequireComponent(typeof (CarController))] + [RequireComponent(typeof(CarController))] public class CarAudio : MonoBehaviour { // This script reads some of the car's current properties and plays sounds accordingly. @@ -90,13 +89,13 @@ private void Update() float camDist = (Camera.main.transform.position - transform.position).sqrMagnitude; // stop sound if the object is beyond the maximum roll off distance - if (m_StartedSound && camDist > maxRolloffDistance*maxRolloffDistance) + if (m_StartedSound && camDist > maxRolloffDistance * maxRolloffDistance) { StopSound(); } // start the sound if not playing and it is nearer than the maximum distance - if (!m_StartedSound && camDist < maxRolloffDistance*maxRolloffDistance) + if (!m_StartedSound && camDist < maxRolloffDistance * maxRolloffDistance) { StartSound(); } @@ -112,7 +111,7 @@ private void Update() if (engineSoundStyle == EngineAudioOptions.Simple) { // for 1 channel engine sound, it's oh so simple: - m_HighAccel.pitch = pitch*pitchMultiplier*highPitchMultiplier; + m_HighAccel.pitch = pitch * pitchMultiplier * highPitchMultiplier; m_HighAccel.dopplerLevel = useDoppler ? dopplerLevel : 0; m_HighAccel.volume = 1; } @@ -121,10 +120,10 @@ private void Update() // for 4 channel engine sound, it's a little more complex: // adjust the pitches based on the multipliers - m_LowAccel.pitch = pitch*pitchMultiplier; - m_LowDecel.pitch = pitch*pitchMultiplier; - m_HighAccel.pitch = pitch*highPitchMultiplier*pitchMultiplier; - m_HighDecel.pitch = pitch*highPitchMultiplier*pitchMultiplier; + m_LowAccel.pitch = pitch * pitchMultiplier; + m_LowDecel.pitch = pitch * pitchMultiplier; + m_HighAccel.pitch = pitch * highPitchMultiplier * pitchMultiplier; + m_HighDecel.pitch = pitch * highPitchMultiplier * pitchMultiplier; // get values for fading the sounds based on the acceleration float accFade = Mathf.Abs(m_CarController.AccelInput); @@ -135,16 +134,16 @@ private void Update() float lowFade = 1 - highFade; // adjust the values to be more realistic - highFade = 1 - ((1 - highFade)*(1 - highFade)); - lowFade = 1 - ((1 - lowFade)*(1 - lowFade)); - accFade = 1 - ((1 - accFade)*(1 - accFade)); - decFade = 1 - ((1 - decFade)*(1 - decFade)); + highFade = 1 - ((1 - highFade) * (1 - highFade)); + lowFade = 1 - ((1 - lowFade) * (1 - lowFade)); + accFade = 1 - ((1 - accFade) * (1 - accFade)); + decFade = 1 - ((1 - decFade) * (1 - decFade)); // adjust the source volumes based on the fade values - m_LowAccel.volume = lowFade*accFade; - m_LowDecel.volume = lowFade*decFade; - m_HighAccel.volume = highFade*accFade; - m_HighDecel.volume = highFade*decFade; + m_LowAccel.volume = lowFade * accFade; + m_LowDecel.volume = lowFade * decFade; + m_HighAccel.volume = highFade * accFade; + m_HighDecel.volume = highFade * decFade; // adjust the doppler levels m_HighAccel.dopplerLevel = useDoppler ? dopplerLevel : 0; @@ -178,7 +177,7 @@ private AudioSource SetUpEngineAudioSource(AudioClip clip) // unclamped versions of Lerp and Inverse Lerp, to allow value to exceed the from-to range private static float ULerp(float from, float to, float value) { - return (1.0f - value)*from + value*to; + return (1.0f - value) * from + value * to; } } } diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs index 1273c6cf68e2787e3c14a85ef8cf15f89d96b6d5..947e6370ae55ad63d7c8a3b1af30d581102d5003 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/CarController.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Car @@ -49,9 +48,9 @@ public class CarController : MonoBehaviour public bool Skidding { get; private set; } public float BrakeInput { get; private set; } - public float CurrentSteerAngle{ get { return m_SteerAngle; }} - public float CurrentSpeed{ get { return m_Rigidbody.velocity.magnitude*2.23693629f; }} - public float MaxSpeed{get { return m_Topspeed; }} + public float CurrentSteerAngle { get { return m_SteerAngle; } } + public float CurrentSpeed { get { return m_Rigidbody.velocity.magnitude * 2.23693629f; } } + public float MaxSpeed { get { return m_Topspeed; } } public float Revs { get; private set; } public float AccelInput { get; private set; } @@ -68,15 +67,15 @@ private void Start() m_MaxHandbrakeTorque = float.MaxValue; m_Rigidbody = GetComponent<Rigidbody>(); - m_CurrentTorque = m_FullTorqueOverAllWheels - (m_TractionControl*m_FullTorqueOverAllWheels); + m_CurrentTorque = m_FullTorqueOverAllWheels - (m_TractionControl * m_FullTorqueOverAllWheels); } private void GearChanging() { - float f = Mathf.Abs(CurrentSpeed/MaxSpeed); - float upgearlimit = (1/(float) NoOfGears)*(m_GearNum + 1); - float downgearlimit = (1/(float) NoOfGears)*m_GearNum; + float f = Mathf.Abs(CurrentSpeed / MaxSpeed); + float upgearlimit = (1 / (float)NoOfGears) * (m_GearNum + 1); + float downgearlimit = (1 / (float)NoOfGears) * m_GearNum; if (m_GearNum > 0 && f < downgearlimit) { @@ -93,24 +92,24 @@ private void GearChanging() // simple function to add a curved bias towards 1 for a value in the 0-1 range private static float CurveFactor(float factor) { - return 1 - (1 - factor)*(1 - factor); + return 1 - (1 - factor) * (1 - factor); } // unclamped version of Lerp, to allow value to exceed the from-to range private static float ULerp(float from, float to, float value) { - return (1.0f - value)*from + value*to; + return (1.0f - value) * from + value * to; } private void CalculateGearFactor() { - float f = (1/(float) NoOfGears); + float f = (1 / (float)NoOfGears); // gear factor is a normalised representation of the current speed within the current gear's range of speeds. // We smooth towards the 'target' gear factor, so that revs don't instantly snap up or down when changing gear. - var targetGearFactor = Mathf.InverseLerp(f*m_GearNum, f*(m_GearNum + 1), Mathf.Abs(CurrentSpeed/MaxSpeed)); - m_GearFactor = Mathf.Lerp(m_GearFactor, targetGearFactor, Time.deltaTime*5f); + var targetGearFactor = Mathf.InverseLerp(f * m_GearNum, f * (m_GearNum + 1), Mathf.Abs(CurrentSpeed / MaxSpeed)); + m_GearFactor = Mathf.Lerp(m_GearFactor, targetGearFactor, Time.deltaTime * 5f); } @@ -119,7 +118,7 @@ private void CalculateRevs() // calculate engine revs (for display / sound) // (this is done in retrospect - revs are not used in force/power calculations) CalculateGearFactor(); - var gearNumFactor = m_GearNum/(float) NoOfGears; + var gearNumFactor = m_GearNum / (float)NoOfGears; var revsRangeMin = ULerp(0f, m_RevRangeBoundary, CurveFactor(gearNumFactor)); var revsRangeMax = ULerp(m_RevRangeBoundary, 1f, gearNumFactor); Revs = ULerp(revsRangeMin, revsRangeMax, m_GearFactor); @@ -140,12 +139,12 @@ public void Move(float steering, float accel, float footbrake, float handbrake) //clamp input values steering = Mathf.Clamp(steering, -1, 1); AccelInput = accel = Mathf.Clamp(accel, 0, 1); - BrakeInput = footbrake = -1*Mathf.Clamp(footbrake, -1, 0); + BrakeInput = footbrake = -1 * Mathf.Clamp(footbrake, -1, 0); handbrake = Mathf.Clamp(handbrake, 0, 1); //Set the steer on the front wheels. //Assuming that wheels 0 and 1 are the front wheels. - m_SteerAngle = steering*m_MaximumSteerAngle; + m_SteerAngle = steering * m_MaximumSteerAngle; m_WheelColliders[0].steerAngle = m_SteerAngle; m_WheelColliders[1].steerAngle = m_SteerAngle; @@ -157,7 +156,7 @@ public void Move(float steering, float accel, float footbrake, float handbrake) //Assuming that wheels 2 and 3 are the rear wheels. if (handbrake > 0f) { - var hbTorque = handbrake*m_MaxHandbrakeTorque; + var hbTorque = handbrake * m_MaxHandbrakeTorque; m_WheelColliders[2].brakeTorque = hbTorque; m_WheelColliders[3].brakeTorque = hbTorque; } @@ -181,13 +180,13 @@ private void CapSpeed() speed *= 2.23693629f; if (speed > m_Topspeed) - m_Rigidbody.velocity = (m_Topspeed/2.23693629f) * m_Rigidbody.velocity.normalized; + m_Rigidbody.velocity = (m_Topspeed / 2.23693629f) * m_Rigidbody.velocity.normalized; break; case SpeedType.KPH: speed *= 3.6f; if (speed > m_Topspeed) - m_Rigidbody.velocity = (m_Topspeed/3.6f) * m_Rigidbody.velocity.normalized; + m_Rigidbody.velocity = (m_Topspeed / 3.6f) * m_Rigidbody.velocity.normalized; break; } } @@ -223,12 +222,12 @@ private void ApplyDrive(float accel, float footbrake) { if (CurrentSpeed > 5 && Vector3.Angle(transform.forward, m_Rigidbody.velocity) < 50f) { - m_WheelColliders[i].brakeTorque = m_BrakeTorque*footbrake; + m_WheelColliders[i].brakeTorque = m_BrakeTorque * footbrake; } else if (footbrake > 0) { m_WheelColliders[i].brakeTorque = 0f; - m_WheelColliders[i].motorTorque = -m_ReverseTorque*footbrake; + m_WheelColliders[i].motorTorque = -m_ReverseTorque * footbrake; } } } @@ -258,7 +257,7 @@ private void SteerHelper() // this is used to add more grip in relation to speed private void AddDownForce() { - m_WheelColliders[0].attachedRigidbody.AddForce(-transform.up*m_Downforce* + m_WheelColliders[0].attachedRigidbody.AddForce(-transform.up * m_Downforce * m_WheelColliders[0].attachedRigidbody.velocity.magnitude); } diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/CarSelfRighting.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/CarSelfRighting.cs index 1769c530f3cdb8cf60f222e8e0485c9357bee70f..05291445e94fbc8c3bfd69b7b91811a8926dfe22 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/CarSelfRighting.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/CarSelfRighting.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Car diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/CarUserControl.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/CarUserControl.cs index 09d010ded3010aaab7ded111b3542d62e680dc7e..54cdb9a08dafe3f97466f55726b3fb76d9f13397 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/CarUserControl.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/CarUserControl.cs @@ -1,10 +1,9 @@ -using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; namespace UnityStandardAssets.Vehicles.Car { - [RequireComponent(typeof (CarController))] + [RequireComponent(typeof(CarController))] public class CarUserControl : MonoBehaviour { private CarController m_Car; // the car controller we want to use diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/Mudguard.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/Mudguard.cs index 895d49f6e1ccadc5dc3adf0c09958a1fc96a4388..c04c369fe9324e565b73fb4e40206025fd136692 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/Mudguard.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/Mudguard.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Car @@ -21,7 +20,7 @@ private void Start() private void Update() { - transform.localRotation = m_OriginalRotation*Quaternion.Euler(0, carController.CurrentSteerAngle, 0); + transform.localRotation = m_OriginalRotation * Quaternion.Euler(0, carController.CurrentSteerAngle, 0); } } } diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/SkidTrail.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/SkidTrail.cs index 73922b124b4d662a28a06a3e0cbef9ad2244cdef..d0f5cb64495240c8a6376550129f38df3b1485fd 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/SkidTrail.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/SkidTrail.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using UnityEngine; @@ -11,13 +10,13 @@ public class SkidTrail : MonoBehaviour private IEnumerator Start() { - while (true) + while (true) { yield return null; if (transform.parent.parent == null) { - Destroy(gameObject, m_PersistTime); + Destroy(gameObject, m_PersistTime); } } } diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/Suspension.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/Suspension.cs index fc63f5db673e180373c935777dd62f3eed1c6ad6..580572edaec3e6dc47d8cc2b3793cadfe2cd96db 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/Suspension.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/Suspension.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; namespace UnityStandardAssets.Vehicles.Car diff --git a/Assets/Standard Assets/Vehicles/Car/Scripts/WheelEffects.cs b/Assets/Standard Assets/Vehicles/Car/Scripts/WheelEffects.cs index a601fbe19d235aa64562dca3549e1e5d2e815815..ee8b44a524ad653a584b2ac36cdceb78fbcf53ee 100644 --- a/Assets/Standard Assets/Vehicles/Car/Scripts/WheelEffects.cs +++ b/Assets/Standard Assets/Vehicles/Car/Scripts/WheelEffects.cs @@ -3,7 +3,7 @@ namespace UnityStandardAssets.Vehicles.Car { - [RequireComponent(typeof (AudioSource))] + [RequireComponent(typeof(AudioSource))] public class WheelEffects : MonoBehaviour { public Transform SkidTrailPrefab; @@ -44,7 +44,7 @@ private void Start() public void EmitTyreSmoke() { - skidParticles.transform.position = transform.position - transform.up*m_WheelCollider.radius; + skidParticles.transform.position = transform.position - transform.up * m_WheelCollider.radius; skidParticles.Emit(1); if (!skidding) { @@ -76,7 +76,7 @@ public IEnumerator StartSkidTrail() yield return null; } m_SkidTrail.parent = transform; - m_SkidTrail.localPosition = -Vector3.up*m_WheelCollider.radius; + m_SkidTrail.localPosition = -Vector3.up * m_WheelCollider.radius; } diff --git a/Packages/manifest.json b/Packages/manifest.json index df337cea5866ad57b8e4ff894989231a7cd7ef4f..b9278ee978d218db8ab32a66afda4f0af28bda9c 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -2,18 +2,20 @@ "dependencies": { "com.unity.2d.sprite": "1.0.0", "com.unity.2d.tilemap": "1.0.0", - "com.unity.ads": "3.6.1", - "com.unity.analytics": "3.3.5", - "com.unity.collab-proxy": "1.2.16", - "com.unity.ide.rider": "1.1.4", + "com.unity.ads": "3.7.1", + "com.unity.analytics": "3.5.3", + "com.unity.collab-proxy": "1.5.7", + "com.unity.ide.rider": "2.0.7", + "com.unity.ide.visualstudio": "2.0.9", "com.unity.ide.vscode": "1.2.3", "com.unity.multiplayer-hlapi": "1.0.8", "com.unity.nuget.newtonsoft-json": "2.0.0", "com.unity.probuilder": "4.2.1", - "com.unity.purchasing": "2.2.1", - "com.unity.test-framework": "1.1.22", - "com.unity.textmeshpro": "2.0.1", - "com.unity.timeline": "1.2.6", + "com.unity.purchasing": "3.2.2", + "com.unity.test-framework": "1.1.27", + "com.unity.textmeshpro": "3.0.6", + "com.unity.timeline": "1.4.8", + "com.unity.toolchain.win-x86_64-linux-x86_64": "0.1.21-preview", "com.unity.ugui": "1.0.0", "com.unity.xr.legacyinputhelpers": "2.1.7", "com.unity.modules.ai": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index c9ec41b32a129537a6a7b0a646f717345ba514c9..dfe3e606cd18e9ecb993179a06f6afd36188913b 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -13,7 +13,7 @@ "dependencies": {} }, "com.unity.ads": { - "version": "3.6.1", + "version": "3.7.1", "depth": 0, "source": "registry", "dependencies": { @@ -22,7 +22,7 @@ "url": "https://packages.unity.com" }, "com.unity.analytics": { - "version": "3.3.5", + "version": "3.5.3", "depth": 0, "source": "registry", "dependencies": { @@ -31,10 +31,12 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "1.2.16", + "version": "1.5.7", "depth": 0, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.unity.nuget.newtonsoft-json": "2.0.0" + }, "url": "https://packages.unity.com" }, "com.unity.ext.nunit": { @@ -45,7 +47,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "1.1.4", + "version": "2.0.7", "depth": 0, "source": "registry", "dependencies": { @@ -53,6 +55,15 @@ }, "url": "https://packages.unity.com" }, + "com.unity.ide.visualstudio": { + "version": "2.0.9", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.9" + }, + "url": "https://packages.unity.com" + }, "com.unity.ide.vscode": { "version": "1.2.3", "depth": 0, @@ -86,11 +97,15 @@ "url": "https://packages.unity.com" }, "com.unity.purchasing": { - "version": "2.2.1", + "version": "3.2.2", "depth": 0, "source": "registry", "dependencies": { - "com.unity.ugui": "1.0.0" + "com.unity.ugui": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.androidjni": "1.0.0" }, "url": "https://packages.unity.com" }, @@ -101,8 +116,24 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.sysroot": { + "version": "0.1.19-preview", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.sysroot.linux-x86_64": { + "version": "0.1.14-preview", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "0.1.18-preview" + }, + "url": "https://packages.unity.com" + }, "com.unity.test-framework": { - "version": "1.1.22", + "version": "1.1.27", "depth": 0, "source": "registry", "dependencies": { @@ -113,7 +144,7 @@ "url": "https://packages.unity.com" }, "com.unity.textmeshpro": { - "version": "2.0.1", + "version": "3.0.6", "depth": 0, "source": "registry", "dependencies": { @@ -122,10 +153,25 @@ "url": "https://packages.unity.com" }, "com.unity.timeline": { - "version": "1.2.6", + "version": "1.4.8", "depth": 0, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.unity.modules.director": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.toolchain.win-x86_64-linux-x86_64": { + "version": "0.1.21-preview", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "0.1.19-preview", + "com.unity.sysroot.linux-x86_64": "0.1.14-preview" + }, "url": "https://packages.unity.com" }, "com.unity.ugui": { @@ -287,6 +333,18 @@ "depth": 0, "source": "builtin", "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.uielementsnative": "1.0.0" + } + }, + "com.unity.modules.uielementsnative": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0" } diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 4a2378de10ed168b4028fa8fe11d8378eff7519b..808215cccb69db39b4534230458bb1828ba94c46 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -309,3 +309,67 @@ InputManager: type: 0 axis: 0 joyNum: 0 + - serializedVersion: 3 + m_Name: modifier + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: m + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: mod+undo + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: u + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: mod+redo + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: r + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: mod+reset + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: backspace + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/ProjectSettings/Packages/com.unity.probuilder/Settings.json b/ProjectSettings/Packages/com.unity.probuilder/Settings.json index 401fa09fd142286033acb5c25eac52ac52960ce6..844ef8673c5c3d754b1c8dcec2605693d996053a 100644 --- a/ProjectSettings/Packages/com.unity.probuilder/Settings.json +++ b/ProjectSettings/Packages/com.unity.probuilder/Settings.json @@ -126,7 +126,7 @@ { "type": "UnityEngine.ProBuilder.SelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "key": "editor.selectMode", - "value": "{\"m_Value\":8}" + "value": "{\"m_Value\":1}" }, { "type": "UnityEditor.ProBuilder.Actions.Export+ExportFormat, Unity.ProBuilder.Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", @@ -154,7 +154,7 @@ "value": "{\"m_Value\":{\"instanceID\":0}}" }, { - "type": "UnityEditor.StaticEditorFlags, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", + "type": "UnityEditor.StaticEditorFlags, UnityEditor.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "key": "mesh.defaultStaticEditorFlags", "value": "{\"m_Value\":0}" }, diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index e8a0ab94d4ef18d5846dbf730dc91abdae296347..98c9697e769ea76e15529f94d311fdabb9eb20c8 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.4.20f1 -m_EditorVersionWithRevision: 2019.4.20f1 (6dd1c08eedfa) +m_EditorVersion: 2020.3.14f1 +m_EditorVersionWithRevision: 2020.3.14f1 (d0d1bb862f9d)