Skip to content

Commit

Permalink
fix(SDK): run controller init code using Awake
Browse files Browse the repository at this point in the history
The `Awake()` method is supported in the ScriptableObject so it's
more appropriate to use this and `[RuntimeInitializeOnLoadMethod]`
only works on static methods meaning the `Initialise()` method was
never being run.

The Oculus SDK doesn't need an Awake method as the controllers
are not ready to be cached at that time anyway and the cache setup
will be run the first time they are called, which is a more
appropriate time to set the cache up as the other dependencies will
be available.
  • Loading branch information
thestonefox committed Jan 12, 2017
1 parent 4bf52b0 commit cbc397a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
6 changes: 0 additions & 6 deletions Assets/VRTK/SDK/OculusVR/SDK_OculusVRController.cs
Expand Up @@ -810,12 +810,6 @@ public override bool IsButtonTwoTouchedUpOnIndex(uint index)
return IsButtonPressed(index, ButtonPressTypes.TouchUp, OVRInput.Touch.Two);
}

[RuntimeInitializeOnLoadMethod]
private void Initialise()
{
SetTrackedControllerCaches(true);
}

private void SetTrackedControllerCaches(bool forceRefresh = false)
{
if (forceRefresh)
Expand Down
3 changes: 1 addition & 2 deletions Assets/VRTK/SDK/SteamVR/SDK_SteamVRController.cs
Expand Up @@ -728,8 +728,7 @@ public override bool IsButtonTwoTouchedUpOnIndex(uint index)
return false;
}

[RuntimeInitializeOnLoadMethod]
private void Initialise()
private void Awake()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type eventClass = executingAssembly.GetType("SteamVR_Utils").GetNestedType("Event");
Expand Down

0 comments on commit cbc397a

Please sign in to comment.