Skip to content

Commit 6f296ed

Browse files
committed
feat(Structure): add ObsoleteInspector attribute
The new `[ObsoleteInspector]` attribute is placed above public inspector parameters in place of the previous `[HideInInspector]` attribute as hidden deprecated parameters was causing confusion and this new attribute will display the parameter still but render the label in a red, italic font so it's obvious there is something different about the field. The tooltip for the parameter is also replaced by the obsolete message from the `[System.Obsolete]` attribute.
1 parent f77dcc1 commit 6f296ed

File tree

15 files changed

+74
-35
lines changed

15 files changed

+74
-35
lines changed

Assets/VRTK/Documentation/API.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@ Adds a collection of Object Tooltips to the Controller providing information to
290290
* **Controller Events:** The controller to read the controller events from. If this is blank then it will attempt to get a controller events script from the same or parent GameObject.
291291
* **Headset Controller Aware:** The headset controller aware script to use to see if the headset is looking at the controller. If this is blank then it will attempt to get a controller events script from the same or parent GameObject.
292292
* **Hide When Not In View:** If this is checked then the tooltips will be hidden when the headset is not looking at the controller.
293-
* **Retry Init Max Tries:** The total number of initialisation attempts to make when waiting for the button transforms to initialise.
294-
* **Retry Init Counter:** The amount of seconds to wait before re-attempting to initialise the controller tooltips if the button transforms have not been initialised yet.
295293

296294
### Class Events
297295

@@ -4254,7 +4252,6 @@ Determines if the GameObject can be interacted with.
42544252

42554253
* **Disable When Idle:** If this is checked then the Interactable Object component will be disabled when the Interactable Object is not being interacted with.
42564254
* **Allowed Near Touch Controllers:** Determines which controller can initiate a near touch action.
4257-
* **Touch Highlight Color:** The Color to highlight the object when it is touched.
42584255
* **Allowed Touch Controllers:** Determines which controller can initiate a touch action.
42594256
* **Ignored Colliders:** An array of colliders on the GameObject to ignore when being touched.
42604257
* **Is Grabbable:** Determines if the Interactable Object can be grabbed.

Assets/VRTK/Prefabs/ControllerTooltips/VRTK_ControllerTooltips.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,11 @@ public enum TooltipButtons
9494
[Tooltip("If this is checked then the tooltips will be hidden when the headset is not looking at the controller.")]
9595
public bool hideWhenNotInView = true;
9696

97-
[HideInInspector]
9897
[System.Obsolete("`VRTK_ControllerTooltips.retryInitMaxTries` has been deprecated as tooltip initialisation now uses the `VRTK_TrackedController.ControllerModelAvailable` event.")]
99-
[Tooltip("The total number of initialisation attempts to make when waiting for the button transforms to initialise.")]
98+
[ObsoleteInspector]
10099
public int retryInitMaxTries = 10;
101-
[HideInInspector]
102100
[System.Obsolete("`VRTK_ControllerTooltips.retryInitCounter` has been deprecated as tooltip initialisation now uses the `VRTK_TrackedController.ControllerModelAvailable` event.")]
103-
[Tooltip("The amount of seconds to wait before re-attempting to initialise the controller tooltips if the button transforms have not been initialised yet.")]
101+
[ObsoleteInspector]
104102
public float retryInitCounter = 0.1f;
105103

106104
/// <summary>

Assets/VRTK/Prefabs/SnapDropZone/VRTK_SnapDropZone.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
namespace VRTK
33
{
44
using UnityEngine;
5-
using System;
65
using System.Collections;
76
using System.Collections.Generic;
87
using Highlighters;
@@ -80,14 +79,13 @@ public enum SnapTypes
8079
[Tooltip("If this is checked then the drop zone highlight section will be displayed in the scene editor window.")]
8180
public bool displayDropZoneInEditor = true;
8281

83-
[Tooltip("The GameObject to snap into the dropzone when the drop zone is enabled. The Interactable Object must be valid in any given policy list to snap.")]
84-
[Obsolete("`VRTK_SnapDropZone.defaultSnappedObject` has been replaced with the `VRTK_SnapDropZone.defaultSnappedInteractableObject`. This parameter will be removed in a future version of VRTK.")]
85-
[HideInInspector]
86-
public GameObject defaultSnappedObject;
87-
8882
[Tooltip("The Interactable Object to snap into the dropzone when the drop zone is enabled. The Interactable Object must be valid in any given policy list to snap.")]
8983
public VRTK_InteractableObject defaultSnappedInteractableObject;
9084

85+
[System.Obsolete("`VRTK_SnapDropZone.defaultSnappedObject` has been replaced with the `VRTK_SnapDropZone.defaultSnappedInteractableObject`. This parameter will be removed in a future version of VRTK.")]
86+
[ObsoleteInspector]
87+
public GameObject defaultSnappedObject;
88+
9189
/// <summary>
9290
/// Emitted when a valid interactable object enters the snap drop zone trigger collider.
9391
/// </summary>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace VRTK
2+
{
3+
using UnityEngine;
4+
using UnityEditor;
5+
using System;
6+
7+
[CustomPropertyDrawer(typeof(ObsoleteInspectorAttribute))]
8+
class ObsoleteInspectorDrawer : PropertyDrawer
9+
{
10+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
11+
{
12+
ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(ObsoleteAttribute));
13+
EditorStyles.label.richText = true;
14+
EditorGUI.PropertyField(position, property, new GUIContent("<color=red><i>" + label.text + "</i></color>", "**OBSOLETE**\n\n" + obsoleteAttribute.Message), true);
15+
}
16+
}
17+
}

Assets/VRTK/Source/Editor/Attributes/ObsoleteInspectorDrawer.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/VRTK/Source/Scripts/Interactions/Interactables/SecondaryControllerGrabActions/VRTK_AxisScaleGrabAction.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ public class VRTK_AxisScaleGrabAction : VRTK_BaseGrabAction
2222
public float ungrabDistance = 1f;
2323
[Tooltip("Locks the specified checked axes so they won't be scaled")]
2424
public Vector3State lockAxis = Vector3State.False;
25+
[Tooltip("If checked all the axes will be scaled together (unless locked)")]
26+
public bool uniformScaling = false;
2527
[System.Obsolete("`VRTK_AxisScaleGrabAction.lockXAxis` has been replaced with the `VRTK_AxisScaleGrabAction.lockAxis`. This parameter will be removed in a future version of VRTK.")]
26-
[HideInInspector]
28+
[ObsoleteInspector]
2729
public bool lockXAxis = false;
2830
[System.Obsolete("`VRTK_AxisScaleGrabAction.lockYAxis` has been replaced with the `VRTK_AxisScaleGrabAction.lockAxis`. This parameter will be removed in a future version of VRTK.")]
29-
[HideInInspector]
31+
[ObsoleteInspector]
3032
public bool lockYAxis = false;
3133
[System.Obsolete("`VRTK_AxisScaleGrabAction.lockZAxis` has been replaced with the `VRTK_AxisScaleGrabAction.lockAxis`. This parameter will be removed in a future version of VRTK.")]
32-
[HideInInspector]
34+
[ObsoleteInspector]
3335
public bool lockZAxis = false;
34-
[Tooltip("If checked all the axes will be scaled together (unless locked)")]
35-
public bool uniformScaling = false;
3636

3737
protected Vector3 initialScale;
3838
protected float initalLength;

Assets/VRTK/Source/Scripts/Interactions/Interactables/VRTK_InteractableObject.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,17 @@ public enum ValidDropTypes
155155
[Tooltip("Determines which controller can initiate a near touch action.")]
156156
public AllowedController allowedNearTouchControllers = AllowedController.Both;
157157

158-
[System.Obsolete("`VRTK_InteractableObject.touchHighlightColor` has been replaced with `VRTK_InteractObjectHighlighter.touchHighlight`. This parameter will be removed in a future version of VRTK.")]
159-
[Tooltip("The Color to highlight the object when it is touched.")]
160-
[HideInInspector]
161-
public Color touchHighlightColor = Color.clear;
162-
163158
[Header("Touch Settings")]
164159

165160
[Tooltip("Determines which controller can initiate a touch action.")]
166161
public AllowedController allowedTouchControllers = AllowedController.Both;
167162
[Tooltip("An array of colliders on the GameObject to ignore when being touched.")]
168163
public Collider[] ignoredColliders;
169164

165+
[System.Obsolete("`VRTK_InteractableObject.touchHighlightColor` has been replaced with `VRTK_InteractObjectHighlighter.touchHighlight`. This parameter will be removed in a future version of VRTK.")]
166+
[ObsoleteInspector]
167+
public Color touchHighlightColor = Color.clear;
168+
170169
[Header("Grab Settings")]
171170

172171
[Tooltip("Determines if the Interactable Object can be grabbed.")]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace VRTK
2+
{
3+
using UnityEngine;
4+
public class ObsoleteInspectorAttribute : PropertyAttribute
5+
{
6+
}
7+
}

Assets/VRTK/Source/Scripts/Internal/Attributes/ObsoleteInspectorAttribute.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/VRTK/Source/Scripts/Locomotion/VRTK_BasicTeleport.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ namespace VRTK
33
{
44
using UnityEngine;
55
using System.Collections;
6-
using System;
76
#if UNITY_5_5_OR_NEWER
87
using UnityEngine.AI;
98
#endif
@@ -49,8 +48,8 @@ public class VRTK_BasicTeleport : MonoBehaviour
4948
[Tooltip("An optional NavMeshData object that will be utilised for limiting the teleport to within any scene NavMesh.")]
5049
public VRTK_NavMeshData navMeshData;
5150

52-
[HideInInspector]
53-
[Obsolete("`VRTK_BasicTeleport.navMeshLimitDistance` is no longer used, use `VRTK_BasicTeleport.processNavMesh` instead. This parameter will be removed in a future version of VRTK.")]
51+
[System.Obsolete("`VRTK_BasicTeleport.navMeshLimitDistance` is no longer used, use `VRTK_BasicTeleport.processNavMesh` instead. This parameter will be removed in a future version of VRTK.")]
52+
[ObsoleteInspector]
5453
public float navMeshLimitDistance = 0f;
5554

5655
/// <summary>

0 commit comments

Comments
 (0)