BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / VR / Scripts / Util / OVRModeParms.cs

OVRModeParms.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
OVRModeParms.cs 2.5 KiB Download Raw
1/************************************************************************************
2Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
3
4Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
5the Utilities SDK except in compliance with the License, which is provided at the time of installation
6or download, or which otherwise accompanies this software in either electronic or hard copy form.
7
8You may obtain a copy of the License at
9https://developer.oculus.com/licenses/utilities-1.31
10
11Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
12under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13ANY KIND, either express or implied. See the License for the specific language governing
14permissions and limitations under the License.
15************************************************************************************/
16
17using UnityEngine;
18
19/// <summary>
20/// Logs when the application enters power save mode and allows you to a low-power CPU/GPU level with a button press.
21/// </summary>
22public class OVRModeParms : MonoBehaviour
23{
24#region Member Variables
25
26 /// <summary>
27 /// The gamepad button that will switch the application to CPU level 0 and GPU level 1.
28 /// </summary>
29 public OVRInput.RawButton resetButton = OVRInput.RawButton.X;
30
31#endregion
32
33 /// <summary>
34 /// Invoke power state mode test.
35 /// </summary>
36 void Start()
37 {
38 if (!OVRManager.isHmdPresent)
39 {
40 enabled = false;
41 return;
42 }
43
44 // Call TestPowerLevelState after 10 seconds
45 // and repeats every 10 seconds.
46 InvokeRepeating ( "TestPowerStateMode", 10, 10.0f );
47 }
48
49 /// <summary>
50 /// Change default vr mode parms dynamically.
51 /// </summary>
52 void Update()
53 {
54 // NOTE: some of the buttons defined in OVRInput.RawButton are not available on the Android game pad controller
55 if ( OVRInput.GetDown(resetButton))
56 {
57 //*************************
58 // Dynamically change VrModeParms cpu and gpu level.
59 // NOTE: Reset will cause 1 frame of flicker as it leaves
60 // and re-enters Vr mode.
61 //*************************
62 OVRPlugin.cpuLevel = 0;
63 OVRPlugin.gpuLevel = 1;
64 }
65 }
66
67 /// <summary>
68 /// Check current power state mode.
69 /// </summary>
70 void TestPowerStateMode()
71 {
72 //*************************
73 // Check power-level state mode
74 //*************************
75 if (OVRPlugin.powerSaving)
76 {
77 // The device has been throttled
78 Debug.Log("POWER SAVE MODE ACTIVATED");
79 }
80 }
81}