using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Stary.Evo.RKTools { #if Evo_Rokid public interface IVoiceCommandSystem : ISystem { public void AddVoiceCommand(string content, string spell, Action action); public void DeleteVoiceCommand(string content); public void ClearAllVoiceCommands(); } public class VoiceCommandSystem : AbstractSystem, IVoiceCommandSystem { private VoiceCommandController _voiceController; protected virtual string ControllerName { get { return "VoiceCommandController"; } } private void createVoiceCommandContriller() { GameObject VoiceControllerObject = GameObject.Find(ControllerName); if (VoiceControllerObject == null) { VoiceControllerObject = new GameObject(ControllerName); } _voiceController = VoiceControllerObject.GetComponent(); if (_voiceController == null) { _voiceController = VoiceControllerObject.AddComponent(); } } public void AddVoiceCommand(string content, string spell, Action action) { if (_voiceController == null) createVoiceCommandContriller(); _voiceController.RegisteredVoiceCommand(content, spell, action); } public void DeleteVoiceCommand(string content) { if (_voiceController != null) _voiceController.DeleteVoiceCommand(content); } public void ClearAllVoiceCommands() { if (_voiceController != null) { _voiceController.ClearAllVoiceCommand(); GameObject.Destroy(_voiceController.gameObject); } } public override void Dispose() { ClearAllVoiceCommands(); } protected override void OnInit() { } } #endif }