Skip to content

Commit c211d58

Browse files
authored
Merge pull request #12 from MidraLab/feat/action_voice
Clickしたときのボイス再生の対応
2 parents 117af47 + 1d7a07a commit c211d58

23 files changed

+642
-2
lines changed

Assets/uDesktopMascot/Editor.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System.IO;
2+
using Unity.Logging;
3+
using UnityEditor;
4+
using UnityEditor.Callbacks;
5+
using UnityEngine;
6+
7+
public class PostBuildProcessor
8+
{
9+
/// <summary>
10+
/// ビルド後SteamAssetsフォルダを生成する
11+
/// </summary>
12+
/// <param name="target"></param>
13+
/// <param name="pathToBuiltProject"></param>
14+
[PostProcessBuild(1)]
15+
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
16+
{
17+
// ビルドされたプロジェクトのディレクトリを取得
18+
var buildDirectory = Path.GetDirectoryName(pathToBuiltProject);
19+
if (string.IsNullOrEmpty(buildDirectory))
20+
{
21+
Log.Error("ビルドされたプロジェクトのディレクトリが取得できませんでした。");
22+
return;
23+
}
24+
25+
var appName = Path.GetFileNameWithoutExtension(pathToBuiltProject);
26+
27+
var streamingAssetsPath = "";
28+
29+
if (target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64 ||
30+
target == BuildTarget.StandaloneLinux64)
31+
{
32+
// Windows および Linux の場合
33+
streamingAssetsPath = Path.Combine(buildDirectory, $"{appName}_Data", "StreamingAssets");
34+
} else if (target == BuildTarget.StandaloneOSX)
35+
{
36+
// macOS の場合
37+
streamingAssetsPath = Path.Combine(buildDirectory, $"{appName}.app", "Contents", "Resources", "Data",
38+
"StreamingAssets");
39+
} else
40+
{
41+
Debug.LogWarning("このプラットフォームはサポートされていません: " + target);
42+
return;
43+
}
44+
45+
// StreamingAssets フォルダが存在しない場合は作成
46+
if (!Directory.Exists(streamingAssetsPath))
47+
{
48+
Directory.CreateDirectory(streamingAssetsPath);
49+
}
50+
51+
// Voice/Click フォルダを作成
52+
var clickVoicePath = Path.Combine(streamingAssetsPath, "Voice", "Click");
53+
if (!Directory.Exists(clickVoicePath))
54+
{
55+
Directory.CreateDirectory(clickVoicePath);
56+
}
57+
58+
// Voice/Drag フォルダを作成(または Voice/Hold フォルダ)
59+
var dragVoicePath = Path.Combine(streamingAssetsPath, "Voice", "Drag");
60+
if (!Directory.Exists(dragVoicePath))
61+
{
62+
Directory.CreateDirectory(dragVoicePath);
63+
}
64+
65+
// ログ出力(必要に応じて)
66+
Log.Debug("ビルド後処理が完了しました。必要なフォルダを生成しました。");
67+
}
68+
}

Assets/uDesktopMascot/Editor/PostBuildProcessor.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace uDesktopMascot.Editor
5+
{
6+
/// <summary>
7+
/// ボイスファイルのインポート時に設定を変更するためのクラス
8+
/// </summary>
9+
public class VoiceImportPostprocessor : AssetPostprocessor
10+
{
11+
private void OnPreprocessAudio()
12+
{
13+
// ターゲットフォルダのパス
14+
var targetFolder = "Assets/uDesktopMascot/Resources/DefaultVoice/";
15+
16+
// アセットが指定フォルダ内にある場合
17+
if (assetPath.Contains(targetFolder))
18+
{
19+
var audioImporter = (AudioImporter)assetImporter;
20+
21+
// デフォルトのサンプル設定を取得
22+
var sampleSettings = audioImporter.defaultSampleSettings;
23+
24+
// Load TypeをCompressed In Memoryに設定
25+
sampleSettings.loadType = AudioClipLoadType.CompressedInMemory;
26+
// Compression FormatをADPCMに設定
27+
sampleSettings.compressionFormat = AudioCompressionFormat.ADPCM;
28+
// Preload Audio Dataを有効に設定
29+
sampleSettings.preloadAudioData = true;
30+
31+
// 変更した設定を適用
32+
audioImporter.defaultSampleSettings = sampleSettings;
33+
34+
// 必要に応じてプラットフォームごとの設定も変更可能
35+
// 以下の例では、すべてのプラットフォームで同じ設定を適用しています
36+
var platforms = new[] { "Standalone", "Android", "iOS" };
37+
foreach (var platform in platforms)
38+
{
39+
audioImporter.SetOverrideSampleSettings(platform, sampleSettings);
40+
}
41+
}
42+
}
43+
}
44+
}

Assets/uDesktopMascot/Editor/VoiceImportPostprocessor.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/uDesktopMascot/Resources/DefaultVoice.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/uDesktopMascot/Resources/DefaultVoice/Click.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/uDesktopMascot/Resources/DefaultVoice/Click/.gitkeep

Whitespace-only changes.

Assets/uDesktopMascot/Resources/DefaultVoice/Hold.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/uDesktopMascot/Resources/DefaultVoice/Hold/.gitkeep

Whitespace-only changes.

Assets/uDesktopMascot/Scenes/SampleScene.unity

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,151 @@ Transform:
509509
m_Children: []
510510
m_Father: {fileID: 0}
511511
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
512+
--- !u!1 &1494941702
513+
GameObject:
514+
m_ObjectHideFlags: 0
515+
m_CorrespondingSourceObject: {fileID: 0}
516+
m_PrefabInstance: {fileID: 0}
517+
m_PrefabAsset: {fileID: 0}
518+
serializedVersion: 6
519+
m_Component:
520+
- component: {fileID: 1494941703}
521+
- component: {fileID: 1494941705}
522+
- component: {fileID: 1494941704}
523+
m_Layer: 0
524+
m_Name: VoiceManager
525+
m_TagString: Untagged
526+
m_Icon: {fileID: 0}
527+
m_NavMeshLayer: 0
528+
m_StaticEditorFlags: 0
529+
m_IsActive: 1
530+
--- !u!4 &1494941703
531+
Transform:
532+
m_ObjectHideFlags: 0
533+
m_CorrespondingSourceObject: {fileID: 0}
534+
m_PrefabInstance: {fileID: 0}
535+
m_PrefabAsset: {fileID: 0}
536+
m_GameObject: {fileID: 1494941702}
537+
serializedVersion: 2
538+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
539+
m_LocalPosition: {x: 0, y: 0, z: 0}
540+
m_LocalScale: {x: 1, y: 1, z: 1}
541+
m_ConstrainProportionsScale: 1
542+
m_Children: []
543+
m_Father: {fileID: 0}
544+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
545+
--- !u!82 &1494941704
546+
AudioSource:
547+
m_ObjectHideFlags: 0
548+
m_CorrespondingSourceObject: {fileID: 0}
549+
m_PrefabInstance: {fileID: 0}
550+
m_PrefabAsset: {fileID: 0}
551+
m_GameObject: {fileID: 1494941702}
552+
m_Enabled: 1
553+
serializedVersion: 4
554+
OutputAudioMixerGroup: {fileID: 0}
555+
m_audioClip: {fileID: 0}
556+
m_Resource: {fileID: 0}
557+
m_PlayOnAwake: 0
558+
m_Volume: 1
559+
m_Pitch: 1
560+
Loop: 0
561+
Mute: 0
562+
Spatialize: 0
563+
SpatializePostEffects: 0
564+
Priority: 46
565+
DopplerLevel: 1
566+
MinDistance: 1
567+
MaxDistance: 500
568+
Pan2D: 0
569+
rolloffMode: 0
570+
BypassEffects: 0
571+
BypassListenerEffects: 0
572+
BypassReverbZones: 0
573+
rolloffCustomCurve:
574+
serializedVersion: 2
575+
m_Curve:
576+
- serializedVersion: 3
577+
time: 0
578+
value: 1
579+
inSlope: 0
580+
outSlope: 0
581+
tangentMode: 0
582+
weightedMode: 0
583+
inWeight: 0.33333334
584+
outWeight: 0.33333334
585+
- serializedVersion: 3
586+
time: 1
587+
value: 0
588+
inSlope: 0
589+
outSlope: 0
590+
tangentMode: 0
591+
weightedMode: 0
592+
inWeight: 0.33333334
593+
outWeight: 0.33333334
594+
m_PreInfinity: 2
595+
m_PostInfinity: 2
596+
m_RotationOrder: 4
597+
panLevelCustomCurve:
598+
serializedVersion: 2
599+
m_Curve:
600+
- serializedVersion: 3
601+
time: 0
602+
value: 0
603+
inSlope: 0
604+
outSlope: 0
605+
tangentMode: 0
606+
weightedMode: 0
607+
inWeight: 0.33333334
608+
outWeight: 0.33333334
609+
m_PreInfinity: 2
610+
m_PostInfinity: 2
611+
m_RotationOrder: 4
612+
spreadCustomCurve:
613+
serializedVersion: 2
614+
m_Curve:
615+
- serializedVersion: 3
616+
time: 0
617+
value: 0
618+
inSlope: 0
619+
outSlope: 0
620+
tangentMode: 0
621+
weightedMode: 0
622+
inWeight: 0.33333334
623+
outWeight: 0.33333334
624+
m_PreInfinity: 2
625+
m_PostInfinity: 2
626+
m_RotationOrder: 4
627+
reverbZoneMixCustomCurve:
628+
serializedVersion: 2
629+
m_Curve:
630+
- serializedVersion: 3
631+
time: 0
632+
value: 1
633+
inSlope: 0
634+
outSlope: 0
635+
tangentMode: 0
636+
weightedMode: 0
637+
inWeight: 0.33333334
638+
outWeight: 0.33333334
639+
m_PreInfinity: 2
640+
m_PostInfinity: 2
641+
m_RotationOrder: 4
642+
--- !u!114 &1494941705
643+
MonoBehaviour:
644+
m_ObjectHideFlags: 0
645+
m_CorrespondingSourceObject: {fileID: 0}
646+
m_PrefabInstance: {fileID: 0}
647+
m_PrefabAsset: {fileID: 0}
648+
m_GameObject: {fileID: 1494941702}
649+
m_Enabled: 1
650+
m_EditorHideFlags: 0
651+
m_Script: {fileID: 11500000, guid: a9c4c025aa874057b6d75aced08f797c, type: 3}
652+
m_Name:
653+
m_EditorClassIdentifier:
654+
clickVoice:
655+
- {fileID: 8300000, guid: 1dcdad14186b33c4199aa812d8903c3e, type: 3}
656+
dragVoice: []
512657
--- !u!1 &1510895035
513658
GameObject:
514659
m_ObjectHideFlags: 0
@@ -660,3 +805,4 @@ SceneRoots:
660805
- {fileID: 243030076}
661806
- {fileID: 1510895036}
662807
- {fileID: 1795136569}
808+
- {fileID: 1494941703}

Assets/uDesktopMascot/Scripts/CharacterController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void Update()
126126
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
127127

128128
// モデルのスクリーン座標を取得
129-
Vector2 modelScreenPos = Utility.GetModelScreenPosition(_mainCamera, _model.transform);
129+
var modelScreenPos = ScreenUtility.GetModelScreenPosition(_mainCamera, _model.transform);
130130

131131
// エクスプローラーウィンドウの位置を取得
132132
var explorerWindows = ExplorerWindowDetector.GetExplorerWindows();
@@ -192,6 +192,7 @@ private void OnHoldPerformed(InputAction.CallbackContext context)
192192
{
193193
// モデルがクリックされた
194194
_isDraggingModel = true;
195+
VoiceController.Instance.PlayHoldVoice();
195196
} else
196197
{
197198
_isDraggingModel = false;
@@ -210,6 +211,8 @@ private void OnClickStarted(InputAction.CallbackContext context)
210211
{
211212
Log.Debug("クリック開始");
212213

214+
VoiceController.Instance.PlayClickVoice();
215+
213216
// todo キャラクターを触ったときにモーションと音声の反応が付ける
214217
}
215218

Assets/uDesktopMascot/Scripts/Common.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace uDesktopMascot
2+
{
3+
/// <summary>
4+
/// シングルトンパターンの基底クラス
5+
/// </summary>
6+
/// <typeparam name="T"></typeparam>
7+
public class Singleton<T> where T : class, new()
8+
{
9+
private static T _instance;
10+
private static readonly object _lock = new();
11+
12+
public static T Instance
13+
{
14+
get
15+
{
16+
if (_instance == null)
17+
{
18+
lock (_lock)
19+
{
20+
if (_instance == null)
21+
{
22+
_instance = new T();
23+
}
24+
}
25+
}
26+
27+
return _instance;
28+
}
29+
}
30+
}
31+
}

Assets/uDesktopMascot/Scripts/Common/Singleton.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)