clean project

This commit is contained in:
Helar Jaadla
2022-03-07 17:52:41 +02:00
parent a174b45bd2
commit cbeb10ec35
5100 changed files with 837159 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 38d8089fa62e8c44ca4b89cd457e9c9a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d2baf202180c254fa9bdc8b9f29e51e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: e955972de48c3524db27b7ee6812107d
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 51b66b75957473a4f8594d6b4a58888f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae5a46bda3295124c99b0e6537ac7252, type: 3}
m_Name: Shapes Demo - WitConfiguration
m_EditorClassIdentifier:
application:
witConfiguration: {fileID: 0}
name:
id:
lang:
isPrivate: 0
createdAt:
configId: 4e21a24e472ab684e84db753427d5687
clientAccessToken:
entities: []
intents: []
traits: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b3d5ad89f091a0a4785d8fbbfdd39448
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae5a46bda3295124c99b0e6537ac7252, type: 3}
m_Name: Timer Builtins - WitConfiguration
m_EditorClassIdentifier:
application:
witConfiguration: {fileID: 0}
name: Built-in Models
id: voiceSDK_en
lang: en
isPrivate: 0
createdAt:
configId: 74f17110584875d438c76cba2242da14
clientAccessToken: HOKEABS7HPIQVSRSVWRPTTV75TQJ5QBP
entities: []
intents: []
traits: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8ca721df475c92e4ca9167b74de4b2f6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c8f449cba03430f45b629ec30e9f86a3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7ecd492229a42c243a6013ad1bada8e0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Shapes
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc0300e976173994a92b5e91881aeaad
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Skybox
m_Shader: {fileID: 106, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _SUNDISK_HIGH_QUALITY
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AtmosphereThickness: 1.54
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _Exposure: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SunDisk: 2
- _SunSize: 0
- _SunSizeConvergence: 5
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _GroundColor: {r: 1, g: 1, b: 1, a: 1}
- _SkyTint: {r: 0.3773585, g: 0.2076738, b: 0, a: 1}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fea35dc83d97e2b438e3baebaf6ead34
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 75eb0b55e037c534b8d0b28dc57b53d3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,218 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1110266669
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1110266671}
- component: {fileID: 1110266670}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1110266671
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1110266669}
m_LocalRotation: {x: -0.3892604, y: 0.3656803, z: -0.72808844, w: 0.42969945}
m_LocalPosition: {x: 0.17430386, y: 3.2850657, z: -10.452414}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8853415545987821512}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 11.418, y: 64.012, z: -111.753006}
--- !u!108 &1110266670
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1110266669}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &8853415545987821519
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8853415545987821512}
m_Layer: 0
m_Name: Environment
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8853415545987821512
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8853415545987821519}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.17430386, y: -0.28506565, z: 10.452414}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8853415547494044119}
- {fileID: 1110266671}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8853415547494044118
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8853415547494044119}
- component: {fileID: 8853415547494044112}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8853415547494044119
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8853415547494044118}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0.17430386, y: 3.2850657, z: -10.452414}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8853415545987821512}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!108 &8853415547494044112
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8853415547494044118}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.802082
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0381539164984dc4ca193f001869c526
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9e2c99d589c9fcb4b8254df996a55503
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8e367e1dd90bb894d88708e7548eae48
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0b4eecbae5fd7be46896db34734286a0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cef010296d8fc744e9abe187269ea0b5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 820d90595e7544215bde6c6f43664cb1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,244 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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 UnityEngine.UI;
namespace Oculus.Voice.Demo.BuiltInDemo
{
/// <summary>
/// Represents a countdown timer.
/// </summary>
public class TimerController : MonoBehaviour
{
private float _time = 0; // [sec] current time of the countdown timer.
private bool _timerExist = false;
private bool _timerRunning = false;
[Tooltip("The UI text element to show app messages.")]
public Text logText;
[Tooltip("The timer ring sound.")] public AudioClip buzzSound;
// Update is called once per frame
void Update()
{
if (_timerExist && _timerRunning)
{
_time -= Time.deltaTime;
if (_time < 0)
{
// Raise a ring.
OnElapsedTime();
}
}
}
private void Log(string msg)
{
Debug.Log(msg);
logText.text = msg;
}
/// <summary>
/// Buzzes and resets the timer.
/// </summary>
private void OnElapsedTime()
{
_time = 0;
_timerRunning = false;
_timerExist = false;
Log("Buzz!");
AudioSource.PlayClipAtPoint(buzzSound, Vector3.zero);
}
/// <summary>
/// Deletes the timer. It corresponds to the wit intent "wit$delete_timer"
/// </summary>
public void DeleteTimer()
{
if (!_timerExist)
{
Log("Error: There is no timer to delete.");
return;
}
_timerExist = false;
_time = 0;
_timerRunning = false;
Log("Timer deleted.");
}
/// <summary>
/// Creates a timer. It corresponds to the wit intent "wit$create_timer"
/// </summary>
/// <param name="entityValues">countdown in minutes.</param>
public void CreateTimer(string[] entityValues)
{
if (_timerExist)
{
Log("A timer already exist.");
return;
}
if (ParseTime(entityValues, out _time))
{
_timerExist = true;
_timerRunning = true;
Log($"Countdown Timer is set for {entityValues[0]} {entityValues[1]}(s).");
}
else
{
Log("Error in CreateTimer(): Could not parse wit reply.");
}
}
/// <summary>
/// Displays current timer value. It corresponds to "wit$get_timer".
/// </summary>
public void GetTimerIntent()
{
// Show the remaining time of the countdown timer.
var msg = GetFormattedTimeFromSeconds();
Log(msg);
}
/// <summary>
/// Pauses the timer. It corresponds to the wit intent "wit$pause_timer"
/// </summary>
public void PauseTimer()
{
_timerRunning = false;
Log("Timer paused.");
}
/// <summary>
/// It corresponds to the wit intent "wit$resume_timer"
/// </summary>
public void ResumeTimer()
{
_timerRunning = true;
Log("Timer resumed.");
}
/// <summary>
/// Subtracts time from the timer. It corresponds to the wit intent "wit$subtract_time_timer".
/// </summary>
/// <param name="entityValues"></param>
public void SubtractTimeTimer(string[] entityValues)
{
if (!_timerExist)
{
Log("Error: No Timer is created.");
return;
}
if (ParseTime(entityValues, out var time))
{
var msg = $"{entityValues[0]} {entityValues[1]}(s) were subtracted from the timer.";
_time -= time;
if (_time < 0)
{
_time = 0;
Log(msg);
return;
}
Log(msg);
}
else
{
Log("Error in Subtract_time_timer(): Could not parse the wit reply.");
}
}
/// <summary>
/// Adds time to the timer. It corresponds to the wit intent "wit$add_time_timer".
/// </summary>
/// <param name="entityValues"></param>
public void AddTimeToTimer(string[] entityValues)
{
if (!_timerExist)
{
Log("Error: No Timer is created.");
return;
}
if (ParseTime(entityValues, out var time))
{
_time += time;
var msg = $"{entityValues[0]} {entityValues[1]}(s) were added to the timer.";
Log(msg);
}
else
{
Log("Error in AddTimeToTimer(): Could not parse with reply.");
}
}
/// <summary>
/// Returns the remaining time (in sec) of the countdown timer.
/// </summary>
/// <returns></returns>
public float GetRemainingTime()
{
return _time;
}
/// <summary>
/// Returns time in the format of min:sec.
/// </summary>
/// <returns></returns>
public string GetFormattedTimeFromSeconds()
{
return TimeSpan.FromSeconds(_time).ToString();
}
/// <summary>
/// Parses entity values to get a resulting time value in seconds
/// </summary>
/// <param name="entityValues">The entity value results from a Response Handler</param>
/// <param name="time">The parsed time</param>
/// <returns>The parsed time in seconds or the current value of _time</returns>
/// <exception cref="ArgumentException"></exception>
private bool ParseTime(string[] entityValues, out float time)
{
time = _time;
if (entityValues.Length > 0 && float.TryParse(entityValues[0], out time))
{
if (entityValues.Length < 2)
{
throw new ArgumentException("Entities being parsed must include time value and unit.");
}
// If entity was not included in the result it will be empty, but the array will still be size 2
if (!string.IsNullOrEmpty(entityValues[1]))
{
switch (entityValues[1])
{
case "minute":
time *= 60;
break;
case "hour":
time *= 60 * 60;
break;
}
}
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eb4fe076c92383b438b557433015250e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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;
namespace Oculus.Voice.Demo.BuiltInDemo
{
public class TimerDisplay : MonoBehaviour
{
public TimerController timer;
private Text _uiText;
// Start is called before the first frame update
void Start()
{
_uiText = GetComponent<Text>();
}
// Update is called once per frame
void Update()
{
// Note: This is not optimized and you should avoid updating time each frame.
_uiText.text = timer.GetFormattedTimeFromSeconds();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dacc4d06eebcecb4a846759a3ac9f6e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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;
namespace Oculus.Voice.Demo.BuiltInDemo
{
public class WitActivation : MonoBehaviour
{
[SerializeField] private AppVoiceExperience voiceExperience;
private void OnValidate()
{
if (!voiceExperience) voiceExperience = GetComponent<AppVoiceExperience>();
}
private void Start()
{
voiceExperience = GetComponent<AppVoiceExperience>();
}
private void Update()
{
// Make it possible to activate wit in the Unity Editor without the need to deploy to the headset.
if (Input.GetKeyDown(KeyCode.Space))
{
print("*** Pressed Space bar ***");
ActivateWit();
}
}
/// <summary>
/// Activates Wit i.e. start listening to the user.
/// </summary>
public void ActivateWit()
{
voiceExperience.Activate();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3699a21444dc7164289344371a620e0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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 Facebook.WitAi;
using Facebook.WitAi.Lib;
using UnityEngine;
using UnityEngine.UI;
namespace Oculus.Voice.Demo.UIShapesDemo
{
public class InteractionHandler : MonoBehaviour
{
[Header("Default States"), Multiline]
[SerializeField] private string freshStateText = "Try pressing the Activate button and saying \"Make the cube red\"";
[Header("UI")]
[SerializeField] private Text textArea;
[SerializeField] private bool showJson;
[Header("Voice")]
[SerializeField] private AppVoiceExperience appVoiceExperience;
private string pendingText;
private void OnEnable()
{
appVoiceExperience.events.OnRequestCreated.AddListener(OnRequestStarted);
}
private void OnDisable()
{
appVoiceExperience.events.OnRequestCreated.RemoveListener(OnRequestStarted);
}
private void OnRequestStarted(WitRequest r)
{
// The raw response comes back on a different thread. We store the
// message received for display on the next frame.
if (showJson) r.onRawResponse = (response) => pendingText = response;
}
private void Update()
{
if (null != pendingText)
{
textArea.text = pendingText;
pendingText = null;
}
}
public void OnResponse(WitResponseNode response)
{
if (!string.IsNullOrEmpty(response["text"]))
{
textArea.text = "I heard: " + response["text"];
}
else
{
textArea.text = freshStateText;
}
}
public void OnError(string error, string message)
{
textArea.text = $"<color=\"red\">Error: {error}\n\n{message}</color>";
}
public void ToggleActivation()
{
if (appVoiceExperience.Active) appVoiceExperience.Deactivate();
else
{
appVoiceExperience.Activate();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: abf7a75ccc7b2ef43bde5b4c73de6e65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 12df1a1211c7e46b3bed480404376c50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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 Facebook.WitAi;
using Facebook.WitAi.Lib;
using UnityEngine;
namespace Oculus.Voice.Demo.UIShapesDemo
{
public class ColorChanger : MonoBehaviour
{
/// <summary>
/// Sets the color of the specified transform.
/// </summary>
/// <param name="trans"></param>
/// <param name="color"></param>
private void SetColor(Transform trans, Color color)
{
trans.GetComponent<Renderer>().material.color = color;
}
/// <summary>
/// Directly processes a command result getting the slots with WitResult utilities
/// </summary>
/// <param name="commandResult">Result data from Wit.ai activation to be processed</param>
public void UpdateColor(WitResponseNode commandResult)
{
string colorName = commandResult.GetFirstEntityValue("color:color");
string shape = commandResult.GetFirstEntityValue("shape:shape");
UpdateColor(colorName, shape);
}
/// <summary>
/// Processes the values of a result handler with a color and shape filter.
/// </summary>
/// <param name="results">Results from result handler [0] color name, [1] shape</param>
public void UpdateColor(string[] results)
{
var colorName = results[0];
var shape = results[1];
UpdateColor(colorName, shape);
}
/// <summary>
/// Updates the color of a shape or all shapes
/// </summary>
/// <param name="colorName">The name of a color to be processed</param>
/// <param name="shape">The shape name or if empty all shapes</param>
public void UpdateColor(string colorName, string shape)
{
if (!ColorUtility.TryParseHtmlString(colorName, out var color)) return;
if (string.IsNullOrEmpty(shape) || shape == "color")
{
for (int i = 0; i < transform.childCount; i++)
{
SetColor(transform.GetChild(i), color);
}
}
else
{
for (int i = 0; i < transform.childCount; i++)
{
Transform child = transform.GetChild(i);
if (String.Equals(shape, child.name,
StringComparison.CurrentCultureIgnoreCase))
{
SetColor(child, color);
break;
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d86bf3f91fb7d4d41855107fcab470d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,182 @@
using Facebook.WitAi;
using Facebook.WitAi.Data.Configuration;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Oculus.Voice.Demo.UIShapesDemo
{
[ExecuteAlways]
public class Instructions : MonoBehaviour
{
internal enum Step
{
SetupWit = 0,
MissingServerToken,
MissingClientToken,
AddConfig,
AddVoiceExperiences,
SetConfig,
Ready
}
static readonly string[] steps = new string[]
{
"Create an application at https://wit.ai. You can import the \"shapes_demo - Wit.ai Config.zip\" in the Demo/Data directory to create it for you.\n\nConnect to the Wit.ai app by clicking Oculus>Voice SDK>Settings and copy the Server Access Token from the Wit.ai app's settings page.Next, create a new Wit configuration by clicking Create.",
"Copy the Server Access Token from the Wit.ai app's settings page and paste it in field found in Oculus/Voice SDK/Settings.",
"Wit configuration is missing a Client Access Token. Open the Wit configuration, expand Application Configuration, and click Refresh or paste a Client Access Token from your Wit.ai app settings page.",
"Create a Wit configuration by clicking Assets/Create/Voice SDK/Configuration.",
"The scene is missing the App Voice Experience component. Add it by clicking Assets/Create/Voice SDK/Add App Voice Experience to Scene.",
"The App Voice Experience GameObject is missing its Wit configuration. Set the configuration to begin trying voice commands.",
""
};
[SerializeField] private Text instructionText;
private Step currentStep = Step.Ready;
internal Step CurrentStep => currentStep;
internal string CurrentStepText => steps[(int) currentStep];
private void OnValidate()
{
UpdateStep();
}
private void OnEnable()
{
UpdateStep();
}
private void Update()
{
UpdateStep();
}
private void UpdateStep()
{
#if UNITY_EDITOR
var appVoiceExperience = FindObjectOfType<AppVoiceExperience>();
string[] guids = AssetDatabase.FindAssets("t:WitConfiguration");
if (guids.Length == 0)
{
currentStep = Step.SetupWit;
}
else if (!appVoiceExperience)
{
currentStep = Step.AddVoiceExperiences;
}
else if (!appVoiceExperience.RuntimeConfiguration.witConfiguration)
{
currentStep = Step.SetConfig;
appVoiceExperience.RuntimeConfiguration.witConfiguration =
AssetDatabase.LoadAssetAtPath<WitConfiguration>(
AssetDatabase.GUIDToAssetPath(guids[0]));
}
else if (!WitAuthUtility.IsServerTokenValid())
{
currentStep = Step.MissingServerToken;
}
else if (string.IsNullOrEmpty(appVoiceExperience.RuntimeConfiguration?.witConfiguration
.clientAccessToken))
{
currentStep = Step.MissingClientToken;
}
else
{
currentStep = Step.Ready;
}
instructionText.text = steps[(int) currentStep];
#endif
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(Instructions))]
public class InstructionManagerEditor : Editor
{
public override void OnInspectorGUI()
{
var instructions = (Instructions) target;
if (instructions.CurrentStep == Instructions.Step.Ready)
{
GUILayout.Label(
"Everything is ready. Press play to test activation via the Activate button.");
}
else
{
GUILayout.TextArea(instructions.CurrentStepText);
GUILayout.Space(32);
switch (instructions.CurrentStep)
{
case Instructions.Step.SetupWit:
SetupWitResources();
break;
case Instructions.Step.MissingServerToken:
MissingServerTokenResources();
break;
case Instructions.Step.MissingClientToken:
MissingClientTokenResources();
break;
}
}
}
private void MissingClientTokenResources()
{
GUILayout.Label("Resources", EditorStyles.boldLabel);
if (GUILayout.Button("Select Wit Config"))
{
Selection.activeObject = (FindObjectOfType<AppVoiceExperience>()
.RuntimeConfiguration.witConfiguration);
}
if (GUILayout.Button("Open Wit.ai"))
{
Application.OpenURL("https://wit.ai/apps");
}
}
private void MissingServerTokenResources()
{
GUILayout.Label("Resources", EditorStyles.boldLabel);
if (GUILayout.Button("Open Wit.ai"))
{
Application.OpenURL("https://wit.ai/apps");
}
}
private void SetupWitResources()
{
GUILayout.Label("Resources", EditorStyles.boldLabel);
if (GUILayout.Button("Open Wit.ai"))
{
Application.OpenURL("https://wit.ai/apps");
}
GUILayout.Label("Wit.ai Sample Application File");
GUILayout.BeginHorizontal();
if (GUILayout.Button("Open In Explorer"))
{
EditorUtility.RevealInFinder("Assets/Oculus/Voice/Demo/Data/");
}
if (GUILayout.Button("Copy Path"))
{
GUIUtility.systemCopyBuffer = Application.dataPath + "/Oculus/Voice/Demo/Data";
}
GUILayout.EndHorizontal();
}
}
#endif
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7123fd6df18ed94c8e232bfe699014a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 01140a1e45fc04b4dad90190533566a1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e6b205bdeb6af41b78c76b629f0634a6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 89232d6dd6475634a989a733ca609d72
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8af63f3a49855bc49ab30a54897228fc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
{
"name": "AssistantCoreSDKEditor",
"references": [
"GUID:a7c32ded21d3b9b42a71cdf39f2ed8da"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a32f21e557428c84e845c18e46d9284f
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 13ae9debef50c7e46a015123dfc48813
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,118 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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.
**************************************************************************************************/
// Based off Unity forum post https://forum.unity.com/threads/how-to-change-the-name-of-list-elements-in-the-inspector.448910/
using UnityEditor;
using UnityEngine;
namespace Oculus.Voice.Core.Utilities
{
[CustomPropertyDrawer(typeof(ArrayElementTitleAttribute))]
public class ArrayElementTitleDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property,
GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
protected virtual ArrayElementTitleAttribute Attribute
{
get { return (ArrayElementTitleAttribute) attribute; }
}
SerializedProperty titleNameProp;
public override void OnGUI(Rect position,
SerializedProperty property,
GUIContent label)
{
string name = null;
if (string.IsNullOrEmpty(Attribute.varname))
{
titleNameProp = property.serializedObject.FindProperty(property.propertyPath);
}
else
{
string fullPathName = property.propertyPath + "." + Attribute.varname;
titleNameProp = property.serializedObject.FindProperty(fullPathName);
}
if (null != titleNameProp)
{
name = GetTitle();
}
if (string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(Attribute.fallbackName))
{
name = Attribute.fallbackName;
}
if (string.IsNullOrEmpty(name))
{
name = label.text;
}
EditorGUI.PropertyField(position, property, new GUIContent(name, label.tooltip), true);
}
private string GetTitle()
{
switch (titleNameProp.propertyType)
{
case SerializedPropertyType.Generic:
break;
case SerializedPropertyType.Integer:
return titleNameProp.intValue.ToString();
case SerializedPropertyType.Boolean:
return titleNameProp.boolValue.ToString();
case SerializedPropertyType.Float:
return titleNameProp.floatValue.ToString();
case SerializedPropertyType.String:
return titleNameProp.stringValue;
case SerializedPropertyType.Color:
return titleNameProp.colorValue.ToString();
case SerializedPropertyType.ObjectReference:
return titleNameProp.objectReferenceValue?.ToString();
case SerializedPropertyType.LayerMask:
break;
case SerializedPropertyType.Enum:
return titleNameProp.enumNames[titleNameProp.enumValueIndex];
case SerializedPropertyType.Vector2:
return titleNameProp.vector2Value.ToString();
case SerializedPropertyType.Vector3:
return titleNameProp.vector3Value.ToString();
case SerializedPropertyType.Vector4:
return titleNameProp.vector4Value.ToString();
case SerializedPropertyType.Rect:
break;
case SerializedPropertyType.ArraySize:
break;
case SerializedPropertyType.Character:
break;
case SerializedPropertyType.AnimationCurve:
break;
case SerializedPropertyType.Bounds:
break;
case SerializedPropertyType.Gradient:
break;
case SerializedPropertyType.Quaternion:
break;
default:
break;
}
return "";
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 99800bf0e26831a41983faa658759631
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fa3bcde078d02604fb774938a2a9ea66
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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.Reflection;
namespace Oculus.Voice.Core.Utilities
{
public class AssistantEditorUtils
{
public static T GetFieldValue<T>(object obj, string name)
{
// Set the flags so that private and public fields from instances will be found
var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var field = obj.GetType().GetField(name, bindingFlags);
return (T) field?.GetValue(obj);
}
public static void SetFieldValue<T>(object obj, string name, T value)
{
// Set the flags so that private and public fields from instances will be found
var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var field = obj.GetType().GetField(name, bindingFlags);
field?.SetValue(obj, value);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91dbfa5ea168d9444aeca84e19716861
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 08b982f4564aa084e9f123b2855d6881
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 719ae09d6be753e46845c9b349912e3e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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 Oculus.Voice.Core.Bindings.Interfaces;
using UnityEngine;
namespace Oculus.Voice.Core.Bindings.Android
{
public class AndroidServiceConnection : IConnection
{
private AndroidJavaObject mAssistantServiceConnection;
private string serviceFragmentClass;
private string serviceGetter;
public bool IsConnected => null != mAssistantServiceConnection;
public AndroidJavaObject AssistantServiceConnection => mAssistantServiceConnection;
/// <summary>
/// Creates a connection manager of the given type
/// </summary>
/// <param name="serviceFragmentClassName">The fully qualified class name of the service fragment that will manage this connection</param>
/// <param name="serviceGetterMethodName">The name of the method that will return an instance of the service</param>
/// TODO: We should make the getBlahService simply getService() within each fragment implementation.
public AndroidServiceConnection(string serviceFragmentClassName, string serviceGetterMethodName)
{
serviceFragmentClass = serviceFragmentClassName;
serviceGetter = serviceGetterMethodName;
}
public void Connect()
{
if (null == mAssistantServiceConnection)
{
AndroidJNIHelper.debug = true;
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
using (AndroidJavaClass assistantBackgroundFragment = new AndroidJavaClass(serviceFragmentClass))
{
mAssistantServiceConnection =
assistantBackgroundFragment.CallStatic<AndroidJavaObject>("createAndAttach", activity);
}
}
}
public void Disconnect()
{
mAssistantServiceConnection.Call("detach");
}
public AndroidJavaObject GetService()
{
return mAssistantServiceConnection.Call<AndroidJavaObject>(serviceGetter);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85f4ff04745e1ab459e49eb38bc288b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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;
namespace Oculus.Voice.Core.Bindings.Android
{
public class BaseAndroidConnectionImpl<T> where T : BaseServiceBinding
{
private string fragmentClassName;
protected T service;
protected readonly AndroidServiceConnection serviceConnection;
public bool IsConnected => serviceConnection.IsConnected;
public BaseAndroidConnectionImpl(string className)
{
fragmentClassName = className;
serviceConnection = new AndroidServiceConnection(className, "getService");
}
#region Service Connection
public virtual void Connect()
{
serviceConnection.Connect();
var serviceInstance = serviceConnection.GetService();
if (null == serviceInstance)
{
throw new Exception("Unable to get service connection from " + fragmentClassName);
}
service = (T) Activator.CreateInstance(typeof(T), serviceInstance);
}
public virtual void Disconnect()
{
service.Shutdown();
serviceConnection.Disconnect();
service = null;
}
#endregion
}
public class BaseServiceBinding
{
protected AndroidJavaObject binding;
protected BaseServiceBinding(AndroidJavaObject sdkInstance)
{
binding = sdkInstance;
}
public void Shutdown()
{
binding.Call("shutdown");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aa5e9cb2d6b763f4c983b82092bb192d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
{
"name": "AssistantCoreSDKRuntime"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a7c32ded21d3b9b42a71cdf39f2ed8da
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a116b0921542354a9d57799cba768bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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.
**************************************************************************************************/
namespace Oculus.Voice.Core.Bindings.Interfaces
{
public interface IConnection
{
void Connect();
void Disconnect();
bool IsConnected { get; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0a8340504b2574441afe16939acde7ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 48dd050ce4e9b904fa2888ae3c2724d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
/**************************************************************************************************
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Utilities 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.
**************************************************************************************************/
// Based off Unity forum post https://forum.unity.com/threads/how-to-change-the-name-of-list-elements-in-the-inspector.448910/
using UnityEngine;
namespace Oculus.Voice.Core.Utilities
{
public class ArrayElementTitleAttribute : PropertyAttribute
{
public string varname;
public string fallbackName;
public ArrayElementTitleAttribute(string elementTitleVar = null, string fallbackName = null)
{
varname = elementTitleVar;
this.fallbackName = fallbackName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd85a8631126f474f8d69375b5cc2bf4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0506c1dcc88b4d2db266065e8aa3deb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
Copyright (c) 2021, Wit.ai, Inc. All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to
use, copy, modify, and distribute this software in source code or binary
form for use in connection with the web services and APIs provided by
Wit.ai.
As with any software that integrates with the Wit.ai platform, your use
of this software is subject to the Wit.ai Terms of Service
[https://wit.ai/terms]. This copyright notice shall be included in all
copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ca52cefa5d9be7643968c328c2c55512
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 13bc28f0ddcf2524286888da398e2c5a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,120 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2494780024417762855
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2494780024417762853}
- component: {fileID: 2494780024417762852}
m_Layer: 0
m_Name: Wit
m_TagString: Untagged
m_Icon: {fileID: 2800000, guid: d3b5ac4c8b01ef14a8a66d7e2a4991cc, type: 3}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2494780024417762853
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2494780024417762855}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2494780024417762852
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2494780024417762855}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 89cc923dc7c7b4f0b91a7df096c80b00, type: 3}
m_Name:
m_EditorClassIdentifier:
configuration: {fileID: 0}
minKeepAliveVolume: 0.01
minKeepAliveTime: 2
maxRecordingTime: 10
events:
OnResponse:
m_PersistentCalls:
m_Calls: []
OnError:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_MethodName:
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
OnMicLevelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_MethodName: set_fillAmount
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
OnStartListening:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_MethodName: set_text
m_Mode: 5
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument: Deactivate
m_BoolArgument: 0
m_CallState: 2
OnStoppedListening:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_MethodName: set_text
m_Mode: 5
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument: Activate
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 0}
m_MethodName: set_fillAmount
m_Mode: 4
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dc847e9f83e1d68469a4741be4840ccf
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5b027aeb22062344bac09580e2a41e81
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,116 @@
fileFormatVersion: 2
guid: 2ed0be21c4a8bce4fadffab71d5b6e85
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -0,0 +1,116 @@
fileFormatVersion: 2
guid: 6a61dbb599169b64ca5584c8eebeb69e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -0,0 +1,116 @@
fileFormatVersion: 2
guid: d3b5ac4c8b01ef14a8a66d7e2a4991cc
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0c637df927b25624d9774400db7b0d1a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 16a820272b4003349b419acb053e0bca
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,156 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Facebook.WitAi.Data.Configuration;
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi
{
public abstract class BaseWitWindow : EditorWindow
{
protected static WitConfiguration[] witConfigs = Array.Empty<WitConfiguration>();
protected static string[] witConfigNames = Array.Empty<string>();
protected int witConfigIndex = -1;
protected WitConfiguration witConfiguration;
public static WitConfiguration[] WitConfigs => witConfigs;
public static string[] WitConfigNames => witConfigNames;
protected virtual string HeaderLink => null;
protected virtual void OnEnable()
{
RefreshConfigList();
}
protected virtual void OnDisable()
{
}
protected virtual void OnProjectChange()
{
RefreshConfigList();
}
protected void RefreshContent()
{
if (witConfiguration) witConfiguration.UpdateData();
}
protected static void RefreshConfigList()
{
string[] guids = AssetDatabase.FindAssets("t:WitConfiguration");
witConfigs = new WitConfiguration[guids.Length];
witConfigNames = new string[guids.Length];
for (int i = 0; i < guids.Length; i++) //probably could get optimized
{
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
witConfigs[i] = AssetDatabase.LoadAssetAtPath<WitConfiguration>(path);
witConfigNames[i] = witConfigs[i].name;
}
}
protected virtual void OnGUI()
{
minSize = new Vector2(450, 300);
DrawHeader();
GUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
OnDrawContent();
GUILayout.EndVertical();
}
protected abstract void OnDrawContent();
protected void DrawHeader()
{
DrawHeader(HeaderLink);
}
public static void DrawHeader(string headerLink = null, Texture2D header = null)
{
GUILayout.BeginVertical();
GUILayout.Space(16);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (!header) header = WitStyles.MainHeader;
var headerWidth = Mathf.Min(header.width, EditorGUIUtility.currentViewWidth - 64);
var headerHeight =
header.height * headerWidth / header.width;
if (GUILayout.Button(header, "Label", GUILayout.Width(headerWidth), GUILayout.Height(headerHeight)))
{
Application.OpenURL(!string.IsNullOrEmpty(headerLink)
? headerLink
: "https://wit.ai");
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(16);
GUILayout.EndVertical();
}
protected bool DrawWitConfigurationPopup()
{
if (null == witConfigs) return false;
bool changed = false;
if (witConfigs.Length == 1)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Wit Configuration");
EditorGUILayout.LabelField(witConfigNames[0], EditorStyles.popup);
GUILayout.EndHorizontal();
}
else
{
var selectedConfig = EditorGUILayout.Popup("Wit Configuration", witConfigIndex, witConfigNames);
if (selectedConfig != witConfigIndex)
{
witConfigIndex = selectedConfig;
changed = true;
}
}
if (changed || witConfigs.Length > 0 && !witConfiguration)
{
if (witConfigIndex < 0 || witConfigIndex >= witConfigs.Length)
{
witConfigIndex = 0;
}
witConfiguration = witConfigs[witConfigIndex];
RefreshContent();
}
return changed;
}
public static void BeginCenter(int width = -1)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (width > 0)
{
GUILayout.BeginVertical(GUILayout.Width(width));
}
else
{
GUILayout.BeginVertical();
}
}
public static void EndCenter()
{
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: cb1fb949657a24a43bce2710d35ef1df
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_ViewDataDictionary: {instanceID: 0}
- witIcon: {fileID: 2800000, guid: d3b5ac4c8b01ef14a8a66d7e2a4991cc, type: 3}
- mainHeader: {fileID: 2800000, guid: 6a61dbb599169b64ca5584c8eebeb69e, type: 3}
- continueButton: {fileID: 2800000, guid: 2ed0be21c4a8bce4fadffab71d5b6e85, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 26754a049aa53d445a323de4dcb955e3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Linq;
using Facebook.WitAi.Data.Configuration;
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi.CallbackHandlers
{
public class SimpleIntentHandlerEditor : Editor
{
private SimpleIntentHandler handler;
private string[] intentNames;
private int intentIndex;
private void OnEnable()
{
handler = target as SimpleIntentHandler;
}
public override void OnInspectorGUI()
{
if (!handler.wit)
{
GUILayout.Label(
"Wit component is not present in the scene. Add wit to scene to get intent and entity suggestions.",
EditorStyles.helpBox);
}
if (handler && handler.wit && null == intentNames)
{
if (handler.wit is IWitRuntimeConfigProvider provider && null != provider.RuntimeConfiguration && provider.RuntimeConfiguration.witConfiguration)
{
provider.RuntimeConfiguration.witConfiguration.UpdateData();
intentNames = provider.RuntimeConfiguration.witConfiguration.intents.Select(i => i.name).ToArray();
intentIndex = Array.IndexOf(intentNames, handler.intent);
}
}
WitEditorUI.FallbackPopup(serializedObject, "intent",
intentNames, ref intentIndex);
var confidenceProperty = serializedObject.FindProperty("confidence");
EditorGUILayout.PropertyField(confidenceProperty);
GUILayout.Space(16);
var eventProperty = serializedObject.FindProperty("onIntentTriggered");
EditorGUILayout.PropertyField(eventProperty);
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 10996c842bbaede43a73adef9cddba5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Linq;
using Facebook.WitAi.Data.Configuration;
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi.CallbackHandlers
{
public class SimpleStringEntityHandlerEditor : Editor
{
private SimpleStringEntityHandler handler;
private string[] intentNames;
private int intentIndex;
private string[] entityNames;
private int entityIndex;
private void OnEnable()
{
handler = target as SimpleStringEntityHandler;
if (handler && handler.wit && null == intentNames)
{
if (handler.wit is IWitRuntimeConfigProvider provider &&
null != provider.RuntimeConfiguration &&
provider.RuntimeConfiguration.witConfiguration)
{
provider.RuntimeConfiguration.witConfiguration.UpdateData();
intentNames = provider.RuntimeConfiguration.witConfiguration.intents.Select(i => i.name).ToArray();
intentIndex = Array.IndexOf(intentNames, handler.intent);
}
}
}
public override void OnInspectorGUI()
{
var handler = target as SimpleStringEntityHandler;
if (!handler) return;
if (!handler.wit)
{
GUILayout.Label("Wit component is not present in the scene. Add wit to scene to get intent and entity suggestions.", EditorStyles.helpBox);
}
var intentChanged = WitEditorUI.FallbackPopup(serializedObject,"intent", intentNames, ref intentIndex);
if (intentChanged ||
null != intentNames && intentNames.Length > 0 && null == entityNames)
{
if (handler && handler.wit && null == intentNames)
{
if (handler.wit is IWitRuntimeConfigProvider provider &&
null != provider.RuntimeConfiguration &&
provider.RuntimeConfiguration.witConfiguration)
{
var entities = provider.RuntimeConfiguration.witConfiguration.intents[intentIndex]?.entities;
if (null != entities)
{
entityNames = entities.Select((e) => e.name).ToArray();
entityIndex = Array.IndexOf(entityNames, handler.entity);
}
}
}
}
WitEditorUI.FallbackPopup(serializedObject, "entity", entityNames, ref entityIndex);
var confidenceProperty = serializedObject.FindProperty("confidence");
EditorGUILayout.PropertyField(confidenceProperty);
EditorGUILayout.Space(16);
var formatProperty = serializedObject.FindProperty("format");
EditorGUILayout.PropertyField(formatProperty);
GUILayout.Space(16);
var eventProperty = serializedObject.FindProperty("onIntentEntityTriggered");
EditorGUILayout.PropertyField(eventProperty);
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a303e99a01d07d54e9659f3b46adbe25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,241 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System.Collections.Generic;
using Facebook.WitAi.Data;
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi.CallbackHandlers
{
public class ValuePathMatcherPropertyDrawer : PropertyDrawer
{
private string currentEditPath;
class Properties
{
public const string witValueRef = "witValueReference";
public const string path = "path";
public const string contentRequired = "contentRequired";
public const string matchMethod = "matchMethod";
public const string comparisonMethod = "comparisonMethod";
public const string matchValue = "matchValue";
public const string floatingPointComparisonTolerance =
"floatingPointComparisonTolerance";
}
private Dictionary<string, bool> foldouts =
new Dictionary<string, bool>();
private string GetPropertyPath(SerializedProperty property)
{
var valueRefProp = property.FindPropertyRelative(Properties.witValueRef);
if (valueRefProp.objectReferenceValue)
{
return ((WitValue) valueRefProp.objectReferenceValue).path;
}
return property.FindPropertyRelative(Properties.path).stringValue;
}
private bool IsEditingProperty(SerializedProperty property)
{
var path = GetPropertyPath(property);
return path == currentEditPath || string.IsNullOrEmpty(path);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = 0;
// Path
height += EditorGUIUtility.singleLineHeight;
if (IsExpanded(property))
{
// Content Required
height += EditorGUIUtility.singleLineHeight;
// Match Method
height += EditorGUIUtility.singleLineHeight;
if (ComparisonMethodsVisible(property))
{
// Comparison Method
height += EditorGUIUtility.singleLineHeight;
}
if (ComparisonValueVisible(property))
{
// Comparison Value
height += EditorGUIUtility.singleLineHeight;
}
if (FloatingToleranceVisible(property))
{
// Floating Point Tolerance
height += EditorGUIUtility.singleLineHeight;
}
height += 4;
}
return height;
}
private bool IsExpanded(SerializedProperty property)
{
return foldouts.TryGetValue(GetPropertyPath(property), out bool value) && value;
}
private bool Foldout(Rect rect, SerializedProperty property)
{
var path = GetPropertyPath(property);
if (!foldouts.TryGetValue(path, out var value))
{
foldouts[path] = false;
}
foldouts[path] = EditorGUI.Foldout(rect, value, "");
return foldouts[path];
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var rect = new Rect(position);
rect.height = EditorGUIUtility.singleLineHeight;
var path = property.FindPropertyRelative(Properties.path);
var valueRefProp = property.FindPropertyRelative(Properties.witValueRef);
var editIconWidth = 24;
var pathRect = new Rect(rect);
pathRect.width -= editIconWidth;
var pathValue = GetPropertyPath(property);
if (IsEditingProperty(property))
{
if (!valueRefProp.objectReferenceValue)
{
pathRect.width -= WitStyles.IconButtonWidth;
var value = EditorGUI.TextField(pathRect, path.stringValue);
if (value != path.stringValue)
{
path.stringValue = value;
}
pathRect.width += WitStyles.IconButtonWidth;
var pickerRect = new Rect(pathRect);
pickerRect.x = pathRect.x + pathRect.width - 20;
pickerRect.width = 20;
if (GUI.Button(pickerRect, WitStyles.ObjectPickerIcon, "Label"))
{
var id = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
EditorGUIUtility.ShowObjectPicker<WitValue>(
(WitValue) valueRefProp.objectReferenceValue, false, "", id);
}
}
else
{
EditorGUI.PropertyField(pathRect, valueRefProp, new GUIContent());
}
if (Event.current.commandName == "ObjectSelectorClosed")
{
valueRefProp.objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
}
pathValue = GetPropertyPath(property);
if (pathValue != currentEditPath && null != currentEditPath)
{
foldouts[currentEditPath] = false;
currentEditPath = GetPropertyPath(property);
foldouts[currentEditPath] = true;
}
}
else
{
if (valueRefProp.objectReferenceValue)
{
EditorGUI.LabelField(pathRect, valueRefProp.objectReferenceValue.name);
}
else
{
EditorGUI.LabelField(pathRect, path.stringValue);
}
}
var editRect = new Rect(rect);
editRect.x = pathRect.x + pathRect.width + 8;
if (Foldout(rect, property))
{
if (GUI.Button(editRect, WitStyles.EditIcon, "Label"))
{
if (currentEditPath == pathValue)
{
currentEditPath = null;
}
else
{
currentEditPath = pathValue;
}
}
rect.x += WitStyles.IconButtonWidth;
rect.width -= WitStyles.IconButtonWidth;
rect.y += rect.height;
EditorGUI.PropertyField(rect, property.FindPropertyRelative(Properties.contentRequired));
rect.y += rect.height;
EditorGUI.PropertyField(rect, property.FindPropertyRelative(Properties.matchMethod));
if (ComparisonMethodsVisible(property))
{
rect.y += rect.height;
EditorGUI.PropertyField(rect,
property.FindPropertyRelative(Properties.comparisonMethod));
}
if (ComparisonValueVisible(property))
{
rect.y += rect.height;
EditorGUI.PropertyField(rect,
property.FindPropertyRelative(Properties.matchValue));
}
if (FloatingToleranceVisible(property))
{
rect.y += rect.height;
EditorGUI.PropertyField(rect,
property.FindPropertyRelative(Properties.floatingPointComparisonTolerance));
}
}
}
private bool ComparisonMethodsVisible(SerializedProperty property)
{
var matchedMethodProperty = property.FindPropertyRelative(Properties.matchMethod);
return matchedMethodProperty.enumValueIndex > (int) MatchMethod.RegularExpression;
}
private bool ComparisonValueVisible(SerializedProperty property)
{
var matchedMethodProperty = property.FindPropertyRelative(Properties.matchMethod);
return matchedMethodProperty.enumValueIndex > 0;
}
private bool FloatingToleranceVisible(SerializedProperty property)
{
var matchedMethodProperty = property.FindPropertyRelative(Properties.matchMethod);
var comparisonMethodProperty =
property.FindPropertyRelative(Properties.comparisonMethod);
var comparisonMethod = comparisonMethodProperty.enumValueIndex;
return matchedMethodProperty.enumValueIndex >= (int) MatchMethod.FloatComparison &&
(comparisonMethod == (int) ComparisonMethod.Equals || comparisonMethod == (int) ComparisonMethod.NotEquals);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70c91e08d884bfe4a99b40d2706b15d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 817d0e10131c4339849a5c99f8fb082b
timeCreated: 1624319154

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d192dfd6dc3ff0240b7171d81525428b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.WitAi.Data.Configuration
{
public interface IApplicationDetailProvider
{
void DrawApplication(WitApplication application);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ed426c1b615d4b44a3c55c12850ce15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using UnityEngine;
namespace Facebook.WitAi.Data.Configuration
{
public class WitApplicationDetailProvider : IApplicationDetailProvider
{
public void DrawApplication(WitApplication application)
{
if (string.IsNullOrEmpty(application.name))
{
GUILayout.Label("Loading...");
}
else
{
InfoField("Name", application.name);
InfoField("ID", application.id);
InfoField("Language", application.lang);
InfoField("Created", application.createdAt);
GUILayout.BeginHorizontal();
GUILayout.Label("Private", GUILayout.Width(100));
GUILayout.Toggle(application.isPrivate, "");
GUILayout.EndHorizontal();
}
}
private void InfoField(string name, string value)
{
GUILayout.BeginHorizontal();
GUILayout.Label(name, GUILayout.Width(100));
GUILayout.Label(value, "TextField");
GUILayout.EndHorizontal();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 394d4d63ba17f4ed5918eccdd3b7059f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,565 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using Facebook.WitAi.Configuration;
using Facebook.WitAi.Data.Entities;
using Facebook.WitAi.Data.Intents;
using Facebook.WitAi.Data.Traits;
using Facebook.WitAi.Utilities;
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi.Data.Configuration
{
public class WitConfigurationEditor : Editor
{
public IApplicationDetailProvider appDrawer = new WitApplicationDetailProvider();
private WitConfiguration configuration;
private Dictionary<string, bool> foldouts = new Dictionary<string, bool>();
private int selectedToolPanel;
private readonly string[] toolPanelNames = new[]
{
"Application",
"Intents",
"Entities",
"Traits"
};
private readonly string[] toolPanelNamesOnlyAppInfo = new[]
{
"Application"
};
private readonly string[] toolPanelNamesWithoutAppInfo = new[]
{
"Intents",
"Entities",
"Traits"
};
private const int TOOL_PANEL_APP = 0;
private const int TOOL_PANEL_INTENTS = 1;
private const int TOOL_PANEL_ENTITIES = 2;
private const int TOOL_PANEL_TRAITS = 3;
private Editor applicationEditor;
private Vector2 scroll;
private bool appConfigurationFoldout;
private bool initialized = false;
public bool drawHeader = true;
private string currentToken;
private bool endpointConfigurationFoldout;
private bool IsTokenValid => !string.IsNullOrEmpty(configuration.clientAccessToken) &&
configuration.clientAccessToken.Length == 32;
public void Initialize()
{
WitAuthUtility.InitEditorTokens();
configuration = target as WitConfiguration;
currentToken = WitAuthUtility.GetAppServerToken(configuration);
if (WitAuthUtility.IsServerTokenValid(currentToken) && !string.IsNullOrEmpty(configuration?.clientAccessToken))
{
configuration?.UpdateData(() =>
{
EditorUtility.SetDirty(configuration);
});
}
}
public override void OnInspectorGUI()
{
if (!initialized || configuration != target)
{
Initialize();
initialized = true;
}
if (drawHeader)
{
string link = null;
if (configuration && null != configuration.application &&
!string.IsNullOrEmpty(configuration.application.id))
{
link = $"https://wit.ai/apps/{configuration.application.id}/settings";
}
BaseWitWindow.DrawHeader(headerLink: link);
}
GUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.BeginHorizontal();
GUILayout.Space(16);
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
appConfigurationFoldout = EditorGUILayout.Foldout(appConfigurationFoldout,
"Application Configuration", true);
if (!string.IsNullOrEmpty(configuration?.application?.name))
{
GUILayout.FlexibleSpace();
GUILayout.Label(configuration?.application?.name);
}
GUILayout.EndHorizontal();
bool hasApplicationInfo = configuration && null != configuration.application;
if (appConfigurationFoldout || !IsTokenValid)
{
GUILayout.BeginHorizontal();
var token = EditorGUILayout.PasswordField("Server Access Token", currentToken);
if (token != currentToken)
{
currentToken = token;
ApplyToken(token);
}
if (configuration && GUILayout.Button("Refresh", GUILayout.Width(75)))
{
ApplyToken(currentToken);
}
if (GUILayout.Button(WitStyles.PasteIcon, WitStyles.ImageIcon))
{
currentToken = EditorGUIUtility.systemCopyBuffer;
ApplyToken(currentToken);
}
GUILayout.EndHorizontal();
if (configuration)
{
var clientToken =
EditorGUILayout.PasswordField("Client Access Token",
configuration.clientAccessToken);
if (clientToken != configuration.clientAccessToken)
{
configuration.clientAccessToken = clientToken;
EditorUtility.SetDirty(configuration);
}
var timeout = EditorGUILayout.IntField(new GUIContent("Request Timeout (ms)", "The amount of time a server request can take to respond to voice."), configuration.timeoutMS);
if (timeout != configuration.timeoutMS)
{
configuration.timeoutMS = timeout;
EditorUtility.SetDirty(configuration);
}
GUILayout.BeginHorizontal();
GUILayout.Space(16);
GUILayout.BeginVertical();
endpointConfigurationFoldout = EditorGUILayout.Foldout(endpointConfigurationFoldout,
"Endpoint Configuration", true);
GUILayout.BeginHorizontal();
GUILayout.Space(16);
GUILayout.BeginVertical();
if (endpointConfigurationFoldout)
{
if (null == configuration.endpointConfiguration)
{
configuration.endpointConfiguration = new WitEndpointConfig();
EditorUtility.SetDirty(configuration);
}
var confSerializedObject = new SerializedObject(configuration);
var epConfProp = confSerializedObject.FindProperty("endpointConfiguration");
EditorGUILayout.PropertyField(epConfProp);
confSerializedObject.ApplyModifiedProperties();
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
}
GUILayout.EndVertical();
GUILayout.EndVertical();
GUILayout.EndHorizontal();
if (hasApplicationInfo)
{
if (configuration.application.id != null && !configuration.application.id.StartsWith("voice"))
{
selectedToolPanel = GUILayout.Toolbar(selectedToolPanel, toolPanelNames);
}
else
{
selectedToolPanel = GUILayout.Toolbar(selectedToolPanel, toolPanelNamesOnlyAppInfo);
}
}
else
{
selectedToolPanel = GUILayout.Toolbar(selectedToolPanel, toolPanelNamesWithoutAppInfo);
}
scroll = GUILayout.BeginScrollView(scroll);
switch (hasApplicationInfo ? selectedToolPanel : selectedToolPanel + 1)
{
case TOOL_PANEL_APP:
DrawApplication(configuration.application);
break;
case TOOL_PANEL_INTENTS:
DrawIntents();
break;
case TOOL_PANEL_ENTITIES:
DrawEntities();
break;
case TOOL_PANEL_TRAITS:
DrawTraits();
break;
}
GUILayout.EndScrollView();
if (GUILayout.Button("Open Wit.ai"))
{
if (!string.IsNullOrEmpty(configuration.application?.id))
{
Application.OpenURL($"https://wit.ai/apps/{configuration.application.id}");
}
else
{
Application.OpenURL("https://wit.ai");
}
}
}
private void ApplyToken(string token)
{
if (!string.IsNullOrEmpty(token) && WitAuthUtility.IsServerTokenValid(token))
{
RefreshAppData(WitAuthUtility.GetAppId(token), token);
}
}
private void RefreshAppData(string appId, string token = "")
{
var refreshToken = WitAuthUtility.GetAppServerToken(appId, token);
if (string.IsNullOrEmpty(refreshToken) &&
string.IsNullOrEmpty(appId) &&
!string.IsNullOrEmpty(configuration?.application?.id))
{
refreshToken = WitAuthUtility.GetAppServerToken(configuration.application.id,
WitAuthUtility.ServerToken);
appId = WitAuthUtility.GetAppId(refreshToken);
if (string.IsNullOrEmpty(appId))
{
UpdateTokenData(refreshToken, () =>
{
appId = WitAuthUtility.GetAppId(refreshToken);
if (appId == configuration.application.id)
{
configuration.FetchAppConfigFromServerToken(refreshToken, () =>
{
currentToken = refreshToken;
WitAuthUtility.SetAppServerToken(configuration.application.id, currentToken);
EditorUtility.SetDirty(configuration);
Repaint();
appConfigurationFoldout = false;
});
}
});
return;
}
if (appId == configuration.application.id)
{
refreshToken = WitAuthUtility.ServerToken;
}
}
if (currentToken != refreshToken)
{
currentToken = refreshToken;
}
configuration.FetchAppConfigFromServerToken(refreshToken, () =>
{
currentToken = refreshToken;
Repaint();
appConfigurationFoldout = false;
});
}
public static void UpdateTokenData(string serverToken, Action updateComplete = null)
{
if (!WitAuthUtility.IsServerTokenValid(serverToken)) return;
var listRequest = WitRequestFactory.ListAppsRequest(serverToken, 10000);
listRequest.onResponse = (r) =>
{
if (r.StatusCode == 200)
{
var applications = r.ResponseData.AsArray;
for (int i = 0; i < applications.Count; i++)
{
if (applications[i]["is_app_for_token"].AsBool)
{
var application = WitApplication.FromJson(applications[i]);
WitAuthUtility.SetAppServerToken(application.id, serverToken);
updateComplete?.Invoke();
break;
}
}
}
else
{
Debug.LogError(r.StatusDescription);
}
};
listRequest.Request();
}
private void DrawTraits()
{
var traits = configuration.traits;
if (null != traits)
{
var n = traits.Length;
if (n == 0)
{
GUILayout.Label("No traits available.");
}
else
{
BeginIndent();
for (int i = 0; i < n; i++)
{
var trait = traits[i];
if (null != trait && Foldout("t:", trait.name))
{
DrawTrait(trait);
}
}
EndIndent();
}
}
else
{
GUILayout.Label("Traits have not been loaded yet.", EditorStyles.helpBox);
}
}
private void DrawTrait(WitTrait trait)
{
InfoField("ID", trait.id);
InfoField("Name", trait.name);
GUILayout.BeginHorizontal();
GUILayout.Label("Values", GUILayout.Width(100));
GUILayout.EndHorizontal();
var values = trait.values;
var n = values.Length;
if (n == 0)
{
GUILayout.Label("No values available.");
}
else
{
BeginIndent();
for (int i = 0; i < n; i++)
{
var value = values[i];
if (null != value && Foldout("v:", value.value))
{
DrawTraitValue(value);
}
}
EndIndent();
}
}
private void DrawTraitValue(WitTraitValue traitValue)
{
InfoField("ID", traitValue.id);
InfoField("Value", traitValue.value);
}
private void DrawEntities()
{
var entities = configuration.entities;
if (null != entities)
{
var n = entities.Length;
if (n == 0)
{
GUILayout.Label("No entities available.");
}
else
{
BeginIndent();
for (int i = 0; i < n; i++)
{
var entity = entities[i];
if (null != entity && Foldout("e:", entity.name))
{
DrawEntity(entity);
}
}
EndIndent();
}
}
else
{
GUILayout.Label("Entities have not been loaded yet.", EditorStyles.helpBox);
}
}
private void DrawApplication(WitApplication application)
{
appDrawer.DrawApplication(application);
}
private void DrawEntity(WitEntity entity)
{
BeginIndent();
InfoField("ID", entity.id);
if (entity.roles != null && entity.roles.Length > 0)
{
var entityRoles = entity.roles.Select(e => e.name).ToArray();
DrawStringArray("Roles", entityRoles, entity.roles.GetHashCode().ToString());
}
DrawStringArray("Lookups", entity.lookups);
EndIndent();
}
private void DrawIntents()
{
var intents = configuration.intents;
if (null != intents)
{
var n = intents.Length;
if (n == 0)
{
GUILayout.Label("No intents available.");
}
else
{
BeginIndent();
for (int i = 0; i < n; i++)
{
var intent = intents[i];
if (null != intent && Foldout("i:", intent.name))
{
DrawIntent(intent);
}
}
EndIndent();
}
}
else
{
GUILayout.Label("Intents have not been loaded yet.", EditorStyles.helpBox);
}
}
private void DrawIntent(WitIntent intent)
{
BeginIndent();
InfoField("ID", intent.id);
var entities = intent.entities;
if (entities.Length > 0)
{
var entityNames = entities.Select(e => e.name).ToArray();
DrawStringArray("Entities", entityNames, intent.entities.GetHashCode().ToString());
}
EndIndent();
}
private void DrawStringArray(string displayName, string[] vals, string keybase = "")
{
if (vals != null && vals.Length > 0)
{
if (string.IsNullOrEmpty(keybase))
{
keybase = vals.GetHashCode().ToString();
}
if (Foldout(keybase, displayName))
{
BeginIndent();
BeginIndent();
for (int i = 0; i < vals.Length; i++)
{
GUILayout.Label(vals[i]);
}
EndIndent();
EndIndent();
}
}
}
#region UI Components
private void BeginIndent()
{
GUILayout.BeginHorizontal();
GUILayout.Space(10);
GUILayout.BeginVertical();
}
private void EndIndent()
{
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
private void InfoField(string name, string value)
{
GUILayout.BeginHorizontal();
GUILayout.Label(name, GUILayout.Width(100));
GUILayout.Label(value, "TextField");
GUILayout.EndHorizontal();
}
private bool Foldout(string keybase, string name)
{
string key = keybase + name;
bool show = false;
if (!foldouts.TryGetValue(key, out show))
{
foldouts[key] = false;
}
show = EditorGUILayout.Foldout(show, name, true);
foldouts[key] = show;
return show;
}
#endregion
public static WitConfiguration CreateWitConfiguration(string serverToken, Action onCreationComplete)
{
var path = EditorUtility.SaveFilePanel("Create Wit Configuration", Application.dataPath,
"WitConfiguration", "asset");
if (!string.IsNullOrEmpty(path) && path.StartsWith(Application.dataPath))
{
WitConfiguration asset = ScriptableObject.CreateInstance<WitConfiguration>();
asset.FetchAppConfigFromServerToken(serverToken, onCreationComplete);
path = path.Substring(Application.dataPath.Length - 6);
AssetDatabase.CreateAsset(asset, path);
AssetDatabase.SaveAssets();
return asset;
}
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fda2e192978913c42af9533c9a0baa01
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,216 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Facebook.WitAi.Data.Entities;
using Facebook.WitAi.Data.Intents;
using Facebook.WitAi.Data.Traits;
using Facebook.WitAi.Lib;
using Facebook.WitAi.Utilities;
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi.Data.Configuration
{
public static class WitConfigurationUtility
{
#if UNITY_EDITOR
public static void UpdateData(this WitConfiguration configuration,
Action onUpdateComplete = null)
{
DoUpdateData(configuration, onUpdateComplete);
}
private static void DoUpdateData(WitConfiguration configuration, Action onUpdateComplete)
{
if (!string.IsNullOrEmpty(
WitAuthUtility.GetAppServerToken(configuration.application.id)))
{
var intentsRequest = configuration.ListIntentsRequest();
intentsRequest.onResponse =
(r) => ListEntities(r, configuration, onUpdateComplete);
configuration.application?.UpdateData(intentsRequest.Request);
}
}
private static void ListEntities(WitRequest r, WitConfiguration configuration, Action onUpdateComplete)
{
var entitiesRequest = configuration.ListEntitiesRequest();
entitiesRequest.onResponse = (er) => ListTraits(er, configuration, onUpdateComplete);
OnUpdateData(r, (response) => UpdateIntentList(configuration, response),
entitiesRequest.Request);
}
private static void ListTraits(WitRequest er, WitConfiguration configuration, Action onUpdateComplete)
{
var traitsRequest = configuration.ListTraitsRequest();
traitsRequest.onResponse =
(tr) =>
{
OnUpdateData(tr,
(dataResponse) => UpdateTraitList(configuration, dataResponse),
onUpdateComplete);
};
OnUpdateData(er,
(entityResponse) => UpdateEntityList(configuration, entityResponse),
traitsRequest.Request);
}
private static void OnUpdateData(WitRequest request,
Action<WitResponseNode> updateComponent, Action onUpdateComplete)
{
if (request.StatusCode == 200)
{
updateComponent(request.ResponseData);
}
else
{
Debug.LogError($"Request for {request} failed: {request.StatusDescription}");
}
if (onUpdateComplete != null)
{
onUpdateComplete();
}
}
private static void UpdateIntentList(this WitConfiguration configuration,
WitResponseNode intentListWitResponse)
{
var intentList = intentListWitResponse.AsArray;
var n = intentList.Count;
configuration.intents = new WitIntent[n];
for (int i = 0; i < n; i++)
{
var intent = WitIntent.FromJson(intentList[i]);
intent.witConfiguration = configuration;
configuration.intents[i] = intent;
intent.UpdateData();
}
}
private static void UpdateEntityList(this WitConfiguration configuration,
WitResponseNode entityListWitResponse)
{
var entityList = entityListWitResponse.AsArray;
var n = entityList.Count;
configuration.entities = new WitEntity[n];
for (int i = 0; i < n; i++)
{
var entity = WitEntity.FromJson(entityList[i]);
entity.witConfiguration = configuration;
configuration.entities[i] = entity;
entity.UpdateData();
}
}
public static void UpdateTraitList(this WitConfiguration configuration,
WitResponseNode traitListWitResponse)
{
var traitList = traitListWitResponse.AsArray;
var n = traitList.Count;
configuration.traits = new WitTrait[n];
for (int i = 0; i < n; i++)
{
var trait = WitTrait.FromJson(traitList[i]);
trait.witConfiguration = configuration;
configuration.traits[i] = trait;
trait.UpdateData();
}
}
/// <summary>
/// Gets the app info and client id that is associated with the server token being used
/// </summary>
/// <param name="serverToken">The server token to use to get the app config</param>
/// <param name="action"></param>
public static void FetchAppConfigFromServerToken(this WitConfiguration configuration,
string serverToken, Action action)
{
if (WitAuthUtility.IsServerTokenValid(serverToken))
{
FetchApplicationFromServerToken(configuration, serverToken,
() =>
{
FetchClientToken(configuration,
() => { configuration.UpdateData(action); });
});
}
else
{
Debug.LogError($"No server token set for {configuration.name}.");
}
}
private static void FetchApplicationFromServerToken(WitConfiguration configuration,
string serverToken, Action response)
{
var listRequest = WitRequestFactory.ListAppsRequest(serverToken, 10000);
listRequest.onResponse = (r) =>
{
if (r.StatusCode == 200)
{
var applications = r.ResponseData.AsArray;
for (int i = 0; i < applications.Count; i++)
{
if (applications[i]["is_app_for_token"].AsBool)
{
if (null != configuration.application)
{
configuration.application.UpdateData(applications[i]);
}
else
{
configuration.application =
WitApplication.FromJson(applications[i]);
}
WitAuthUtility.SetAppServerToken(configuration.application.id, serverToken);
response?.Invoke();
break;
}
}
}
else
{
Debug.LogError(r.StatusDescription);
}
};
listRequest.Request();
}
private static void FetchClientToken(WitConfiguration configuration, Action action)
{
if (!string.IsNullOrEmpty(configuration.application?.id))
{
var tokenRequest = configuration.GetClientToken(configuration.application.id);
tokenRequest.onResponse = (r) =>
{
if (r.StatusCode == 200)
{
var token = r.ResponseData["client_token"];
SerializedObject so = new SerializedObject(configuration);
so.FindProperty("clientAccessToken").stringValue =
r.ResponseData["client_token"];
so.ApplyModifiedProperties();
configuration.clientAccessToken = token;
EditorUtility.SetDirty(configuration);
action?.Invoke();
}
else
{
Debug.LogError(r.StatusDescription);
}
};
tokenRequest.Request();
}
}
#endif
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 67da0cb4ba914f6cb2a97a343ff81db1
timeCreated: 1631316958

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using UnityEditor;
using UnityEngine;
namespace Facebook.WitAi.Configuration
{
[CustomPropertyDrawer(typeof(WitEndpointConfig))]
public class WitEndpointConfigDrawer : PropertyDrawer
{
private string editing;
private Vector2 scroll;
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return 0;
}
private void DrawProperty(SerializedProperty propery, string name,
string label, string defaultValue)
{
var propValue = propery.FindPropertyRelative(name);
GUILayout.BeginHorizontal();
if (editing == name)
{
EditorGUILayout.PropertyField(propValue, new GUIContent(label));
WitStyles.ResetIcon.tooltip = $"Reset to default values ({defaultValue})";
if (GUILayout.Button(WitStyles.ResetIcon, WitStyles.ImageIcon))
{
editing = string.Empty;
switch (propValue.type)
{
case "string":
propValue.stringValue = defaultValue;
break;
case "int":
propValue.intValue = int.Parse(defaultValue);
break;
}
}
if (GUILayout.Button(WitStyles.AcceptIcon, WitStyles.ImageIcon))
{
editing = string.Empty;
}
}
else
{
switch (propValue.type)
{
case "string":
defaultValue = string.IsNullOrEmpty(propValue.stringValue)
? defaultValue
: propValue.stringValue;
break;
case "int":
defaultValue = propValue.intValue.ToString();
break;
}
EditorGUI.BeginDisabledGroup(editing != name);
EditorGUILayout.TextField(label, defaultValue);
EditorGUI.EndDisabledGroup();
if (GUILayout.Button(WitStyles.EditIcon, WitStyles.ImageIcon))
{
if (editing == name)
{
editing = string.Empty;
}
else
{
editing = name;
}
}
}
GUILayout.EndHorizontal();
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
scroll = GUILayout.BeginScrollView(scroll, GUILayout.Height(100));
DrawProperty(property, "uriScheme", "Uri Scheme", WitRequest.URI_SCHEME);
DrawProperty(property, "authority", "Host", WitRequest.URI_AUTHORITY);
DrawProperty(property, "port", "Port", "80");
DrawProperty(property, "witApiVersion", "Wit Api Version", WitRequest.WIT_API_VERSION);
DrawProperty(property, "speech", "Speech", WitRequest.WIT_ENDPOINT_SPEECH);
DrawProperty(property, "message", "Message", WitRequest.WIT_ENDPOINT_MESSAGE);
GUILayout.EndScrollView();
}
}
}

Some files were not shown because too many files have changed in this diff Show More