Skip to content

Commit c598e36

Browse files
Merge pull request #92 from Live2D/develop
Update to Cubism 5 SDK for Unity R5
2 parents cd8058a + 18a5028 commit c598e36

613 files changed

Lines changed: 112591 additions & 33824 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Live2D/Cubism/CHANGELOG.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,40 @@ 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+
## [5-r.5] - 2026-04-02
9+
10+
### Added
11+
12+
* Added Cubism Core for ARM64 iOS Simulator.
13+
* See `CHANGELOG.md` in Core.
14+
15+
### Changed
16+
17+
* Update each model's prefab to match environment updates.
18+
* Change to allow specifying `AnimatorController` in scenes under `Assets/Live2D/Cubism/Samples/AsyncBenchmark`.
19+
* Change to explicitly set texture sampler settings.
20+
* Change the version of the development project to `6000.0.68f1`.
21+
* Change to work with the `Input System` package.
22+
* Change property names related to multiply color and screen color.
23+
24+
### Fixed
25+
26+
* Fix an issue in URP where Cubism models could not be picked in the Scene View.
27+
* Fix an issue in URP where selected Cubism models were not highlighted with an outline in the Scene View.
28+
* Fix an issue where the scaling reference position was set to the center of the rendering area.
29+
* Fix incorrect quaternion composition in `CubismRenderer`.
30+
* Fix an issue where the model would disappear when regaining Editor focus if `Run In Background` was disabled.
31+
* Fix an issue where the import process would run for models imported under the `StreamingAssets` folder. by [@redwyre](https://github.com/Live2D/CubismUnityComponents/pull/90)
32+
* Fix an issue where the `Koharu` model used in scenes under `Assets/Live2D/Cubism/Samples` was outdated.
33+
* Fix an issue where `CubismPartColorsEditor` was using incorrect flags for determination.
34+
* Fix an issue where the re-import process for a model did not support increasing or decreasing parameters and other elements.
35+
* Fix CubismImporterBase.Save so that it no longer performs a reimport when saving.
36+
* Fix the importer to import motion3.json first, followed by model3.json, and then all other assets.
37+
* Fix PoseMotionImporter processing to accommodate the new import order.
38+
* Fix an issue where specifying an override in `CubismParameterExtensionMethods.BlendToValue()` caused the applied value to be the current value of that parameter. by [@LoS-Light](https://github.com/Live2D/CubismUnityComponents/pull/89)
39+
* Fix an issue where offscreen rendering of models was not functioning correctly with Z Buffer in Reversed Z environments.
40+
41+
842
## [5-r.5-beta.3] - 2026-01-08
943

1044
### Added
@@ -165,7 +199,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
165199

166200
### Added
167201

168-
* Add `CubimMath` class in namespace `Live2D.Cubism.Framework.Utils`.
202+
* Add `CubismMath` class in namespace `Live2D.Cubism.Framework.Utils`.
169203
* Add function `ModF()` to compute floating-point remainder in `CubismMath` class.
170204

171205
### Changed
@@ -552,6 +586,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
552586
* Fix issue where Priority value was not reset after playing motion with CubismMotionController.
553587

554588

589+
[5-r.5]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.3...5-r.5
555590
[5-r.5-beta.3]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.2...5-r.5-beta.3
556591
[5-r.5-beta.2]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.1...5-r.5-beta.2
557592
[5-r.5-beta.1]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.4.1...5-r.5-beta.1

Assets/Live2D/Cubism/Core/CubismModel.cs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ public static void ResetMocReference(CubismModel model, CubismMoc moc)
8989
model.Moc = moc;
9090
}
9191

92+
/// <summary>
93+
/// Resets non-serialized fields of a <see cref="CubismModel"/>.
94+
/// </summary>
95+
/// <remarks>
96+
/// Call after <c>PrefabUtility.SaveAsPrefabAsset</c> to clear stale
97+
/// component references that may have been cached by <see cref="OnValidate"/>
98+
/// during the prefab replacement.
99+
/// </remarks>
100+
/// <param name="model">Target Cubism model.</param>
101+
public static void ResetNonSerializedFields(CubismModel model)
102+
{
103+
if (model.TaskableModel != null)
104+
{
105+
model.TaskableModel.ReleaseUnmanaged();
106+
model.TaskableModel = null;
107+
}
108+
109+
model._parameters = null;
110+
model._parts = null;
111+
model._drawables = null;
112+
model._offscreens = null;
113+
model._canvasInformation = null;
114+
}
115+
92116
/// <summary>
93117
/// <see cref="Moc"/> backing field.
94118
/// </summary>
@@ -355,6 +379,28 @@ private void Reset(CubismMoc moc)
355379
}
356380
else
357381
{
382+
// Filter stale entries whose UnmanagedIndex exceeds the new Moc count.
383+
var unmanagedParameterCount = TaskableModel.UnmanagedModel.Parameters.Count;
384+
if (Parameters.Length > unmanagedParameterCount)
385+
{
386+
var filtered = new CubismParameter[unmanagedParameterCount];
387+
var n = 0;
388+
for (var i = 0; i < Parameters.Length; i++)
389+
{
390+
if (Parameters[i].UnmanagedIndex < unmanagedParameterCount)
391+
{
392+
filtered[n++] = Parameters[i];
393+
}
394+
}
395+
396+
if (n < unmanagedParameterCount)
397+
{
398+
Array.Resize(ref filtered, n);
399+
}
400+
401+
Parameters = filtered;
402+
}
403+
358404
Parameters.Revive(TaskableModel.UnmanagedModel);
359405
}
360406

@@ -369,6 +415,27 @@ private void Reset(CubismMoc moc)
369415
}
370416
else
371417
{
418+
// Filter stale entries whose UnmanagedIndex exceeds the new Moc count.
419+
var unmanagedPartCount = TaskableModel.UnmanagedModel.Parts.Count;
420+
if (Parts.Length > unmanagedPartCount)
421+
{
422+
var filtered = new CubismPart[unmanagedPartCount];
423+
var n = 0;
424+
for (var i = 0; i < Parts.Length; i++)
425+
{
426+
if (Parts[i].UnmanagedIndex < unmanagedPartCount)
427+
{
428+
filtered[n++] = Parts[i];
429+
}
430+
}
431+
432+
if (n < unmanagedPartCount)
433+
{
434+
Array.Resize(ref filtered, n);
435+
}
436+
437+
Parts = filtered;
438+
}
372439
Parts.Revive(TaskableModel.UnmanagedModel);
373440
}
374441

@@ -383,6 +450,28 @@ private void Reset(CubismMoc moc)
383450
}
384451
else
385452
{
453+
// Filter stale entries whose UnmanagedIndex exceeds the new Moc count.
454+
var unmanagedDrawableCount = TaskableModel.UnmanagedModel.Drawables.Count;
455+
if (Drawables.Length > unmanagedDrawableCount)
456+
{
457+
var filtered = new CubismDrawable[unmanagedDrawableCount];
458+
var n = 0;
459+
for (var i = 0; i < Drawables.Length; i++)
460+
{
461+
if (Drawables[i].UnmanagedIndex < unmanagedDrawableCount)
462+
{
463+
filtered[n++] = Drawables[i];
464+
}
465+
}
466+
467+
if (n < unmanagedDrawableCount)
468+
{
469+
Array.Resize(ref filtered, n);
470+
}
471+
472+
Drawables = filtered;
473+
}
474+
386475
Drawables.Revive(TaskableModel.UnmanagedModel);
387476
}
388477

@@ -398,6 +487,28 @@ private void Reset(CubismMoc moc)
398487
}
399488
else
400489
{
490+
// Filter stale entries whose UnmanagedIndex exceeds the new Moc count.
491+
var unmanagedOffscreenCount = TaskableModel.UnmanagedModel.Offscreens.Count;
492+
if (Offscreens.Length > unmanagedOffscreenCount)
493+
{
494+
var filtered = new CubismOffscreen[unmanagedOffscreenCount];
495+
var n = 0;
496+
for (var i = 0; i < Offscreens.Length; i++)
497+
{
498+
if (Offscreens[i].UnmanagedIndex < unmanagedOffscreenCount)
499+
{
500+
filtered[n++] = Offscreens[i];
501+
}
502+
}
503+
504+
if (n < unmanagedOffscreenCount)
505+
{
506+
Array.Resize(ref filtered, n);
507+
}
508+
509+
Offscreens = filtered;
510+
}
511+
401512
Offscreens.Revive(TaskableModel.UnmanagedModel);
402513
}
403514
}

Assets/Live2D/Cubism/Editor/CubismAssetProcessor.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ namespace Live2D.Cubism.Editor
2626
/// </summary>
2727
public class CubismAssetProcessor : AssetPostprocessor
2828
{
29+
private const string Motion3JsonExtension = ".motion3.json";
30+
private const string Model3JsonExtension = ".model3.json";
31+
2932
#region Unity Event Handling
3033

3134
#if !UNITY_2017_3_OR_NEWER
@@ -58,8 +61,26 @@ private static void OnPostprocessAllAssets(
5861

5962
var assetList = CubismCreatedAssetList.GetInstance();
6063

64+
// Import motion3.json first to create AnimationClip
65+
var orderedAssetPaths = importedAssetPaths
66+
.OrderBy(path =>
67+
{
68+
if (path.EndsWith(Motion3JsonExtension, StringComparison.OrdinalIgnoreCase))
69+
{
70+
return 0;
71+
}
72+
73+
if (path.EndsWith(Model3JsonExtension, StringComparison.OrdinalIgnoreCase))
74+
{
75+
return 1;
76+
}
77+
78+
return 2;
79+
})
80+
.ToArray();
81+
6182
// Handle any imported Cubism assets.
62-
foreach (var assetPath in importedAssetPaths)
83+
foreach (var assetPath in orderedAssetPaths)
6384
{
6485
var importer = CubismImporter.GetImporterAtPath(assetPath);
6586

@@ -69,11 +90,17 @@ private static void OnPostprocessAllAssets(
6990
continue;
7091
}
7192

93+
if (assetPath.StartsWith("Assets/StreamingAssets/"))
94+
{
95+
Debug.LogWarning("CubismAssetProcessor : Skipping import of " + assetPath);
96+
continue;
97+
}
98+
7299
try
73100
{
74101
importer.Import();
75102
}
76-
catch(Exception e)
103+
catch (Exception e)
77104
{
78105
Debug.LogError("CubismAssetProcessor : Following error occurred while importing " + assetPath);
79106
Debug.LogError(e);
@@ -299,6 +326,17 @@ private static void GenerateBuiltinResources()
299326
AssetDatabase.CreateAsset(material, $"{materialsRoot}/{material.name}.mat");
300327
}
301328

329+
if (CubismBuiltinMaterials.TransparentPicking == null)
330+
{
331+
// Create transparent material for Scene View picking.
332+
var material = new Material (CubismBuiltinShaders.TransparentPicking)
333+
{
334+
name = "TransparentPicking"
335+
};
336+
337+
AssetDatabase.CreateAsset(material, $"{materialsRoot}/{material.name}.mat");
338+
}
339+
302340
#region Cubism 5.3
303341

304342
var materialsDir = materialsRoot + "/BlendMode";

Assets/Live2D/Cubism/Editor/Importers/CubismImporter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ private static void BuiltinTextureImportHandler(CubismModel3JsonImporter importe
234234
if (!textureImporter.mipmapEnabled
235235
&& textureImporter.alphaIsTransparency
236236
&& textureImporter.textureType == TextureImporterType.Default
237-
&& textureImporter.textureCompression == TextureImporterCompression.Uncompressed)
237+
&& textureImporter.textureCompression == TextureImporterCompression.Uncompressed
238+
&& textureImporter.wrapMode == TextureWrapMode.Repeat
239+
&& textureImporter.filterMode == FilterMode.Bilinear)
238240
{
239241
return;
240242
}
@@ -245,7 +247,8 @@ private static void BuiltinTextureImportHandler(CubismModel3JsonImporter importe
245247
textureImporter.alphaIsTransparency = true;
246248
textureImporter.textureType = TextureImporterType.Default;
247249
textureImporter.textureCompression = TextureImporterCompression.Uncompressed;
248-
250+
textureImporter.wrapMode = TextureWrapMode.Repeat;
251+
textureImporter.filterMode = FilterMode.Bilinear;
249252

250253
EditorUtility.SetDirty(texture);
251254
textureImporter.SaveAndReimport();

Assets/Live2D/Cubism/Editor/Importers/CubismImporterBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void Save()
4242
assetImporter.userData = JsonUtility.ToJson(this);
4343

4444

45-
assetImporter.SaveAndReimport();
45+
AssetDatabase.WriteImportSettingsIfDirty(AssetPath);
4646
}
4747

4848
#region ICubismImporter

0 commit comments

Comments
 (0)