Skip to content

Commit cd8058a

Browse files
Merge pull request #91 from Live2D/develop
Update to Cubism 5 SDK for Unity R5 beta3
2 parents 4e0c106 + 90b3743 commit cd8058a

1,250 files changed

Lines changed: 265317 additions & 130645 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,41 @@ 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-beta.3] - 2026-01-08
9+
10+
### Added
11+
12+
* Add scripts and assets for using the `Universal Render Pipeline` and custom render passes to `Assets/Live2D/Cubism/Rendering/URP`.
13+
* Add a feature to allow rendering of arbitrary objects before and after the rendering of model draw objects.
14+
* Add `CubismLookCenterTransform` and `CubismLookCenterArtMesh` to allow setting the look-at center using either a Transform or an ArtMesh.
15+
16+
### Changed
17+
18+
* Change to work based on the `Universal Render Pipeline`.
19+
* `Built-in Render Pipeline` and `High Definition Render Pipeline` are not supported.
20+
* `Cubism 5 SDK for Unity R4_1` and its derivative packages will be maintained as `Built-in Render Pipeline` compatible versions.
21+
* Models and features from `Cubism 5.3` and later cannot be used.
22+
* The use of custom render passes is required.
23+
24+
### Fixed
25+
26+
* Fix an issue where `ReleaseStaleRenderTextures()` could release `RenderTexture` in use depending on the timing of its invocation.
27+
* Fix an issue where the texture settings were not as intended when imported.
28+
* Fix an issue where look-at tracking was misaligned when using `CubismLookController`.
29+
* Fix an issue where the Koharu model's .model3.json was missing references to .motion3.json.
30+
* Fix Koharu's corrupted .motion3.json files.
31+
* Fix an issue where Raycast was functional even when `CubismRaycastable` was inactive.
32+
33+
### Removed
34+
35+
* Remove unused shaders and materials.
36+
* Remove `Assets/Live2D/Cubism/Rendering/CubismCommonRenderFrameBuffer.cs` and `Assets/Live2D/Cubism/Rendering/ArrayExtensionMethods.cs`.
37+
* Remove `Assets/Live2D/Cubism/Rendering/Resources/Live2D/Cubism/Prefabs/ModelCanvas.prefab`.
38+
* Remove scripts and related processes under `Assets/Live2D/Cubism/Rendering/Masking` and `Assets/Live2D/Cubism/Samples/Masking`.
39+
* Remove `Assets/Live2D/Cubism/Editor/Inspectors/CubismMaskControllerInspector.cs`, `Assets/Live2D/Cubism/Editor/Inspectors/CubismMaskTextureInspector.cs`, and `Assets/Live2D/Cubism/Rendering/Resources/Live2D/Cubism/GlobalMaskTexture.asset` accordingly.
40+
* Mask processing has been integrated into `CubismRenderer`.
41+
42+
843
## [5-r.5-beta.2] - 2025-10-14
944

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

519554

555+
[5-r.5-beta.3]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.2...5-r.5-beta.3
520556
[5-r.5-beta.2]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.1...5-r.5-beta.2
521557
[5-r.5-beta.1]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.4.1...5-r.5-beta.1
522558
[5-r.4.1]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.4...5-r.4.1

Assets/Live2D/Cubism/Core/CubismModel.cs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Live2D.Cubism.Framework;
1111
using System;
1212
using UnityEngine;
13-
using Live2D.Cubism.Rendering.Util;
1413

1514

1615
#if UNITY_2019_3_OR_NEWER
@@ -309,44 +308,10 @@ private bool CanRevive
309308
/// </summary>
310309
private int LastTick { get; set; }
311310

312-
/// <summary>
313-
/// Is the model's MOC version higher than Cubism 5.0?
314-
/// </summary>
315-
public bool IsOverMocVersion50
316-
{
317-
get
318-
{
319-
return CubismCoreDll.MocVersion_50 < Moc.Version;
320-
}
321-
}
322-
323-
/// <summary>
324-
/// Is this model using blend mode.
325-
/// </summary>
326-
[SerializeField, HideInInspector]
327-
private bool _isUsingBlendMode;
328-
329-
330-
/// <summary>
331-
/// Get Flag is this model using blend mode.
332-
/// </summary>
333-
/// <returns>True if Is this model using blend mode; otherwise returns false.</returns>
334-
public bool IsUsingBlendMode
335-
{
336-
get
337-
{
338-
return _isUsingBlendMode;
339-
}
340-
private set
341-
{
342-
_isUsingBlendMode = value;
343-
}
344-
}
345-
346311
/// <summary>
347312
/// Revives instance.
348313
/// </summary>
349-
private void Revive()
314+
internal void Revive()
350315
{
351316
// Return if already revive.
352317
if (IsRevived)
@@ -423,7 +388,6 @@ private void Reset(CubismMoc moc)
423388

424389
if (0 < CubismCoreDll.GetOffscreenCount(TaskableModel.UnmanagedModel.Ptr))
425390
{
426-
IsUsingBlendMode = true;
427391
Offscreens = GetComponentsInChildren<CubismOffscreen>();
428392
if (Offscreens.Length < 1 && (transform.Find("Offscreens") == null))
429393
{
@@ -438,26 +402,6 @@ private void Reset(CubismMoc moc)
438402
}
439403
}
440404

441-
if (IsOverMocVersion50 && !IsUsingBlendMode)
442-
{
443-
var drawableCount = Drawables.Length;
444-
for (var i = 0; i < drawableCount; ++i)
445-
{
446-
var colorBlendType = Drawables[i].ColorBlend;
447-
var alphaBlendType = Drawables[i].AlphaBlend;
448-
if (colorBlendType == BlendTypes.ColorBlend.Normal &&
449-
alphaBlendType == BlendTypes.AlphaBlend.Over ||
450-
colorBlendType == BlendTypes.ColorBlend.Add ||
451-
colorBlendType == BlendTypes.ColorBlend.Multiply)
452-
{
453-
continue;
454-
}
455-
456-
IsUsingBlendMode = true;
457-
break;
458-
}
459-
}
460-
461405
CanvasInformation = new CubismCanvasInformation(TaskableModel.UnmanagedModel);
462406

463407
RefreshParameterStore();

Assets/Live2D/Cubism/Core/CubismPart.cs

Lines changed: 90 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,71 @@ public int OffscreenIndex
123123
}
124124
}
125125

126+
/// <summary>
127+
/// <see cref="AllChildOffscreens"/>'s backing field.
128+
/// </summary>
129+
private CubismOffscreen[] _allChildOffscreens = null;
130+
131+
/// <summary>
132+
/// All child drawables of this part, including children of children.
133+
/// </summary>
134+
public CubismOffscreen[] AllChildOffscreens
135+
{
136+
get
137+
{
138+
if (_allChildOffscreens == null)
139+
{
140+
var model = this.FindCubismModel(true);
141+
if (!model)
142+
{
143+
return null;
144+
}
145+
146+
if (model.Offscreens == null)
147+
{
148+
return null;
149+
}
150+
151+
var parts = model.Parts;
152+
153+
var childrenParts = Array.Empty<CubismPart>();
154+
155+
for (var index = 0; index < parts.Length; index++)
156+
{
157+
if (parts[index].UnmanagedParentIndex == UnmanagedIndex)
158+
{
159+
Array.Resize(ref childrenParts, childrenParts.Length + 1);
160+
childrenParts[^1] = parts[index];
161+
}
162+
}
163+
164+
// Initialize the array of all children drawables.
165+
_allChildOffscreens = Array.Empty<CubismOffscreen>();
166+
167+
// Add the drawables of this part.
168+
Array.Resize(ref _allChildOffscreens, ChildOffscreens.Length);
169+
Array.Copy(ChildOffscreens, _allChildOffscreens, ChildOffscreens.Length);
170+
171+
// Collect all children drawables from child parts.
172+
for (var index = 0; index < childrenParts.Length; index++)
173+
{
174+
Array.Resize(ref _allChildOffscreens, _allChildOffscreens.Length + childrenParts[index].AllChildOffscreens.Length);
175+
Array.Copy(childrenParts[index].AllChildOffscreens,
176+
0,
177+
_allChildOffscreens,
178+
_allChildOffscreens.Length - childrenParts[index].AllChildOffscreens.Length,
179+
childrenParts[index].AllChildOffscreens.Length);
180+
}
181+
}
182+
183+
return _allChildOffscreens;
184+
}
185+
}
186+
126187
/// <summary>
127188
/// <see cref="AllChildDrawables"/>'s backing field.
128189
/// </summary>
129-
[SerializeField, HideInInspector]
130-
private CubismDrawable[] _allChildrenDrawables = null;
190+
private CubismDrawable[] _allChildDrawables = null;
131191

132192
/// <summary>
133193
/// All child drawables of this part, including children of children.
@@ -136,10 +196,10 @@ public CubismDrawable[] AllChildDrawables
136196
{
137197
get
138198
{
139-
if (_allChildrenDrawables == null)
199+
if (_allChildDrawables == null)
140200
{
141201
var model = this.FindCubismModel(true);
142-
if (!model)
202+
if (!model || (model.Drawables?.Length ?? -1) < 1)
143203
{
144204
return null;
145205
}
@@ -158,25 +218,30 @@ public CubismDrawable[] AllChildDrawables
158218
}
159219

160220
// Initialize the array of all children drawables.
161-
_allChildrenDrawables = Array.Empty<CubismDrawable>();
221+
_allChildDrawables = Array.Empty<CubismDrawable>();
162222

163223
// Add the drawables of this part.
164-
Array.Resize(ref _allChildrenDrawables, ChildDrawables.Length);
165-
Array.Copy(ChildDrawables, _allChildrenDrawables, ChildDrawables.Length);
224+
Array.Resize(ref _allChildDrawables, ChildDrawables.Length);
225+
Array.Copy(ChildDrawables, _allChildDrawables, ChildDrawables.Length);
166226

167227
// Collect all children drawables from child parts.
168228
for (var index = 0; index < childrenParts.Length; index++)
169229
{
170-
Array.Resize(ref _allChildrenDrawables, _allChildrenDrawables.Length + childrenParts[index].AllChildDrawables.Length);
230+
if ((childrenParts[index]?.AllChildDrawables?.Length ?? -1) < 1)
231+
{
232+
continue;
233+
}
234+
235+
Array.Resize(ref _allChildDrawables, _allChildDrawables.Length + childrenParts[index].AllChildDrawables.Length);
171236
Array.Copy(childrenParts[index].AllChildDrawables,
172237
0,
173-
_allChildrenDrawables,
174-
_allChildrenDrawables.Length - childrenParts[index].AllChildDrawables.Length,
238+
_allChildDrawables,
239+
_allChildDrawables.Length - childrenParts[index].AllChildDrawables.Length,
175240
childrenParts[index].AllChildDrawables.Length);
176241
}
177242
}
178243

179-
return _allChildrenDrawables;
244+
return _allChildDrawables;
180245
}
181246
}
182247

@@ -261,7 +326,7 @@ public CubismDrawable[] ChildDrawables
261326
private CubismOffscreen[] _childOffscreens;
262327

263328
/// <summary>
264-
/// Child offscreens of this part.
329+
/// Array of offscreen from child parts;
265330
/// </summary>
266331
public CubismOffscreen[] ChildOffscreens
267332
{
@@ -282,14 +347,21 @@ public CubismOffscreen[] ChildOffscreens
282347
return null;
283348
}
284349

350+
_childOffscreens = Array.Empty<CubismOffscreen>();
351+
285352
for (var index = 0; index < offscreens.Length; index++)
286353
{
354+
var part = model.Parts[offscreens[index].OwnerIndex];
355+
287356
// When this object is the parent part.
288-
if (offscreens[index].OwnerIndex == UnmanagedIndex)
357+
if (part.UnmanagedParentIndex < 0
358+
|| part.UnmanagedParentIndex != UnmanagedIndex)
289359
{
290-
Array.Resize(ref _childOffscreens, _childOffscreens?.Length ?? 0 + 1);
291-
_childOffscreens[^1] = offscreens[index];
360+
continue;
292361
}
362+
363+
Array.Resize(ref _childOffscreens, _childOffscreens.Length + 1);
364+
_childOffscreens[^1] = offscreens[index];
293365
}
294366
}
295367
return _childOffscreens;
@@ -331,15 +403,14 @@ private void InitializePartInfo()
331403
}
332404

333405
var childObjectCount = ChildDrawables.Length + ChildParts.Length;
334-
335406
_partInfo = new CubismModelTypes.PartInfo
336407
{
337408
PartUnmanagedIndex = UnmanagedIndex,
338409
ChildObjects = new CubismModelTypes.PartChildObjectInfo[childObjectCount],
339410
DrawObjects = new CubismModelTypes.PartDrawObjectInfo
340411
{
341412
Drawables = AllChildDrawables,
342-
Offscreens = ChildOffscreens
413+
Offscreens = AllChildOffscreens
343414
}
344415
};
345416

@@ -394,7 +465,8 @@ private void Reset(CubismUnmanagedModel unmanagedModel, int unmanagedIndex)
394465
name = Id;
395466
Opacity = UnmanagedParts.Opacities[unmanagedIndex];
396467

397-
_allChildrenDrawables = null;
468+
_allChildDrawables = null;
469+
_allChildOffscreens = null;
398470
_childParts = null;
399471
_childDrawables = null;
400472
_childOffscreens = null;

0 commit comments

Comments
 (0)