From 44109ab727e2a61019f4c6df0090a17eeb8c6d31 Mon Sep 17 00:00:00 2001 From: esnya <2088693+esnya@users.noreply.github.com> Date: Tue, 26 Jul 2022 21:43:28 +0900 Subject: [PATCH] :bug: fix(core): Fix inspector --- .../Editor/USC_CarEditor.cs | 36 ++- .../Scripts/Core/USC_Car.asset | 258 ++++++++++-------- .../Scripts/Core/USC_Car.cs | 22 +- 3 files changed, 172 insertions(+), 144 deletions(-) diff --git a/Packages/com.nekometer.esnya.udon-simple-cars/Editor/USC_CarEditor.cs b/Packages/com.nekometer.esnya.udon-simple-cars/Editor/USC_CarEditor.cs index a0373a1..db630eb 100644 --- a/Packages/com.nekometer.esnya.udon-simple-cars/Editor/USC_CarEditor.cs +++ b/Packages/com.nekometer.esnya.udon-simple-cars/Editor/USC_CarEditor.cs @@ -106,7 +106,7 @@ public static void Apply(SerializedObject serializedCarObject, IEnumerable gameObjectNameTable = new Dictionary() { @@ -150,33 +148,31 @@ public override void OnInspectorGUI() while (property.NextVisible(false)) { - if (property.name == nameof(USC_Car.wheels)) OnWheelsGUI(property); - else + using (new EditorGUILayout.HorizontalScope()) { - using (new EditorGUILayout.HorizontalScope()) - { - EditorGUILayout.PropertyField(property, true); + EditorGUILayout.PropertyField(property, true); - if (gameObjectNameTable.ContainsKey(property.name)) + if (gameObjectNameTable.ContainsKey(property.name)) + { + var name = gameObjectNameTable[property.name]; + if (GUILayout.Button("Find", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { - var name = gameObjectNameTable[property.name]; - if (GUILayout.Button("Find", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) + var gameObject = EditorUtility.CollectDeepHierarchy(serializedObject.targetObjects) + .Select(o => o as GameObject) + .FirstOrDefault(o => o && o.name == name); + + if (gameObject) { - var gameObject = EditorUtility.CollectDeepHierarchy(serializedObject.targetObjects) - .Select(o => o as GameObject) - .FirstOrDefault(o => o && o.name == name); - - if (gameObject) - { - var fieldType = typeof(USC_Car).GetField(property.name, BindingFlags.Instance | BindingFlags.DeclaredOnly)?.FieldType; - property.objectReferenceValue = fieldType?.IsSubclassOf(typeof(Component)) == true ? (UnityEngine.Object)gameObject.GetComponent(fieldType) : gameObject; - } + var fieldType = typeof(USC_Car).GetField(property.name, BindingFlags.Instance | BindingFlags.DeclaredOnly)?.FieldType; + property.objectReferenceValue = fieldType?.IsSubclassOf(typeof(Component)) == true ? (UnityEngine.Object)gameObject.GetComponent(fieldType) : gameObject; } } } } } + OnWheelsGUI(); + serializedObject.ApplyModifiedProperties(); } } diff --git a/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.asset b/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.asset index 9bbfbda..4efd14c 100644 --- a/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.asset +++ b/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.asset @@ -2035,7 +2035,7 @@ MonoBehaviour: mscorlib - Name: Entry: 12 - Data: 1 + Data: 2 - Name: Entry: 7 Data: 103|UnityEngine.HeaderAttribute, UnityEngine.CoreModule @@ -2045,6 +2045,12 @@ MonoBehaviour: - Name: Entry: 8 Data: + - Name: + Entry: 7 + Data: 104|UnityEngine.HideInInspector, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: @@ -2065,7 +2071,7 @@ MonoBehaviour: Data: steeredWheels - Name: $v Entry: 7 - Data: 104|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 105|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: steeredWheels @@ -2089,11 +2095,17 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 105|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 106|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 - Data: 0 + Data: 1 + - Name: + Entry: 7 + Data: 107|UnityEngine.HideInInspector, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: @@ -2114,7 +2126,7 @@ MonoBehaviour: Data: drivingWheels - Name: $v Entry: 7 - Data: 106|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 108|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: drivingWheels @@ -2138,11 +2150,17 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 107|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 109|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 - Data: 0 + Data: 1 + - Name: + Entry: 7 + Data: 110|UnityEngine.HideInInspector, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: @@ -2163,7 +2181,7 @@ MonoBehaviour: Data: brakeWheels - Name: $v Entry: 7 - Data: 108|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 111|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: brakeWheels @@ -2187,11 +2205,17 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 109|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 112|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 - Data: 0 + Data: 1 + - Name: + Entry: 7 + Data: 113|UnityEngine.HideInInspector, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: @@ -2212,7 +2236,7 @@ MonoBehaviour: Data: detachedWheels - Name: $v Entry: 7 - Data: 110|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 114|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: detachedWheels @@ -2236,11 +2260,17 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 111|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 115|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 - Data: 0 + Data: 1 + - Name: + Entry: 7 + Data: 116|UnityEngine.HideInInspector, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: @@ -2261,13 +2291,13 @@ MonoBehaviour: Data: wheelVisuals - Name: $v Entry: 7 - Data: 112|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 117|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelVisuals - Name: k__BackingField Entry: 7 - Data: 113|System.RuntimeType, mscorlib + Data: 118|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Transform[], UnityEngine.CoreModule @@ -2276,7 +2306,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 113 + Data: 118 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2291,11 +2321,17 @@ MonoBehaviour: Data: true - Name: _fieldAttributes Entry: 7 - Data: 114|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 119|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 - Data: 0 + Data: 1 + - Name: + Entry: 7 + Data: 120|UnityEngine.HideInInspector, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: @@ -2316,13 +2352,13 @@ MonoBehaviour: Data: animator - Name: $v Entry: 7 - Data: 115|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 121|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: animator - Name: k__BackingField Entry: 7 - Data: 116|System.RuntimeType, mscorlib + Data: 122|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Animator, UnityEngine.AnimationModule @@ -2331,7 +2367,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 116 + Data: 122 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2346,7 +2382,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 117|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 123|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2371,13 +2407,13 @@ MonoBehaviour: Data: vehicleRigidbody - Name: $v Entry: 7 - Data: 118|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 124|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: vehicleRigidbody - Name: k__BackingField Entry: 7 - Data: 119|System.RuntimeType, mscorlib + Data: 125|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Rigidbody, UnityEngine.PhysicsModule @@ -2386,7 +2422,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 119 + Data: 125 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2401,7 +2437,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 120|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 126|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2426,13 +2462,13 @@ MonoBehaviour: Data: wheelCount - Name: $v Entry: 7 - Data: 121|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 127|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelCount - Name: k__BackingField Entry: 7 - Data: 122|System.RuntimeType, mscorlib + Data: 128|System.RuntimeType, mscorlib - Name: Entry: 1 Data: System.Int32, mscorlib @@ -2441,7 +2477,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 122 + Data: 128 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2456,7 +2492,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 123|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 129|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2481,13 +2517,13 @@ MonoBehaviour: Data: wheelAngles - Name: $v Entry: 7 - Data: 124|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 130|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelAngles - Name: k__BackingField Entry: 7 - Data: 125|System.RuntimeType, mscorlib + Data: 131|System.RuntimeType, mscorlib - Name: Entry: 1 Data: System.Single[], mscorlib @@ -2496,7 +2532,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 125 + Data: 131 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2511,7 +2547,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 126|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 132|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2536,13 +2572,13 @@ MonoBehaviour: Data: wheelVisualLocalRotations - Name: $v Entry: 7 - Data: 127|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 133|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelVisualLocalRotations - Name: k__BackingField Entry: 7 - Data: 128|System.RuntimeType, mscorlib + Data: 134|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Quaternion[], UnityEngine.CoreModule @@ -2551,7 +2587,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 128 + Data: 134 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2566,7 +2602,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 129|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 135|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2591,13 +2627,13 @@ MonoBehaviour: Data: wheelVisualPositionOffsets - Name: $v Entry: 7 - Data: 130|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 136|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelVisualPositionOffsets - Name: k__BackingField Entry: 7 - Data: 131|System.RuntimeType, mscorlib + Data: 137|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Vector3[], UnityEngine.CoreModule @@ -2606,7 +2642,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 131 + Data: 137 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2621,7 +2657,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 132|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 138|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2646,16 +2682,16 @@ MonoBehaviour: Data: wheelVisualAxiesRight - Name: $v Entry: 7 - Data: 133|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 139|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelVisualAxiesRight - Name: k__BackingField Entry: 9 - Data: 131 + Data: 137 - Name: k__BackingField Entry: 9 - Data: 131 + Data: 137 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2670,7 +2706,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 134|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 140|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2695,16 +2731,16 @@ MonoBehaviour: Data: wheelVisualAxiesUp - Name: $v Entry: 7 - Data: 135|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 141|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelVisualAxiesUp - Name: k__BackingField Entry: 9 - Data: 131 + Data: 137 - Name: k__BackingField Entry: 9 - Data: 131 + Data: 137 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2719,7 +2755,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 136|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 142|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2744,13 +2780,13 @@ MonoBehaviour: Data: wheelIsSteered - Name: $v Entry: 7 - Data: 137|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 143|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelIsSteered - Name: k__BackingField Entry: 7 - Data: 138|System.RuntimeType, mscorlib + Data: 144|System.RuntimeType, mscorlib - Name: Entry: 1 Data: System.Boolean[], mscorlib @@ -2759,7 +2795,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 138 + Data: 144 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2774,7 +2810,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 139|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 145|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2799,13 +2835,13 @@ MonoBehaviour: Data: steeringWheelInitialRotation - Name: $v Entry: 7 - Data: 140|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 146|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: steeringWheelInitialRotation - Name: k__BackingField Entry: 7 - Data: 141|System.RuntimeType, mscorlib + Data: 147|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Quaternion, UnityEngine.CoreModule @@ -2814,7 +2850,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 141 + Data: 147 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2829,7 +2865,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 142|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 148|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2854,13 +2890,13 @@ MonoBehaviour: Data: detachedRigidbodies - Name: $v Entry: 7 - Data: 143|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 149|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: detachedRigidbodies - Name: k__BackingField Entry: 7 - Data: 144|System.RuntimeType, mscorlib + Data: 150|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Rigidbody[], UnityEngine.PhysicsModule @@ -2869,7 +2905,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 144 + Data: 150 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2884,7 +2920,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 145|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 151|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2909,13 +2945,13 @@ MonoBehaviour: Data: detachedRigidbodyTransforms - Name: $v Entry: 7 - Data: 146|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 152|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: detachedRigidbodyTransforms - Name: k__BackingField Entry: 7 - Data: 147|System.RuntimeType, mscorlib + Data: 153|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Matrix4x4[], UnityEngine.CoreModule @@ -2924,7 +2960,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 147 + Data: 153 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2939,7 +2975,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 148|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 154|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2964,13 +3000,13 @@ MonoBehaviour: Data: detachedObjecySyncs - Name: $v Entry: 7 - Data: 149|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 155|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: detachedObjecySyncs - Name: k__BackingField Entry: 7 - Data: 150|System.RuntimeType, mscorlib + Data: 156|System.RuntimeType, mscorlib - Name: Entry: 1 Data: VRC.SDK3.Components.VRCObjectSync[], VRCSDK3 @@ -2979,7 +3015,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 150 + Data: 156 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2994,7 +3030,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 151|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 157|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3019,7 +3055,7 @@ MonoBehaviour: Data: prevSpeed - Name: $v Entry: 7 - Data: 152|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 158|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: prevSpeed @@ -3043,7 +3079,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 153|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 159|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3068,13 +3104,13 @@ MonoBehaviour: Data: prevStartMoving - Name: $v Entry: 7 - Data: 154|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 160|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: prevStartMoving - Name: k__BackingField Entry: 7 - Data: 155|System.RuntimeType, mscorlib + Data: 161|System.RuntimeType, mscorlib - Name: Entry: 1 Data: System.Boolean, mscorlib @@ -3083,7 +3119,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3098,7 +3134,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 156|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 162|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3123,16 +3159,16 @@ MonoBehaviour: Data: _localIsDriver - Name: $v Entry: 7 - Data: 157|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 163|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _localIsDriver - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3147,7 +3183,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 158|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 164|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3172,16 +3208,16 @@ MonoBehaviour: Data: _localInVehicle - Name: $v Entry: 7 - Data: 159|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 165|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _localInVehicle - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3196,7 +3232,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 160|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 166|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3221,7 +3257,7 @@ MonoBehaviour: Data: wheelSpeed - Name: $v Entry: 7 - Data: 161|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 167|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: wheelSpeed @@ -3245,14 +3281,14 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 162|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 168|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 1 - Name: Entry: 7 - Data: 163|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 169|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: @@ -3276,7 +3312,7 @@ MonoBehaviour: Data: _accelerationValue - Name: $v Entry: 7 - Data: 164|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 170|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _accelerationValue @@ -3300,20 +3336,20 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 165|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 171|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 166|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 172|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 167|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime + Data: 173|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: @@ -3337,7 +3373,7 @@ MonoBehaviour: Data: _brakeValue - Name: $v Entry: 7 - Data: 168|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 174|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _brakeValue @@ -3361,20 +3397,20 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 169|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 175|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 170|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 176|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 171|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime + Data: 177|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: @@ -3398,7 +3434,7 @@ MonoBehaviour: Data: _steeringValue - Name: $v Entry: 7 - Data: 172|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 178|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _steeringValue @@ -3422,20 +3458,20 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 173|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 179|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 174|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 180|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 175|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime + Data: 181|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: @@ -3459,16 +3495,16 @@ MonoBehaviour: Data: _isOperating - Name: $v Entry: 7 - Data: 176|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 182|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _isOperating - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 9 - Data: 155 + Data: 161 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3483,20 +3519,20 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 177|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 183|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 178|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 184|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 179|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime + Data: 185|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: @@ -3520,16 +3556,16 @@ MonoBehaviour: Data: _gear - Name: $v Entry: 7 - Data: 180|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 186|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _gear - Name: k__BackingField Entry: 9 - Data: 122 + Data: 128 - Name: k__BackingField Entry: 9 - Data: 122 + Data: 128 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3544,20 +3580,20 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 181|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 187|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 2 - Name: Entry: 7 - Data: 182|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 188|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: - Name: Entry: 7 - Data: 183|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime + Data: 189|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: diff --git a/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.cs b/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.cs index 528463b..049d3ca 100644 --- a/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.cs +++ b/Packages/com.nekometer.esnya.udon-simple-cars/Scripts/Core/USC_Car.cs @@ -64,13 +64,13 @@ public class USC_Car : UdonSharpBehaviour [Tooltip("Bool")] public string localInVehicleParameter = "LocalInVehicle"; [Header("Wheels")] - public WheelCollider[] wheels = { }; - public WheelCollider[] steeredWheels = { }; - public WheelCollider[] drivingWheels = { }; - public WheelCollider[] brakeWheels = { }; - // public WheelCollider[] parkingBrakeWheels = {}; - public WheelCollider[] detachedWheels = { }; - public Transform[] wheelVisuals = { }; + [HideInInspector] public WheelCollider[] wheels = { }; + [HideInInspector] public WheelCollider[] steeredWheels = { }; + [HideInInspector] public WheelCollider[] drivingWheels = { }; + [HideInInspector] public WheelCollider[] brakeWheels = { }; + // [HideInInspector] public WheelCollider[] parkingBrakeWheels = {}; + [HideInInspector] public WheelCollider[] detachedWheels = { }; + [HideInInspector] public Transform[] wheelVisuals = { }; private Animator animator; private Rigidbody vehicleRigidbody; @@ -245,9 +245,7 @@ private void Start() if (visual != null) { var wheelVisual = wheelVisuals[i]; - Vector3 wheelPosition; - Quaternion wheelRotation; - wheel.GetWorldPose(out wheelPosition, out wheelRotation); + wheel.GetWorldPose(out var wheelPosition, out var wheelRotation); wheelVisualPositionOffsets[i] = transform.InverseTransformVector(wheelVisual.position - wheelPosition); wheelVisualLocalRotations[i] = visual.localRotation; wheelVisualAxiesRight[i] = visual.InverseTransformDirection(Vector3.Project(vehicleRight, wheelTransform.right).normalized); @@ -350,9 +348,7 @@ private void LocalUpdate() var wheel = wheels[i]; var wheelTransform = wheel.transform; - Vector3 position; - Quaternion rotation; - wheel.GetWorldPose(out position, out rotation); + wheel.GetWorldPose(out Vector3 position, out Quaternion rotation); visual.position = wheelTransform.TransformPoint(wheelTransform.InverseTransformPoint(position) + wheelVisualPositionOffsets[i]); var wheelAngle = wheelAngles[i] + (LocalIsDriver ? wheel.rpm : wheelSpeed * wheel.radius) * Time.deltaTime * (360.0f / 60.0f);