fr.jeanf.universal.player 0.8.44 → 0.8.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.vrplayer
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Detects and logs missing references in MonoBehaviour components using reflection.
|
|
9
|
+
/// Attach this to any GameObject to check its hierarchy for missing references.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class MissingReferenceDetector : MonoBehaviour
|
|
12
|
+
{
|
|
13
|
+
[Header("Detection Settings")]
|
|
14
|
+
[Tooltip("Check this GameObject and all its children")]
|
|
15
|
+
[SerializeField] private bool checkChildren = true;
|
|
16
|
+
|
|
17
|
+
[Tooltip("Log even if no missing references are found")]
|
|
18
|
+
[SerializeField] private bool verboseLogging = true;
|
|
19
|
+
|
|
20
|
+
[Tooltip("Run check on Start")]
|
|
21
|
+
[SerializeField] private bool checkOnStart = true;
|
|
22
|
+
|
|
23
|
+
private void Start()
|
|
24
|
+
{
|
|
25
|
+
if (checkOnStart)
|
|
26
|
+
{
|
|
27
|
+
CheckForMissingReferences();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[ContextMenu("Check For Missing References")]
|
|
32
|
+
public void CheckForMissingReferences()
|
|
33
|
+
{
|
|
34
|
+
int missingCount = 0;
|
|
35
|
+
List<string> missingReferencesList = new List<string>();
|
|
36
|
+
|
|
37
|
+
Transform[] transforms = checkChildren ? GetComponentsInChildren<Transform>(true) : new Transform[] { transform };
|
|
38
|
+
|
|
39
|
+
Debug.Log($"<color=cyan>Starting missing reference check on: <b>{gameObject.name}</b></color>");
|
|
40
|
+
|
|
41
|
+
foreach (Transform t in transforms)
|
|
42
|
+
{
|
|
43
|
+
MonoBehaviour[] components = t.GetComponents<MonoBehaviour>();
|
|
44
|
+
|
|
45
|
+
foreach (MonoBehaviour component in components)
|
|
46
|
+
{
|
|
47
|
+
if (component == null)
|
|
48
|
+
{
|
|
49
|
+
string msg = $"[MISSING SCRIPT] on GameObject: {t.name}";
|
|
50
|
+
Debug.LogError(msg, t.gameObject);
|
|
51
|
+
missingReferencesList.Add(msg);
|
|
52
|
+
missingCount++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Use reflection to check all serialized fields
|
|
57
|
+
FieldInfo[] fields = component.GetType().GetFields(
|
|
58
|
+
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
|
59
|
+
|
|
60
|
+
foreach (FieldInfo field in fields)
|
|
61
|
+
{
|
|
62
|
+
// Check if field is serialized
|
|
63
|
+
if (!field.IsPublic && field.GetCustomAttribute<SerializeField>() == null)
|
|
64
|
+
continue;
|
|
65
|
+
|
|
66
|
+
// Check if it's a Unity Object reference type
|
|
67
|
+
if (!typeof(Object).IsAssignableFrom(field.FieldType))
|
|
68
|
+
continue;
|
|
69
|
+
|
|
70
|
+
// Get the field value
|
|
71
|
+
object fieldValue = field.GetValue(component);
|
|
72
|
+
|
|
73
|
+
// Check if it's null
|
|
74
|
+
if (fieldValue == null || fieldValue.Equals(null))
|
|
75
|
+
{
|
|
76
|
+
// Try to determine if this should be assigned (not just optional)
|
|
77
|
+
// We'll log it and let the user decide
|
|
78
|
+
string msg = $"[NULL REFERENCE] GameObject: {t.name} | " +
|
|
79
|
+
$"Component: {component.GetType().Name} | " +
|
|
80
|
+
$"Field: {field.Name} (Type: {field.FieldType.Name})";
|
|
81
|
+
Debug.LogWarning(msg, t.gameObject);
|
|
82
|
+
missingReferencesList.Add(msg);
|
|
83
|
+
missingCount++;
|
|
84
|
+
}
|
|
85
|
+
// Special check for destroyed Unity objects
|
|
86
|
+
else if (fieldValue is Object unityObj && unityObj == null)
|
|
87
|
+
{
|
|
88
|
+
string msg = $"[DESTROYED REFERENCE] GameObject: {t.name} | " +
|
|
89
|
+
$"Component: {component.GetType().Name} | " +
|
|
90
|
+
$"Field: {field.Name}";
|
|
91
|
+
Debug.LogError(msg, t.gameObject);
|
|
92
|
+
missingReferencesList.Add(msg);
|
|
93
|
+
missingCount++;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Summary
|
|
100
|
+
if (missingCount > 0)
|
|
101
|
+
{
|
|
102
|
+
Debug.LogError($"MISSING/NULL REFERENCES DETECTED: {missingCount} issues found on {gameObject.name}\n" +
|
|
103
|
+
"Check console for details.", gameObject);
|
|
104
|
+
}
|
|
105
|
+
else if (verboseLogging)
|
|
106
|
+
{
|
|
107
|
+
Debug.Log($"<color=green>No missing references found in {gameObject.name} hierarchy</color>", gameObject);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -53,10 +53,7 @@ namespace jeanf.universalplayer
|
|
|
53
53
|
{
|
|
54
54
|
nonPhysicalHand.SetActive(false);
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
void FixedUpdate()
|
|
58
|
-
{
|
|
59
|
-
rb.linearVelocity = (target.position - transform.position)/Time.fixedDeltaTime;
|
|
56
|
+
rb.linearVelocity = (target.position - transform.position)/Time.deltaTime;
|
|
60
57
|
|
|
61
58
|
|
|
62
59
|
Quaternion rotationDifference = target.rotation * Quaternion.Inverse(transform.rotation*offset);
|
|
@@ -67,6 +64,7 @@ namespace jeanf.universalplayer
|
|
|
67
64
|
rb.angularVelocity = (rotationDifferenceInDegree * Mathf.Deg2Rad/Time.deltaTime);
|
|
68
65
|
}
|
|
69
66
|
|
|
67
|
+
|
|
70
68
|
private void CheckXRStatus()
|
|
71
69
|
{
|
|
72
70
|
if (BroadcastControlsStatus.controlScheme == BroadcastControlsStatus.ControlScheme.XR)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fr.jeanf.universal.player",
|
|
3
3
|
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.46",
|
|
5
5
|
|
|
6
6
|
"displayName": "Universal Player",
|
|
7
7
|
"description": "This package contains a universal player working in URP & HDRP for Mouse+Keyboard or VR",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"com.unity.modules.vr": "1.0.0",
|
|
23
23
|
"com.unity.modules.xr": "1.0.0",
|
|
24
|
-
"com.unity.inputsystem": "1.
|
|
25
|
-
"com.unity.vectorgraphics": "2.0.0-preview.
|
|
26
|
-
"com.unity.xr.openxr": "1.
|
|
27
|
-
"com.unity.xr.interaction.toolkit": "
|
|
28
|
-
"com.unity.xr.hands": "1.1
|
|
29
|
-
"com.unity.xr.management": "4.
|
|
30
|
-
"com.unity.xr.oculus": "
|
|
31
|
-
"fr.jeanf.eventsystem": "0.1.
|
|
24
|
+
"com.unity.inputsystem": "1.14.2",
|
|
25
|
+
"com.unity.vectorgraphics": "2.0.0-preview.25",
|
|
26
|
+
"com.unity.xr.openxr": "1.15.1",
|
|
27
|
+
"com.unity.xr.interaction.toolkit": "3.0.9",
|
|
28
|
+
"com.unity.xr.hands": "1.5.1",
|
|
29
|
+
"com.unity.xr.management": "4.5.3",
|
|
30
|
+
"com.unity.xr.oculus": "4.5.2",
|
|
31
|
+
"fr.jeanf.eventsystem": "0.1.124",
|
|
32
32
|
"fr.jeanf.propertydrawer": "1.1.6",
|
|
33
33
|
"fr.jeanf.tooltipsystem": "0.0.7"
|
|
34
34
|
},
|