惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
博客园_首页
Jina AI
Jina AI
WordPress大学
WordPress大学
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
美团技术团队
IT之家
IT之家
爱范儿
爱范儿
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】

博客园 - sun_dust_shadow

(翻译) 延迟补偿方法的协议设计与优化 Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization (翻译) Dota2 Random Distribution Dota2中的随机分布 (个人思考)游戏技能的实现 (读书笔记)平衡掌控者 [瞄准辅助] 实现一种柔和平滑的瞄准辅助 (个人思考)实现游戏GAS系统中的Tag (翻译) Efficiency Tips on Switching Spaces and Transformation Matrices in Unity (翻译) V Rising's Animation Layering in Unity (翻译 unity2020.1) Understanding the managed heap (翻译 ue gas) Gameplay Ability 总结 Overwatch Gameplay Architecture and Netcode 守望先锋的游戏架构与网络代码 (翻译 ) Source Multiplayer Networking Source引擎的多人网路系统 (翻译 gafferongames) Networked Physics in Virtual Reality VR中的网络物理 Topdown游戏中Input朝向的转化 (翻译 gafferongames) Client Server Connection 客户端服务器连接 (翻译 gafferongames)Reliable Ordered Messages 可靠有序消息 (翻译 gafferongames) Sending Large Blocks of Data 发送大块数据 (翻译 gafferongames) Packet Fragmentation and Reassembly 数据包分片与重组 游戏中Shotgun(喷子)发射子弹的实现
(UnityEditor Tool) 语音控制unity editor暂停和播放
sun_dust_shadow · 2025-04-16 · via 博客园 - sun_dust_shadow
在Windows平台上可以通过KeywordRecognizer识别简单的语音关键字,我们可以通过麦克风控制编辑器的开启、暂停、关闭
只是一个有趣的小实验
 1 using System;
 2 using UnityEngine;
 3 using UnityEngine.Windows.Speech;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using UnityEditor;
 7 
 8 namespace Game.Editor
 9 {
10     public class EditorVoiceKeywordRecognition : EditorWindow
11     {
12         private  KeywordRecognizer _keywordRecognizer;
13         private readonly Dictionary<string, System.Action> _keywords;
14 
15         [MenuItem("Tools/Custom/Voice Control")]
16         public static void ShowWindow()
17         {
18             EditorWindow.GetWindow(typeof(EditorVoiceKeywordRecognition), false, "Voice Control");
19         }
20 
21         private EditorVoiceKeywordRecognition()
22         {
23             _keywords = new Dictionary<string, System.Action>
24             {
25                 {
26                     "pause", () =>
27                     {
28                         EditorApplication.isPaused = !EditorApplication.isPaused;
29                     }
30                 },
31                 {
32                     "stop", () =>
33                     {
34                         EditorApplication.isPlaying = false;
35                     }
36                 },
37 
38                 {
39                     "play", () =>
40                     {
41                         EditorApplication.isPlaying = true;
42                     }
43                 }
44             };
45         }
46 
47         private void Awake()
48         {
49             _keywordRecognizer = new KeywordRecognizer(_keywords.Keys.ToArray());
50             _keywordRecognizer.OnPhraseRecognized += OnKeywordsRecognized;
51             _keywordRecognizer.Start();
52             Debug.Log("Keyword Recognizer Started");
53         }
54 
55         private void OnDestroy()
56         {
57             if (_keywordRecognizer != null)
58             {
59                 _keywordRecognizer.Stop();
60                 _keywordRecognizer.Dispose();
61                 Debug.Log("Keyword Recognizer Stopped");
62             }
63         }
64 
65         private void OnGUI()
66         {
67             GUILayout.Label("Voice Control", EditorStyles.boldLabel);
68             if (_keywordRecognizer != null && _keywordRecognizer.IsRunning)
69             {
70                 GUILayout.Label("Voice Recognition: Running");
71             }
72             else
73             {
74                 GUILayout.Label("Voice Recognition: Stopped");
75             }
76 
77             if (GUILayout.Button("Restart Recognizer"))
78             {
79                 _keywordRecognizer.Stop();
80                 _keywordRecognizer.Start();
81             }
82         }
83 
84         private void OnKeywordsRecognized(PhraseRecognizedEventArgs args)
85         {
86             Debug.Log($"Recognized Keyword: {args.text}");
87             if (_keywords.TryGetValue(args.text, out Action keyword))
88             {
89                 keyword?.Invoke();
90             }
91         }
92     }
93 }