Initialer Upload neues Unity-Projekt
This commit is contained in:
99
Assets/Oculus/LipSync/Editor/OVRLipSyncBuildPostProcessor.cs
Normal file
99
Assets/Oculus/LipSync/Editor/OVRLipSyncBuildPostProcessor.cs
Normal file
@ -0,0 +1,99 @@
|
||||
/************************************************************************************
|
||||
Filename : OVRLipSyncBuildPostProcessor.cs
|
||||
Content : Editor extension to generate LipSync-powered iOS apps
|
||||
Created : Feb 11th, 2019
|
||||
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.
|
||||
************************************************************************************/
|
||||
#if UNITY_IOS
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
class OVRLipSyncBuildPostProcessor : MonoBehaviour
|
||||
{
|
||||
[PostProcessBuildAttribute(1)]
|
||||
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target == BuildTarget.iOS)
|
||||
{
|
||||
AddMicrophoneAccess(Path.Combine(pathToBuiltProject, "Info.plist"));
|
||||
AddEmbeddedBinary(PBXProject.GetPBXProjectPath(pathToBuiltProject));
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddMicrophoneAccess(string infoPlistPath)
|
||||
{
|
||||
const string micUsageProperty = "NSMicrophoneUsageDescription";
|
||||
|
||||
var plist = new PlistDocument();
|
||||
plist.ReadFromFile(infoPlistPath);
|
||||
var rootDict = plist.root.AsDict();
|
||||
// Don't override the description other might have edited already
|
||||
if (rootDict.values.ContainsKey(micUsageProperty))
|
||||
{
|
||||
return;
|
||||
}
|
||||
rootDict.SetString(micUsageProperty, "To lipsync you");
|
||||
plist.WriteToFile(infoPlistPath);
|
||||
}
|
||||
|
||||
private static void AddEmbeddedBinary(string projectPath)
|
||||
{
|
||||
const string buildPhaseName = "Embed Libraries";
|
||||
const string dylibName = "libOVRLipSync.dylib";
|
||||
|
||||
var project = new PBXProject();
|
||||
project.ReadFromFile(projectPath);
|
||||
|
||||
// Don't add the same library twice
|
||||
if (project.FindFileGuidByProjectPath(dylibName) != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var targetGUID = project.TargetGuidByName(PBXProject.GetUnityTargetName());
|
||||
// Limit the target to ARM64
|
||||
project.SetBuildProperty(targetGUID, "ARCHS", "arm64");
|
||||
|
||||
// Add dylib to the project
|
||||
var dylibGUID = project.AddFile(
|
||||
Path.Combine(Application.dataPath, "Oculus/LipSync/Plugins/iOS/" + dylibName),
|
||||
dylibName);
|
||||
// Copy it to the same folder as executable
|
||||
var embedPhaseGuid = project.AddCopyFilesBuildPhase(targetGUID, buildPhaseName, "", "6");
|
||||
project.AddFileToBuildSection(targetGUID, embedPhaseGuid, dylibGUID);
|
||||
var content = project.WriteToString();
|
||||
|
||||
// Add CodeSignOnCopy attribute ot the library using an ugly regex
|
||||
content = Regex.Replace(content,
|
||||
"(?<="+ buildPhaseName + ")(?:.*)(\\/\\* " + Regex.Escape(dylibName) + " \\*\\/)(?=; };)",
|
||||
m => m.Value.Replace(
|
||||
"/* " + dylibName + " */",
|
||||
"/* " + dylibName + " */; settings = {ATTRIBUTES = (CodeSignOnCopy, );}"
|
||||
)
|
||||
);
|
||||
File.WriteAllText(projectPath, content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73f38d977e4ed45f48b632a00fb9c579
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,125 @@
|
||||
/************************************************************************************
|
||||
Filename : OVRLipSyncContextMorphTargetEditor.cs
|
||||
Content : This bridges the viseme output to the morph targets
|
||||
Created : December 21st, 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;
|
||||
|
||||
[CustomEditor(typeof(OVRLipSyncContextMorphTarget))]
|
||||
public class OVRLipSyncContextMorphTargetEditor : Editor
|
||||
{
|
||||
SerializedProperty skinnedMeshRenderer;
|
||||
SerializedProperty visemeToBlendTargets;
|
||||
SerializedProperty visemeTestKeys;
|
||||
SerializedProperty laughterKey;
|
||||
SerializedProperty laughterBlendTarget;
|
||||
SerializedProperty laughterThreshold;
|
||||
SerializedProperty laughterMultiplier;
|
||||
SerializedProperty smoothAmounth;
|
||||
private static string[] visemeNames = new string[] {
|
||||
"sil", "PP", "FF", "TH",
|
||||
"DD", "kk", "CH", "SS",
|
||||
"nn", "RR", "aa", "E",
|
||||
"ih", "oh", "ou" };
|
||||
void OnEnable()
|
||||
{
|
||||
skinnedMeshRenderer = serializedObject.FindProperty("skinnedMeshRenderer");
|
||||
visemeToBlendTargets = serializedObject.FindProperty("visemeToBlendTargets");
|
||||
visemeTestKeys = serializedObject.FindProperty("visemeTestKeys");
|
||||
laughterKey = serializedObject.FindProperty("laughterKey");
|
||||
laughterBlendTarget = serializedObject.FindProperty("laughterBlendTarget");
|
||||
laughterThreshold = serializedObject.FindProperty("laughterThreshold");
|
||||
laughterMultiplier = serializedObject.FindProperty("laughterMultiplier");
|
||||
smoothAmounth = serializedObject.FindProperty("smoothAmount");
|
||||
}
|
||||
|
||||
private void BlendNameProperty(SerializedProperty prop, string name, string[] blendNames = null)
|
||||
{
|
||||
if (blendNames == null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(prop, new GUIContent(name));
|
||||
return;
|
||||
}
|
||||
var values = new int[blendNames.Length + 1];
|
||||
var options = new GUIContent[blendNames.Length + 1];
|
||||
values[0] = -1;
|
||||
options[0] = new GUIContent(" ");
|
||||
for(int i = 0; i < blendNames.Length; ++i)
|
||||
{
|
||||
values[i + 1] = i;
|
||||
options[i + 1] = new GUIContent(blendNames[i]);
|
||||
}
|
||||
EditorGUILayout.IntPopup(prop, options, values, new GUIContent(name));
|
||||
}
|
||||
|
||||
private string[] GetMeshBlendNames()
|
||||
{
|
||||
var morphTarget = (OVRLipSyncContextMorphTarget)serializedObject.targetObject;
|
||||
if (morphTarget == null || morphTarget.skinnedMeshRenderer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var mesh = morphTarget.skinnedMeshRenderer.sharedMesh;
|
||||
var blendshapeCount = mesh.blendShapeCount;
|
||||
var blendNames = new string[blendshapeCount];
|
||||
for(int i = 0; i < mesh.blendShapeCount; ++i)
|
||||
{
|
||||
blendNames[i] = mesh.GetBlendShapeName(i);
|
||||
}
|
||||
return blendNames;
|
||||
}
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var blendNames = GetMeshBlendNames();
|
||||
var morphTarget = (OVRLipSyncContextMorphTarget)serializedObject.targetObject;
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(skinnedMeshRenderer);
|
||||
if (EditorGUILayout.PropertyField(visemeToBlendTargets))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for(int i = 1; i < visemeNames.Length; ++i)
|
||||
{
|
||||
BlendNameProperty(visemeToBlendTargets.GetArrayElementAtIndex(i), visemeNames[i], blendNames);
|
||||
}
|
||||
BlendNameProperty(laughterBlendTarget, "Laughter", blendNames);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
if (morphTarget)
|
||||
{
|
||||
morphTarget.enableVisemeTestKeys = EditorGUILayout.ToggleLeft("Enable Viseme Test Keys", morphTarget.enableVisemeTestKeys);
|
||||
}
|
||||
if (EditorGUILayout.PropertyField(visemeTestKeys))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for(int i = 1; i < visemeNames.Length; ++i)
|
||||
{
|
||||
EditorGUILayout.PropertyField(visemeTestKeys.GetArrayElementAtIndex(i), new GUIContent(visemeNames[i]));
|
||||
}
|
||||
EditorGUILayout.PropertyField(laughterKey, new GUIContent("Laughter"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUILayout.PropertyField(laughterThreshold);
|
||||
EditorGUILayout.PropertyField(laughterMultiplier);
|
||||
EditorGUILayout.PropertyField(smoothAmounth);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7d01b0eb149d9945a23728e5c7f5fcb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
166
Assets/Oculus/LipSync/Editor/OVRLipSyncTool.cs
Normal file
166
Assets/Oculus/LipSync/Editor/OVRLipSyncTool.cs
Normal file
@ -0,0 +1,166 @@
|
||||
/************************************************************************************
|
||||
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(bool useOfflineModel)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
var sequence =
|
||||
OVRLipSyncSequence.CreateSequenceFromAudioClip(clip, useOfflineModel);
|
||||
if (sequence != null)
|
||||
{
|
||||
var path = AssetDatabase.GetAssetPath(clip);
|
||||
var newPath = path.Replace(Path.GetExtension(path), "_lipSync.asset");
|
||||
var existingSequence = AssetDatabase.LoadAssetAtPath<OVRLipSyncSequence>(newPath);
|
||||
if (existingSequence != null)
|
||||
{
|
||||
EditorUtility.CopySerialized(sequence, existingSequence);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetDatabase.CreateAsset(sequence, newPath);
|
||||
|
||||
}
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
if (!clip.preloadAudioData)
|
||||
{
|
||||
clip.UnloadAudioData();
|
||||
}
|
||||
|
||||
totalLengthOfClipsProcessed += clip.length;
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
static OVRLipSyncToolLoader()
|
||||
{
|
||||
processor = null;
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
static void Update()
|
||||
{
|
||||
if (processor != null)
|
||||
{
|
||||
processor.MoveNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OVRLipSyncTool
|
||||
{
|
||||
[MenuItem("Oculus/Lip Sync/Generate Lip Sync Assets", false, 2000000)]
|
||||
static void GenerateLipSyncAssets()
|
||||
{
|
||||
GenerateLipSyncAssetsInternal(false);
|
||||
}
|
||||
|
||||
[MenuItem("Oculus/Lip Sync/Generate Lip Sync Assets With Offline Model", false, 2500000)]
|
||||
static void GenerateLipSyncAssetsOffline()
|
||||
{
|
||||
GenerateLipSyncAssetsInternal(true);
|
||||
}
|
||||
|
||||
private static void GenerateLipSyncAssetsInternal(bool useOfflineModel)
|
||||
|
||||
{
|
||||
|
||||
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(useOfflineModel);
|
||||
}
|
||||
}
|
||||
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:
|
||||
28
Assets/Oculus/LipSync/Editor/Oculus.LipSync.Editor.asmdef
Normal file
28
Assets/Oculus/LipSync/Editor/Oculus.LipSync.Editor.asmdef
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "Oculus.LipSync.Editor",
|
||||
"references": [
|
||||
"Oculus.LipSync"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.xr.management",
|
||||
"expression": "",
|
||||
"define": "USING_XR_MANAGEMENT"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.oculus",
|
||||
"expression": "",
|
||||
"define": "USING_XR_SDK_OCULUS"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a28a0ede888098f48be24ef95777d9bd
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user