Updated oculus stuff
This commit is contained in:
141
Assets/Oculus/LipSync/Editor/OVRLipSyncTool.cs
Normal file
141
Assets/Oculus/LipSync/Editor/OVRLipSyncTool.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
/************************************************************************************
|
||||
Filename : OVRLipSyncTool.cs
|
||||
Content : Editor tool for generating lip sync assets
|
||||
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;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
class OVRLipSyncToolLoader
|
||||
{
|
||||
public static List<AudioClip> clipQueue;
|
||||
public static IEnumerator processor;
|
||||
|
||||
// To show progress we use the total seconds of clip
|
||||
public static float totalLengthOfClips;
|
||||
public static float totalLengthOfClipsProcessed;
|
||||
|
||||
public static IEnumerator ProcessClips()
|
||||
{
|
||||
if (clipQueue == null || clipQueue.Count == 0)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (clipQueue.Count > 0)
|
||||
{
|
||||
// Pop a clip off the list
|
||||
AudioClip clip = clipQueue[0];
|
||||
clipQueue.RemoveAt(0);
|
||||
|
||||
if (clip.loadType != AudioClipLoadType.DecompressOnLoad)
|
||||
{
|
||||
Debug.LogError(clip.name +
|
||||
": Cannot process phonemes from an audio clip unless " +
|
||||
"its load type is set to DecompressOnLoad.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update progress
|
||||
if (totalLengthOfClips > 0.0f)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Generating Lip Sync Assets...", "Processing clip " + clip.name + "...",
|
||||
totalLengthOfClipsProcessed / totalLengthOfClips);
|
||||
}
|
||||
|
||||
if (!clip.preloadAudioData)
|
||||
{
|
||||
clip.LoadAudioData();
|
||||
|
||||
Debug.LogWarning(clip.name +
|
||||
": Audio data is not pre-loaded. Data will be loaded then" +
|
||||
"unloaded on completion.");
|
||||
|
||||
while (clip.loadState != AudioDataLoadState.Loaded)
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
OVRLipSyncSequence sequence = OVRLipSyncSequence.CreateSequenceFromAudioClip(clip);
|
||||
if (sequence != null)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(clip);
|
||||
string newPath = path.Replace(Path.GetExtension(path), "_lipSync.asset");
|
||||
AssetDatabase.CreateAsset(sequence, newPath);
|
||||
AssetDatabase.ImportAsset(newPath);
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
if (!clip.preloadAudioData)
|
||||
{
|
||||
clip.UnloadAudioData();
|
||||
}
|
||||
|
||||
totalLengthOfClipsProcessed += clip.length;
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
static OVRLipSyncToolLoader()
|
||||
{
|
||||
processor = ProcessClips();
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
static void Update()
|
||||
{
|
||||
processor.MoveNext();
|
||||
}
|
||||
}
|
||||
|
||||
class OVRLipSyncTool
|
||||
{
|
||||
[MenuItem("Tools/Oculus/Generate Lip Sync Assets", false, 2000000)]
|
||||
static void GenerateLipSyncAssets()
|
||||
{
|
||||
|
||||
if (OVRLipSyncToolLoader.clipQueue == null)
|
||||
{
|
||||
OVRLipSyncToolLoader.clipQueue = new List<AudioClip>();
|
||||
}
|
||||
|
||||
OVRLipSyncToolLoader.totalLengthOfClips = 0.0f;
|
||||
OVRLipSyncToolLoader.totalLengthOfClipsProcessed = 0.0f;
|
||||
|
||||
for (int i = 0; i < Selection.objects.Length; ++i)
|
||||
{
|
||||
Object obj = Selection.objects[i];
|
||||
if (obj is AudioClip)
|
||||
{
|
||||
AudioClip clip = (AudioClip)obj;
|
||||
|
||||
OVRLipSyncToolLoader.clipQueue.Add(clip);
|
||||
|
||||
OVRLipSyncToolLoader.totalLengthOfClips += clip.length;
|
||||
}
|
||||
}
|
||||
|
||||
OVRLipSyncToolLoader.processor = OVRLipSyncToolLoader.ProcessClips();
|
||||
}
|
||||
}
|
||||
12
Assets/Oculus/LipSync/Editor/OVRLipSyncTool.cs.meta
Normal file
12
Assets/Oculus/LipSync/Editor/OVRLipSyncTool.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08b0ff764adc142d79bfae7dd917cc16
|
||||
timeCreated: 1491977874
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Oculus/LipSync/Editor/OVRNamedArrayPropertyDrawer.cs
Normal file
38
Assets/Oculus/LipSync/Editor/OVRNamedArrayPropertyDrawer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/************************************************************************************
|
||||
Filename : OVRNamedArrayPropertyDrawer.cs
|
||||
Content : Adds a custom named array drawer to the Unity 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;
|
||||
using UnityEditor;
|
||||
|
||||
// Adds a custom named array drawer to the Unity editor
|
||||
[CustomPropertyDrawer( typeof(OVRNamedArrayAttribute) )]
|
||||
public class OVRNamedArrayPropertyDrawer : PropertyDrawer {
|
||||
public override void OnGUI( Rect rect, SerializedProperty property, GUIContent label ) {
|
||||
try {
|
||||
int pos = int.Parse(property.propertyPath.Split('[', ']')[1]);
|
||||
EditorGUI.PropertyField( rect, property,
|
||||
new GUIContent( ( (OVRNamedArrayAttribute)attribute ).names[pos] ) );
|
||||
} catch {
|
||||
EditorGUI.PropertyField( rect, property, label );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2d166626e0b34a40b774467cc6c5868
|
||||
timeCreated: 1534993516
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user