Updated oculus stuff

This commit is contained in:
Chris Midkiff
2018-10-09 20:59:57 -04:00
parent 1e7362c19f
commit 9b7f63739e
957 changed files with 128988 additions and 588 deletions

View File

@@ -0,0 +1,224 @@
/************************************************************************************
Filename : OVRLipSyncDebugConsole.cs
Content : Write to a text string, used by UI.Text
Created : May 22, 2015
Copyright : Copyright Facebook Technologies, LLC and its affiliates.
All rights reserved.
Licensed under the Oculus Audio SDK License Version 3.3 (the "License");
you may not use the Oculus Audio SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
https://developer.oculus.com/licenses/audio-3.3/
Unless required by applicable law or agreed to in writing, the Oculus Audio SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
************************************************************************************/
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class OVRLipSyncDebugConsole : MonoBehaviour
{
public ArrayList messages = new ArrayList();
public int maxMessages = 15; // The max number of messages displayed
public Text textMsg; // text string to display
// Our instance to allow this script to be called without a direct connection.
private static OVRLipSyncDebugConsole s_Instance = null;
// Clear timeout
private bool clearTimeoutOn = false;
private float clearTimeout = 0.0f;
/// <summary>
/// Gets the instance.
/// </summary>
/// <value>The instance.</value>
public static OVRLipSyncDebugConsole instance
{
get
{
if (s_Instance == null)
{
s_Instance = FindObjectOfType(typeof(OVRLipSyncDebugConsole)) as OVRLipSyncDebugConsole;
if (s_Instance == null)
{
GameObject console = new GameObject();
console.AddComponent<OVRLipSyncDebugConsole>();
console.name = "OVRLipSyncDebugConsole";
s_Instance = FindObjectOfType(typeof(OVRLipSyncDebugConsole)) as OVRLipSyncDebugConsole;
}
}
return s_Instance;
}
}
/// <summary>
/// Awake this instance.
/// </summary>
void Awake()
{
s_Instance = this;
Init();
}
/// <summary>
/// Update this instance.
/// </summary>
void Update()
{
if(clearTimeoutOn == true)
{
clearTimeout -= Time.deltaTime;
if(clearTimeout < 0.0f)
{
Clear();
clearTimeout = 0.0f;
clearTimeoutOn = false;
}
}
}
/// <summary>
/// Init this instance.
/// </summary>
public void Init()
{
if(textMsg == null)
{
Debug.LogWarning("DebugConsole Init WARNING::UI text not set. Will not be able to display anything.");
}
Clear();
}
//+++++++++ INTERFACE FUNCTIONS ++++++++++++++++++++++++++++++++
/// <summary>
/// Log the specified message.
/// </summary>
/// <param name="message">Message.</param>
public static void Log(string message)
{
OVRLipSyncDebugConsole.instance.AddMessage(message, Color.white);
}
/// <summary>
/// Log the specified message and color.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="color">Color.</param>
public static void Log(string message, Color color)
{
OVRLipSyncDebugConsole.instance.AddMessage(message, color);
}
/// <summary>
/// Clear this instance.
/// </summary>
public static void Clear()
{
OVRLipSyncDebugConsole.instance.ClearMessages();
}
/// <summary>
/// Calls clear after a certain time.
/// </summary>
/// <param name="timeToClear">Time to clear.</param>
public static void ClearTimeout(float timeToClear)
{
OVRLipSyncDebugConsole.instance.SetClearTimeout(timeToClear);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/// <summary>
/// Adds the message.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="color">Color.</param>
public void AddMessage(string message, Color color)
{
messages.Add(message);
if(textMsg != null)
textMsg.color = color;
Display();
}
/// <summary>
/// Clears the messages.
/// </summary>
public void ClearMessages()
{
messages.Clear();
Display();
}
/// <summary>
/// Sets the clear timeout.
/// </summary>
/// <param name="timeout">Timeout.</param>
public void SetClearTimeout(float timeout)
{
clearTimeout = timeout;
clearTimeoutOn = true;
}
/// <summary>
// Prunes the array to fit within the maxMessages limit
/// </summary>
void Prune()
{
int diff;
if (messages.Count > maxMessages)
{
if (messages.Count <= 0)
{
diff = 0;
}
else
{
diff = messages.Count - maxMessages;
}
messages.RemoveRange(0, (int)diff);
}
}
/// <summary>
/// Display this instance.
/// </summary>
void Display()
{
if (messages.Count > maxMessages)
{
Prune();
}
if(textMsg != null)
{
textMsg.text = ""; // Clear text out
int x = 0;
while (x < messages.Count)
{
textMsg.text += (string)messages[x];
textMsg.text +='\n';
x += 1;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c60ad94815c68aa41a786306cd588495
timeCreated: 1439845885
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
/************************************************************************************
Filename : OVRNamedArrayAttribute.cs
Content : Adds support for a named array attribute in the editor
Created : May 17th, 2018
Copyright : Copyright Facebook Technologies, LLC and its affiliates.
All rights reserved.
Licensed under the Oculus Audio SDK License Version 3.3 (the "License");
you may not use the Oculus Audio SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
https://developer.oculus.com/licenses/audio-3.3/
Unless required by applicable law or agreed to in writing, the Oculus Audio SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
************************************************************************************/
using UnityEngine;
// Adds support for a named array attribute in the editor
public class OVRNamedArrayAttribute : PropertyAttribute {
public readonly string[] names;
public OVRNamedArrayAttribute( string[] names ) { this.names = names; }
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7537accd8e2c6024c860b20e3e7e3424
timeCreated: 1534993516
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,201 @@
/************************************************************************************
Filename : OVRTouchpad.cs
Content : Interface to touchpad
Created : November 13, 2013
Copyright : Copyright Facebook Technologies, LLC and its affiliates.
All rights reserved.
Licensed under the Oculus Audio SDK License Version 3.3 (the "License");
you may not use the Oculus Audio SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
https://developer.oculus.com/licenses/audio-3.3/
Unless required by applicable law or agreed to in writing, the Oculus Audio SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
************************************************************************************/
using UnityEngine;
using System;
//-------------------------------------------------------------------------------------
// ***** OVRTouchpad
//
// OVRTouchpad is an interface class to a touchpad.
//
public static class OVRTouchpad
{
//-------------------------
// Input enums
public enum TouchEvent { SingleTap, DoubleTap, Left, Right, Up, Down };
// mouse
static Vector3 moveAmountMouse;
static float minMovMagnitudeMouse = 25.0f;
public delegate void OVRTouchpadCallback<TouchEvent>(TouchEvent arg);
static public Delegate touchPadCallbacks = null;
//Disable the unused variable warning
#pragma warning disable 0414
//Ensures that the TouchpadHelper will be created automatically upon start of the game.
static private OVRTouchpadHelper touchpadHelper =
( new GameObject("OVRTouchpadHelper") ).AddComponent< OVRTouchpadHelper >();
#pragma warning restore 0414
// We will call this to create the TouchpadHelper class. This will
// add the Touchpad game object into the world and we can call into
// TouchEvent static functions to hook delegates into for touch capture
static public void Create()
{
// Does nothing but call constructor to add game object into scene
}
// Update
static public void Update()
{
// MOUSE INPUT
if(Input.GetMouseButtonDown(0))
{
moveAmountMouse = Input.mousePosition;
}
else if(Input.GetMouseButtonUp(0))
{
moveAmountMouse -= Input.mousePosition;
HandleInputMouse(ref moveAmountMouse);
}
}
// OnDisable
static public void OnDisable()
{
}
// HandleInputMouse
static void HandleInputMouse(ref Vector3 move)
{
if (touchPadCallbacks == null)
{
return;
}
OVRTouchpadCallback<TouchEvent> callback = touchPadCallbacks as OVRTouchpadCallback<TouchEvent>;
if ( move.magnitude < minMovMagnitudeMouse)
{
callback(TouchEvent.SingleTap);
}
else
{
move.Normalize();
// Left/Right
if (Mathf.Abs(move.x) > Mathf.Abs(move.y))
{
if (move.x > 0.0f)
callback(TouchEvent.Left);
else
callback(TouchEvent.Right);
}
// Up/Down
else
{
if (move.y > 0.0f)
callback(TouchEvent.Down);
else
callback(TouchEvent.Up);
}
}
}
static public void AddListener(OVRTouchpadCallback<TouchEvent> handler)
{
touchPadCallbacks = (OVRTouchpadCallback<TouchEvent>)touchPadCallbacks + handler;
}
}
//-------------------------------------------------------------------------------------
// ***** OVRTouchpadHelper
//
// This singleton class gets created and stays resident in the application. It is used to
// trap the touchpad values, which get broadcast to any listener on the "Touchpad" channel.
//
// This class also demontrates how to make calls from any class that needs these events by
// setting up a listener to "Touchpad" channel.
public sealed class OVRTouchpadHelper : MonoBehaviour
{
void Awake ()
{
DontDestroyOnLoad(gameObject);
}
void Start ()
{
// Add a listener to the OVRTouchpad for testing
OVRTouchpad.AddListener(LocalTouchEventCallback);
}
void Update ()
{
OVRTouchpad.Update();
}
public void OnDisable()
{
OVRTouchpad.OnDisable();
}
// LocalTouchEventCallback
void LocalTouchEventCallback(OVRTouchpad.TouchEvent touchEvent)
{
switch(touchEvent)
{
case(OVRTouchpad.TouchEvent.SingleTap):
// OVRLipSyncDebugConsole.Clear();
// OVRLipSyncDebugConsole.ClearTimeout(1.5f);
// OVRLipSyncDebugConsole.Log("TP-SINGLE TAP");
break;
case(OVRTouchpad.TouchEvent.DoubleTap):
// OVRLipSyncDebugConsole.Clear();
// OVRLipSyncDebugConsole.ClearTimeout(1.5f);
// OVRLipSyncDebugConsole.Log("TP-DOUBLE TAP");
break;
case(OVRTouchpad.TouchEvent.Left):
// OVRLipSyncDebugConsole.Clear();
// OVRLipSyncDebugConsole.ClearTimeout(1.5f);
// OVRLipSyncDebugConsole.Log("TP-SWIPE LEFT");
break;
case(OVRTouchpad.TouchEvent.Right):
// OVRLipSyncDebugConsole.Clear();
// OVRLipSyncDebugConsole.ClearTimeout(1.5f);
// OVRLipSyncDebugConsole.Log("TP-SWIPE RIGHT");
break;
case(OVRTouchpad.TouchEvent.Up):
// OVRLipSyncDebugConsole.Clear();
// OVRLipSyncDebugConsole.ClearTimeout(1.5f);
// OVRLipSyncDebugConsole.Log("TP-SWIPE UP");
break;
case(OVRTouchpad.TouchEvent.Down):
// OVRLipSyncDebugConsole.Clear();
// OVRLipSyncDebugConsole.ClearTimeout(1.5f);
// OVRLipSyncDebugConsole.Log("TP-SWIPE DOWN");
break;
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: edde1cb2a78471f409fce5084e6c720c
timeCreated: 1528830158
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: