OculusSampleFrameworkUtil.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /************************************************************************************
  2. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
  4. the Utilities SDK except in compliance with the License, which is provided at the time of installation
  5. or download, or which otherwise accompanies this software in either electronic or hard copy form.
  6. You may obtain a copy of the License at
  7. https://developer.oculus.com/licenses/utilities-1.31
  8. Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
  9. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  10. ANY KIND, either express or implied. See the License for the specific language governing
  11. permissions and limitations under the License.
  12. ************************************************************************************/
  13. #if UNITY_EDITOR
  14. using UnityEditor;
  15. [InitializeOnLoadAttribute]
  16. public class OculusSampleFrameworkUtil
  17. {
  18. static OculusSampleFrameworkUtil()
  19. {
  20. #if UNITY_2017_2_OR_NEWER
  21. EditorApplication.playModeStateChanged += HandlePlayModeState;
  22. #else
  23. EditorApplication.playmodeStateChanged += () =>
  24. {
  25. if (EditorApplication.isPlaying)
  26. {
  27. OVRPlugin.SendEvent("load", OVRPlugin.wrapperVersion.ToString(), "sample_framework");
  28. }
  29. };
  30. #endif
  31. }
  32. #if UNITY_2017_2_OR_NEWER
  33. private static void HandlePlayModeState(PlayModeStateChange state)
  34. {
  35. if (state == PlayModeStateChange.EnteredPlayMode)
  36. {
  37. OVRPlugin.SendEvent("load", OVRPlugin.wrapperVersion.ToString(), "sample_framework");
  38. }
  39. }
  40. #endif
  41. }
  42. #endif