Initialer Upload neues Unity-Projekt
This commit is contained in:
8
Assets/Oculus/Voice/Scripts/Editor/Data.meta
Normal file
8
Assets/Oculus/Voice/Scripts/Editor/Data.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9b850b590def934d88d46d5f230177b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 System;
|
||||
using Meta.WitAi;
|
||||
using Meta.WitAi.Configuration;
|
||||
using Meta.WitAi.Data;
|
||||
using Meta.WitAi.Data.Configuration;
|
||||
using Meta.WitAi.Windows;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Data
|
||||
{
|
||||
[Serializable]
|
||||
public class VoiceSDKDataCreation
|
||||
{
|
||||
[MenuItem("Assets/Create/Voice SDK/Add App Voice Experience to Scene", false, 100)]
|
||||
public static void AddVoiceCommandServiceToScene()
|
||||
{
|
||||
var witGo = new GameObject();
|
||||
witGo.name = "App Voice Experience";
|
||||
var wit = witGo.AddComponent<AppVoiceExperience>();
|
||||
wit.RuntimeConfiguration = new WitRuntimeConfiguration
|
||||
{
|
||||
witConfiguration = WitDataCreation.FindDefaultWitConfig()
|
||||
};
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/Values/String Value")]
|
||||
public static void WitStringValue()
|
||||
{
|
||||
WitDataCreation.CreateStringValue("");
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/Values/Float Value")]
|
||||
public static void WitFloatValue()
|
||||
{
|
||||
WitDataCreation.CreateFloatValue("");
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/Values/Int Value")]
|
||||
public static void WitIntValue()
|
||||
{
|
||||
WitDataCreation.CreateIntValue("");
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/Configuration", false, 200)]
|
||||
public static void CreateWitConfiguration()
|
||||
{
|
||||
WitWindowUtility.OpenSetupWindow(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 766b749f675dba94a92bb81ebf699d06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Oculus/Voice/Scripts/Editor/Hub.meta
Normal file
3
Assets/Oculus/Voice/Scripts/Editor/Hub.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5aef3e0e14d24405919aea5fa6551f92
|
||||
timeCreated: 1681334037
|
||||
30
Assets/Oculus/Voice/Scripts/Editor/Hub/VoiceSettings.cs
Normal file
30
Assets/Oculus/Voice/Scripts/Editor/Hub/VoiceSettings.cs
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
using Meta.Voice.Hub.Attributes;
|
||||
using Meta.Voice.Hub.Interfaces;
|
||||
using Meta.Voice.VSDKHub;
|
||||
using Meta.Voice.Windows;
|
||||
using Oculus.Voice.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Meta.Voice.Hub
|
||||
{
|
||||
[MetaHubPage("Settings", VoiceHubConstants.CONTEXT_VOICE, priority: 800)]
|
||||
public class SettingsWindowPage : SettingsWindow, IMetaHubPage
|
||||
{
|
||||
protected override GUIContent Title => new GUIContent("Voice SDK Settings");
|
||||
protected override Texture2D HeaderIcon => null;
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
|
||||
public new void OnGUI()
|
||||
{
|
||||
base.OnGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f28381e065624802b1cf1a6a2c98c644
|
||||
timeCreated: 1681333993
|
||||
8
Assets/Oculus/Voice/Scripts/Editor/Inspectors.meta
Normal file
8
Assets/Oculus/Voice/Scripts/Editor/Inspectors.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e7c523618d37124d82a50597af82815
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.WitAi.Inspectors;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Oculus.Voice.Inspectors
|
||||
{
|
||||
[CustomEditor(typeof(AppVoiceExperience))]
|
||||
public class AppVoiceExperienceEditor : WitInspector
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03744310c46b6e546b2b772e941f8cb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.WitAi.Data.Configuration;
|
||||
using Meta.WitAi.Windows;
|
||||
using Meta.WitAi;
|
||||
using Meta.WitAi.Data.Info;
|
||||
using Oculus.Voice.Utility;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Inspectors
|
||||
{
|
||||
[CustomEditor(typeof(WitConfiguration))]
|
||||
public class AppVoiceExperienceWitConfigurationEditor : WitConfigurationEditor
|
||||
{
|
||||
// Override with voice sdk header
|
||||
protected override Texture2D HeaderIcon => VoiceSDKStyles.MainHeader;
|
||||
public override string HeaderUrl => GetSafeAppUrl(Configuration, WitTexts.WitAppEndpointType.Settings);
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
protected override string OpenButtonLabel => IsBuiltInConfiguration(Configuration) ? VoiceSDKStyles.Texts.BuiltInAppBtnLabel : base.OpenButtonLabel;
|
||||
|
||||
// Disable server functionality for built in configurations
|
||||
protected override bool _disableServerPost => IsBuiltInConfiguration(Configuration);
|
||||
|
||||
// Use to determine if built in configuration
|
||||
public static bool IsBuiltInConfiguration(WitConfiguration witConfiguration)
|
||||
{
|
||||
if (witConfiguration == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return IsBuiltInConfiguration(witConfiguration.GetApplicationInfo());
|
||||
}
|
||||
public static bool IsBuiltInConfiguration(WitAppInfo appInfo)
|
||||
{
|
||||
return IsBuiltInConfiguration(appInfo.id);
|
||||
}
|
||||
public static bool IsBuiltInConfiguration(string applicationID)
|
||||
{
|
||||
return !string.IsNullOrEmpty(applicationID) && applicationID.StartsWith("voice");
|
||||
}
|
||||
|
||||
// Get safe app url
|
||||
public static string GetSafeAppUrl(WitConfiguration witConfiguration, WitTexts.WitAppEndpointType endpointType)
|
||||
{
|
||||
// Use built in app url
|
||||
if (IsBuiltInConfiguration(witConfiguration))
|
||||
{
|
||||
return VoiceSDKStyles.Texts.BuiltInAppUrl;
|
||||
}
|
||||
// Return wit app id
|
||||
return WitTexts.GetAppURL(witConfiguration?.GetApplicationId(), endpointType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81dc8ceb5197487fa6b8f684c40a0a06
|
||||
timeCreated: 1630651402
|
||||
8
Assets/Oculus/Voice/Scripts/Editor/Upgrade.meta
Normal file
8
Assets/Oculus/Voice/Scripts/Editor/Upgrade.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a51109e9358cfd4fa1690bede306b75
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/Oculus/Voice/Scripts/Editor/Upgrade/WitUpgrader.cs
Normal file
55
Assets/Oculus/Voice/Scripts/Editor/Upgrade/WitUpgrader.cs
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.WitAi;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Upgrade
|
||||
{
|
||||
[CustomEditor(typeof(Wit), false)]
|
||||
public class WitUpgrader : Editor
|
||||
{
|
||||
class Styles
|
||||
{
|
||||
public static GUIContent upgrade = new GUIContent("Upgrade to App Voice Experience",
|
||||
"This will replace your Wit object with a comparable component from the Voice SDK.");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var wit = (Wit) target;
|
||||
if (!wit.GetComponent<AppVoiceExperience>())
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (!Application.isPlaying && GUILayout.Button(Styles.upgrade))
|
||||
{
|
||||
var voiceService = wit.gameObject.AddComponent<AppVoiceExperience>();
|
||||
voiceService.VoiceEvents = wit.VoiceEvents;
|
||||
voiceService.RuntimeConfiguration = wit.RuntimeConfiguration;
|
||||
var voiceServiceSerializedObject = new SerializedObject(voiceService);
|
||||
voiceServiceSerializedObject.ApplyModifiedProperties();
|
||||
DestroyImmediate(wit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b6dc5be923e4794fbc03577778257f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Oculus/Voice/Scripts/Editor/Utility.meta
Normal file
8
Assets/Oculus/Voice/Scripts/Editor/Utility.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c74dbc89a3023bb41b841587da9e9953
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
98
Assets/Oculus/Voice/Scripts/Editor/Utility/VoiceSDKMenu.cs
Normal file
98
Assets/Oculus/Voice/Scripts/Editor/Utility/VoiceSDKMenu.cs
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.Voice.VSDKHub;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Meta.WitAi.Windows;
|
||||
using Meta.WitAi.Data.Entities;
|
||||
using Meta.WitAi.TTS;
|
||||
using Meta.WitAi.TTS.Preload;
|
||||
|
||||
namespace Oculus.Voice.Utility
|
||||
{
|
||||
public static class VoiceSDKMenu
|
||||
{
|
||||
#region WINDOWS
|
||||
[MenuItem("Oculus/Voice SDK/Get Started", false, 1)]
|
||||
private static void OpenConfigurationWindow()
|
||||
{
|
||||
WitWindowUtility.OpenGettingStarted((config) =>
|
||||
{
|
||||
VoiceSDKHub.ShowPage(VoiceSDKHub.GetPageId(VoiceHubConstants.PAGE_WIT_CONFIGS));
|
||||
});
|
||||
}
|
||||
[MenuItem("Oculus/Voice SDK/Understanding Viewer", false, 200)]
|
||||
private static void OpenUnderstandingWindow()
|
||||
{
|
||||
WitWindowUtility.OpenUnderstandingWindow();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Scriptable Objects
|
||||
[MenuItem("Assets/Create/Voice SDK/Dynamic Entities")]
|
||||
public static void CreateDynamicEntities()
|
||||
{
|
||||
WitDynamicEntitiesData asset =
|
||||
ScriptableObject.CreateInstance<WitDynamicEntitiesData>();
|
||||
|
||||
var path = EditorUtility.SaveFilePanel("Save Dynamic Entity", Application.dataPath,
|
||||
"DynamicEntities", "asset");
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = "Assets/" + path.Replace(Application.dataPath, "");
|
||||
AssetDatabase.CreateAsset(asset, path);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
EditorUtility.FocusProjectWindow();
|
||||
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TTS
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/TTS/Add Default TTS Setup")]
|
||||
public static void CreateDefaultTTSSetup()
|
||||
{
|
||||
TTSEditorUtilities.CreateDefaultSetup();
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/TTS/Add TTS Service to Scene", false, 100)]
|
||||
public static void CreateTTSService()
|
||||
{
|
||||
TTSEditorUtilities.CreateService();
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/Voice SDK/TTS/Add TTS Speaker to Scene", false, 100)]
|
||||
public static void CreateTTSSpeaker()
|
||||
{
|
||||
TTSEditorUtilities.CreateSpeaker();
|
||||
}
|
||||
[MenuItem("Assets/Create/Voice SDK/TTS/Preload Settings", false, 200)]
|
||||
public static void CreateTTSPreloadSettings()
|
||||
{
|
||||
TTSPreloadUtility.CreatePreloadSettings();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edfc5f7f2010aa340af1f2b286930dc6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
82
Assets/Oculus/Voice/Scripts/Editor/Utility/VoiceSDKStyles.cs
Normal file
82
Assets/Oculus/Voice/Scripts/Editor/Utility/VoiceSDKStyles.cs
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 System;
|
||||
using UnityEngine;
|
||||
using Meta.WitAi;
|
||||
|
||||
namespace Oculus.Voice.Utility
|
||||
{
|
||||
public static class VoiceSDKStyles
|
||||
{
|
||||
[Serializable]
|
||||
public struct VoiceSDKTexts
|
||||
{
|
||||
[Header("Setup Texts")]
|
||||
public string SetupTitleLabel;
|
||||
public string SetupHeaderLabel;
|
||||
public string SetupSubheaderLabel;
|
||||
public string SetupLanguageLabel;
|
||||
public string VoiceDocsUrl;
|
||||
[Header("About Texts")]
|
||||
public string AboutTitleLabel;
|
||||
public string AboutCloseLabel;
|
||||
public string AboutVoiceSdkVersionLabel;
|
||||
public string AboutWitSdkVersionLabel;
|
||||
public string AboutWitApiVersionLabel;
|
||||
public string AboutTutorialButtonLabel;
|
||||
public string AboutTutorialButtonUrl;
|
||||
[Header("Settings Texts")]
|
||||
public string SettingsTitleLabel;
|
||||
[Header("Understanding Viewer Texts")]
|
||||
public string UnderstandingViewerTitleLabel;
|
||||
[Header("Built-In Texts")]
|
||||
public string BuiltInAppBtnLabel;
|
||||
public string BuiltInAppUrl;
|
||||
}
|
||||
public static VoiceSDKTexts Texts;
|
||||
|
||||
public static Texture2D MainHeader;
|
||||
public static GUIContent SetupTitle;
|
||||
public static GUIContent AboutTitle;
|
||||
public static GUIContent SettingsTitle;
|
||||
public static GUIContent UnderstandingTitle;
|
||||
|
||||
static VoiceSDKStyles()
|
||||
{
|
||||
// Load localization
|
||||
string languageID = "en-us";
|
||||
string textFilePath = $"voicesdk_texts_{languageID}";
|
||||
TextAsset textAsset = Resources.Load<TextAsset>(textFilePath);
|
||||
if (textAsset == null)
|
||||
{
|
||||
VLog.E($"VoiceSDK Texts - Add localization to Resources/{textFilePath}\nLanguage: {languageID}");
|
||||
return;
|
||||
}
|
||||
Texts = JsonUtility.FromJson<VoiceSDKTexts>(textAsset.text);
|
||||
|
||||
MainHeader = (Texture2D) Resources.Load("voicesdk_heroart");
|
||||
SetupTitle = new GUIContent(Texts.SetupTitleLabel);
|
||||
AboutTitle = new GUIContent(Texts.AboutTitleLabel);
|
||||
SettingsTitle = new GUIContent(Texts.SettingsTitleLabel);
|
||||
UnderstandingTitle = new GUIContent(Texts.UnderstandingViewerTitleLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa1f0af066e824a31875bc815a72cc5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 System;
|
||||
using Oculus.VoiceSDK;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Obsolete class for editor version info
|
||||
/// </summary>
|
||||
public class VoiceSDKVersion : MonoBehaviour
|
||||
{
|
||||
[Obsolete("Use 'VoiceSDKConstants.SdkVersion' directly")]
|
||||
public static string VERSION => VoiceSDKConstants.SdkVersion;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bf6b7b99e36e104f964fb70253f847c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Oculus/Voice/Scripts/Editor/VoiceSDK.Editor.asmdef
Normal file
33
Assets/Oculus/Voice/Scripts/Editor/VoiceSDK.Editor.asmdef
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "VoiceSDK.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:e545cc0678493234a9368f4e470c29e8",
|
||||
"GUID:4504b1a6e0fdcc3498c30b266e4a63bf",
|
||||
"GUID:fa958eb9f0171754fb207d563a15ddfa",
|
||||
"GUID:8bbcefc153e1f1b4a98680670797dd16",
|
||||
"GUID:e31cc0253d8f956459091c800a16d68d",
|
||||
"GUID:1c28d8b71ced07540b7c271537363cc6",
|
||||
"GUID:8e054d88729a3fb4bbe539499f824363",
|
||||
"GUID:fb19304c87f76694ca2d792da1915efe",
|
||||
"GUID:a4f6d7d3afe393a4c8034af2ef0f36a8",
|
||||
"GUID:4c3436cc699cb25459568e9fa95b7fd7"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.meta.xr.sdk.voice.telemetry",
|
||||
"expression": "",
|
||||
"define": "VSDK_TELEMETRY_AVAILABLE"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c313d8e945a7904dbf75897c010ac4d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Oculus/Voice/Scripts/Editor/Windows.meta
Normal file
8
Assets/Oculus/Voice/Scripts/Editor/Windows.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6882087e17a8bbe4c80cf5a6764e6a6b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/Oculus/Voice/Scripts/Editor/Windows/AboutWindow.cs
Normal file
56
Assets/Oculus/Voice/Scripts/Editor/Windows/AboutWindow.cs
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.Voice.VSDKHub;
|
||||
using Meta.Voice.Hub.Attributes;
|
||||
using Meta.Voice.Hub.Interfaces;
|
||||
using Meta.WitAi;
|
||||
using Oculus.Voice.Utility;
|
||||
using Oculus.Voice;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Meta.Voice
|
||||
{
|
||||
[MetaHubPage("About", VoiceHubConstants.CONTEXT_VOICE, priority: 1000)]
|
||||
public class AboutWindow : IMetaHubPage
|
||||
{
|
||||
private Vector2 _offset;
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
Vector2 size;
|
||||
WitEditorUI.LayoutWindow(VoiceSDKStyles.Texts.AboutTitleLabel, null, null, null, OnWindowGUI, ref _offset, out size);
|
||||
}
|
||||
|
||||
private void OnWindowGUI()
|
||||
{
|
||||
WitEditorUI.LayoutKeyLabel(VoiceSDKStyles.Texts.AboutVoiceSdkVersionLabel, VoiceSDKConstants.SdkVersion);
|
||||
WitEditorUI.LayoutKeyLabel(VoiceSDKStyles.Texts.AboutWitSdkVersionLabel, WitConstants.SDK_VERSION);
|
||||
WitEditorUI.LayoutKeyLabel(VoiceSDKStyles.Texts.AboutWitApiVersionLabel, WitConstants.API_VERSION);
|
||||
|
||||
GUILayout.Space(16);
|
||||
|
||||
if (WitEditorUI.LayoutTextButton(VoiceSDKStyles.Texts.AboutTutorialButtonLabel))
|
||||
{
|
||||
Application.OpenURL(VoiceSDKStyles.Texts.AboutTutorialButtonUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b92c30adebae6ba4f93106d6fa6f4b3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_ViewDataDictionary: {instanceID: 0}
|
||||
- header: {fileID: 2800000, guid: 41df4ab8a05595e49b2f2d150e753bf7, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
98
Assets/Oculus/Voice/Scripts/Editor/Windows/SettingsWindow.cs
Normal file
98
Assets/Oculus/Voice/Scripts/Editor/Windows/SettingsWindow.cs
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 System.Collections.Generic;
|
||||
using Meta.Voice.Hub.Attributes;
|
||||
using Meta.Voice.Hub.Interfaces;
|
||||
using Meta.Voice.VSDKHub;
|
||||
using Meta.WitAi;
|
||||
using Meta.WitAi.Windows;
|
||||
using Oculus.Voice.Utility;
|
||||
using Oculus.Voice.Windows;
|
||||
using UnityEngine;
|
||||
using Meta.Voice.TelemetryUtilities;
|
||||
|
||||
namespace Meta.Voice.Windows
|
||||
{
|
||||
public class SettingsWindow : WitWindow
|
||||
{
|
||||
protected override GUIContent Title => new GUIContent(VoiceSDKStyles.SettingsTitle.text);
|
||||
protected override Texture2D HeaderIcon => VoiceSDKStyles.MainHeader;
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
WitAuthUtility.tokenValidator = new VoiceSDKTokenValidatorProvider();
|
||||
titleContent = Title;
|
||||
base.OnEnable();
|
||||
}
|
||||
}
|
||||
|
||||
[MetaHubPage("Wit Configurations", VoiceHubConstants.CONTEXT_VOICE, priority: 500)]
|
||||
public class WitConfigWindowPage : SettingsWindow, IMetaHubPage
|
||||
{
|
||||
protected override GUIContent Title => new GUIContent("Wit Configurations");
|
||||
protected override Texture2D HeaderIcon => null;
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
|
||||
public override bool ShowGeneralSettings => false;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
Telemetry.LogInstantEvent(Telemetry.TelemetryEventId.OpenUi, new Dictionary<Telemetry.AnnotationKey, string>()
|
||||
{
|
||||
{Telemetry.AnnotationKey.PageId, "Configuration Window"}
|
||||
});
|
||||
titleContent = Title;
|
||||
}
|
||||
|
||||
public new void OnGUI()
|
||||
{
|
||||
base.OnGUI();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Title.text;
|
||||
}
|
||||
}
|
||||
|
||||
[MetaHubPage("Settings", VoiceHubConstants.CONTEXT_VOICE, priority: 800)]
|
||||
public class SettingsWindowPage : SettingsWindow, IMetaHubPage
|
||||
{
|
||||
protected override GUIContent Title => new GUIContent("Settings");
|
||||
protected override Texture2D HeaderIcon => null;
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
|
||||
public override bool ShowWitConfiguration => false;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
titleContent = Title;
|
||||
}
|
||||
|
||||
public new void OnGUI()
|
||||
{
|
||||
base.OnGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c810bb2a5bea4e4897c121e3264df3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 System.Collections.Generic;
|
||||
using Meta.Voice.TelemetryUtilities;
|
||||
using Meta.WitAi;
|
||||
using Meta.WitAi.Windows;
|
||||
using UnityEngine;
|
||||
using Oculus.Voice.Utility;
|
||||
using Oculus.Voice.Inspectors;
|
||||
|
||||
namespace Oculus.Voice.Windows
|
||||
{
|
||||
public class UnderstandingViewerWindow : WitUnderstandingViewer
|
||||
{
|
||||
protected override GUIContent Title => VoiceSDKStyles.UnderstandingTitle;
|
||||
protected override Texture2D HeaderIcon => VoiceSDKStyles.MainHeader;
|
||||
protected override string HeaderUrl => AppVoiceExperienceWitConfigurationEditor.GetSafeAppUrl(witConfiguration, WitTexts.WitAppEndpointType.Understanding);
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
Telemetry.LogInstantEvent(Telemetry.TelemetryEventId.OpenUi, new Dictionary<Telemetry.AnnotationKey, string>()
|
||||
{
|
||||
{Telemetry.AnnotationKey.PageId, "Configuration Window"}
|
||||
});
|
||||
base.OnEnable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c86fe355d3472b94bbaa52c686a49ddb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 UnityEditor;
|
||||
using System.Reflection;
|
||||
using Meta.WitAi.Data.Info;
|
||||
using Meta.WitAi.Windows;
|
||||
using Oculus.Voice.Inspectors;
|
||||
|
||||
namespace Oculus.Voice.Windows
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(WitAppInfo))]
|
||||
public class VoiceApplicationDetailProvider : WitApplicationPropertyDrawer
|
||||
{
|
||||
// Skip fields if voice sdk app id
|
||||
protected override bool ShouldLayoutField(SerializedProperty property, FieldInfo subfield)
|
||||
{
|
||||
string appID = GetFieldStringValue(property, "id").ToLower();
|
||||
if (AppVoiceExperienceWitConfigurationEditor.IsBuiltInConfiguration(appID))
|
||||
{
|
||||
switch (subfield.Name)
|
||||
{
|
||||
case "name":
|
||||
case "lang":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return base.ShouldLayoutField(property, subfield);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f885966f75e449f6b3912d20c1b85bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 UnityEditor;
|
||||
|
||||
namespace Oculus.Voice.Windows
|
||||
{
|
||||
public class VoiceSDKWizardWindow : ScriptableWizard
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e81c43e4b4674634a8e8b4e34733945
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_ViewDataDictionary: {instanceID: 0}
|
||||
- header: {fileID: 2800000, guid: 41df4ab8a05595e49b2f2d150e753bf7, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
130
Assets/Oculus/Voice/Scripts/Editor/Windows/WelcomeWizard.cs
Normal file
130
Assets/Oculus/Voice/Scripts/Editor/Windows/WelcomeWizard.cs
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus 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/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 System.Collections.Generic;
|
||||
using Meta.Voice.TelemetryUtilities;
|
||||
using Meta.WitAi;
|
||||
using Meta.WitAi.Data.Configuration;
|
||||
using Meta.WitAi.Windows;
|
||||
using Meta.WitAi.Data.Info;
|
||||
using Oculus.Voice.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Windows
|
||||
{
|
||||
public class WelcomeWizard : WitWelcomeWizard
|
||||
{
|
||||
private int witBuiltInIndex;
|
||||
private string[] builtinAppNames;
|
||||
|
||||
protected override Texture2D HeaderIcon => VoiceSDKStyles.MainHeader;
|
||||
protected override GUIContent Title => VoiceSDKStyles.SetupTitle;
|
||||
protected override string ContentHeaderLabel => VoiceSDKStyles.Texts.SetupHeaderLabel;
|
||||
protected override string ContentSubheaderLabel => VoiceSDKStyles.Texts.SetupSubheaderLabel;
|
||||
protected override string DocsUrl => VoiceSDKStyles.Texts.VoiceDocsUrl;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
Telemetry.LogInstantEvent(Telemetry.TelemetryEventId.OpenUi, new Dictionary<Telemetry.AnnotationKey, string>()
|
||||
{
|
||||
{Telemetry.AnnotationKey.PageId, "Getting Started"}
|
||||
});
|
||||
|
||||
WitAuthUtility.tokenValidator = new VoiceSDKTokenValidatorProvider();
|
||||
base.OnEnable();
|
||||
witBuiltInIndex = 0;
|
||||
var names = AppBuiltIns.appNames;
|
||||
builtinAppNames = new string[names.Length + 1];
|
||||
builtinAppNames[0] = "Custom App";
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
builtinAppNames[i + 1] = names[i];
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LayoutFields()
|
||||
{
|
||||
// Prebuilt language app
|
||||
bool updated = false;
|
||||
WitEditorUI.LayoutLabel(VoiceSDKStyles.Texts.SetupLanguageLabel);
|
||||
WitEditorUI.LayoutPopup("", builtinAppNames, ref witBuiltInIndex, ref updated);
|
||||
if (updated)
|
||||
{
|
||||
if (witBuiltInIndex == 0)
|
||||
{
|
||||
serverToken = WitAuthUtility.ServerToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
serverToken = AppBuiltIns.builtInPrefix + builtinAppNames[witBuiltInIndex];
|
||||
}
|
||||
}
|
||||
|
||||
// Base fields
|
||||
if (witBuiltInIndex == 0)
|
||||
{
|
||||
GUILayout.Space(WitStyles.HeaderPaddingBottom);
|
||||
base.LayoutFields();
|
||||
}
|
||||
}
|
||||
|
||||
// Customize configuration if voice app was selected
|
||||
protected override int CreateConfiguration(string newToken)
|
||||
{
|
||||
// Do base for custom app
|
||||
if (witBuiltInIndex <= 0)
|
||||
{
|
||||
return base.CreateConfiguration(newToken);
|
||||
}
|
||||
|
||||
// Get built in app data
|
||||
string languageName = builtinAppNames[witBuiltInIndex];
|
||||
Dictionary<string, string> appData = AppBuiltIns.apps[languageName];
|
||||
|
||||
// Generate asset using app data
|
||||
WitConfiguration configuration = ScriptableObject.CreateInstance<WitConfiguration>();
|
||||
configuration.SetClientAccessToken(appData["clientToken"]);
|
||||
WitAppInfo application = new WitAppInfo()
|
||||
{
|
||||
name = appData["name"],
|
||||
id = appData["id"],
|
||||
lang = appData["lang"]
|
||||
};
|
||||
configuration.SetApplicationInfo(application);
|
||||
configuration.name = application.id;
|
||||
|
||||
// Save configuration to asset
|
||||
return WitConfigurationUtility.SaveConfiguration(string.Empty, configuration);
|
||||
}
|
||||
}
|
||||
|
||||
public class VoiceSDKTokenValidatorProvider : WitAuthUtility.ITokenValidationProvider
|
||||
{
|
||||
public bool IsTokenValid(string appId, string token)
|
||||
{
|
||||
return IsServerTokenValid(token);
|
||||
}
|
||||
|
||||
public bool IsServerTokenValid(string serverToken)
|
||||
{
|
||||
return null != serverToken && (serverToken.Length == 32 || serverToken.StartsWith(AppBuiltIns.builtInPrefix));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1969028d6c8d24d5c83929e0d846ac21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_ViewDataDictionary: {instanceID: 0}
|
||||
- header: {fileID: 2800000, guid: 41df4ab8a05595e49b2f2d150e753bf7, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user