Initialer Upload neues Unity-Projekt
This commit is contained in:
8
Assets/Oculus/Voice/Samples/BuiltInTimer/Audio.meta
Normal file
8
Assets/Oculus/Voice/Samples/BuiltInTimer/Audio.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c7e27799672ce2458de435c31300019
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Oculus/Voice/Samples/BuiltInTimer/Audio/TimesUp.mp3
(Stored with Git LFS)
Normal file
BIN
Assets/Oculus/Voice/Samples/BuiltInTimer/Audio/TimesUp.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b5c12aa38189a145b2a57baf2a7bf4f
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Oculus/Voice/Samples/BuiltInTimer/BuiltInTimer.unity
(Stored with Git LFS)
Normal file
BIN
Assets/Oculus/Voice/Samples/BuiltInTimer/BuiltInTimer.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e6f8accd4b079d40b3603449f318633
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Oculus/Voice/Samples/BuiltInTimer/BuiltIns Timer - WitConfiguration.asset
(Stored with Git LFS)
Normal file
BIN
Assets/Oculus/Voice/Samples/BuiltInTimer/BuiltIns Timer - WitConfiguration.asset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b48b6ce9fd2c0eb448b29ab66a197ef8
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Oculus/Voice/Samples/BuiltInTimer/Materials.meta
Normal file
8
Assets/Oculus/Voice/Samples/BuiltInTimer/Materials.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef1b718734ecc3f44a54c97b4827292c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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}
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b68ed34b82d7ad243968eee45e798c6c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Oculus/Voice/Samples/BuiltInTimer/Scripts.meta
Normal file
8
Assets/Oculus/Voice/Samples/BuiltInTimer/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 480a73091186d9c4f8d9588adca7e45e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Meta.Voice.Samples.BuiltInTimer",
|
||||
"references": [
|
||||
"GUID:4504b1a6e0fdcc3498c30b266e4a63bf",
|
||||
"GUID:1c28d8b71ced07540b7c271537363cc6"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b409cfa88b1012c48b47bf2ac9340e6d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Meta.WitAi;
|
||||
|
||||
namespace Meta.Voice.Samples.BuiltInTimer
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a countdown timer.
|
||||
/// </summary>
|
||||
public class TimerController : MonoBehaviour
|
||||
{
|
||||
private double _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[] timesUpSounds;
|
||||
|
||||
// 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("Your timer is complete.");
|
||||
AudioClip timesUpSfx = timesUpSounds[UnityEngine.Random.Range(0, timesUpSounds.Length)];
|
||||
AudioSource.PlayClipAtPoint(timesUpSfx, 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)
|
||||
{
|
||||
VLog.W("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).");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 double GetRemainingTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns time in the format of min:sec.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetFormattedTimeFromSeconds()
|
||||
{
|
||||
if (_time >= TimeSpan.MaxValue.TotalSeconds)
|
||||
{
|
||||
_time = TimeSpan.MaxValue.TotalSeconds - 1;
|
||||
Log("Error: Hit max time");
|
||||
}
|
||||
TimeSpan span = TimeSpan.FromSeconds(_time);
|
||||
return $"{Math.Floor(span.TotalHours)}:{span.Minutes:00}:{span.Seconds:00}.{Math.Floor(span.Milliseconds/100f)}";
|
||||
}
|
||||
|
||||
/// <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 double time)
|
||||
{
|
||||
time = _time;
|
||||
if (entityValues.Length > 0 && double.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf89088f719e0164b9e096a3394188b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Meta.Voice.Samples.BuiltInTimer
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5cbeedeedc01b2419d881ef197ef2d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user