Skip to content

Commit 2c29ab1

Browse files
Merge pull request #6 from ppcuni/fix_motionsyncdispose
CubismMotionSyncCriEngine が予期せず Dispose される事があるのを修正
2 parents aa41972 + f278a9e commit 2c29ab1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Assets/Live2D/CubismMotionSyncPlugin/Framework/Processor/CRI/CubismMotionSyncCriProcessor.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,18 @@ public CubismMotionSyncCriAudioInput MotionSyncAudioInput
158158
/// </summary>
159159
private float CurrentRemainTime { get; set; }
160160

161+
/// <summary>
162+
/// <see cref="CubismMotionSyncCriEngine.InitializeEngine"/> was called or not
163+
/// </summary>
164+
/// <remarks>
165+
/// Since it is not a good idea to call <see cref="CubismMotionSyncCriEngine.DisposeEngine"/> before <see cref="CubismMotionSyncCriEngine.InitializeEngine"/> is called cache whether it is initialized or not.
166+
/// </remarks>
167+
private bool IsEngineInitialized { get; set; }
168+
161169
private void Start()
162170
{
163171
CubismMotionSyncCriEngine.InitializeEngine();
172+
IsEngineInitialized = true;
164173

165174

166175
if (!CubismMotionSyncCriEngine.IsInitialized)
@@ -189,7 +198,10 @@ private void OnDestroy()
189198
}
190199

191200

192-
CubismMotionSyncCriEngine.DisposeEngine();
201+
if (IsEngineInitialized)
202+
{
203+
CubismMotionSyncCriEngine.DisposeEngine();
204+
}
193205
}
194206

195207
/// <summary>

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77

8+
## [Unreleased] - ####-##-##
9+
10+
### Fixed
11+
12+
* Fix an issue where `CubismMotionSyncEngine_CRI.DisposeEngine()` could be called at an unintended time. by [@ppcuni](https://github.com/Live2D/CubismUnityMotionSyncComponents/pull/6)
13+
14+
815
## [5-r.1] - 2024-05-30
916

1017
### Added

0 commit comments

Comments
 (0)