live2D (sdk가 6.5 미지원으로 sprite로 대응)

This commit is contained in:
2026-08-08 22:13:54 +09:00
parent 9ce6930772
commit 8a4a001fe0
4278 changed files with 287426 additions and 18 deletions

View File

@@ -0,0 +1,71 @@
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using Live2D.Cubism.Framework.MotionFade;
using System;
using UnityEditor;
namespace Live2D.Cubism.Editor.Deleters
{
/// <summary>
/// Handles importing of Cubism models.
/// </summary>
[Serializable]
public sealed class CubismAnimationClipDeleter : CubismDeleterBase
{
#region Unity Event Handling
/// <summary>
/// Registers deleter.
/// </summary>
[InitializeOnLoadMethod]
// ReSharper disable once UnusedMember.Local
private static void RegisterDeleter()
{
CubismDeleter.RegisterDeleter<CubismAnimationClipDeleter>(".anim");
}
#endregion
#region CubismDeleterBase
/// <summary>
/// Deleters the corresponding asset.
/// </summary>
public override void Delete()
{
var fadeAssetPath = AssetPath.Replace(".anim", ".fade.asset");
var fadeAsset = AssetDatabase.LoadAssetAtPath<CubismFadeMotionData>(fadeAssetPath);
// Fail silently...
if (fadeAsset == null)
{
return;
}
// Delete fade motion asset.
AssetDatabase.DeleteAsset(fadeAssetPath);
// Get fade motion asset deleter.
var fadeMotionDeleter = CubismDeleter.GetDeleterAsPath(fadeAssetPath);
// Fail silently...
if (fadeMotionDeleter == null)
{
return;
}
fadeMotionDeleter.Delete();
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 206de3587db344c4a846531664c08a53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Live2D.Cubism.Editor.Deleters
{
/// <summary>
/// Helper functionality for <see cref="ICubismDeleter"/>s.
/// </summary>
public static class CubismDeleter
{
/// <summary>
/// Tries to get an deleter for a Cubism asset.
/// </summary>
/// <typeparam name="T">Deleter type.</typeparam>
/// <param name="assetPath">Path to the asset.</param>
/// <returns>The deleter on success; <see langword="null"/> otherwise.</returns>
public static T GetDeleterAsPath<T>(string assetPath) where T : class, ICubismDeleter
{
return GetDeleterAsPath(assetPath) as T;
}
/// <summary>
/// Tries to deserialize an deleter from <see cref="AssetDeleter.userData"/>.
/// </summary>
/// <param name="assetPath">Path to the asset.</param>
/// <returns>The deleter on success; <see langword="null"/> otherwise.</returns>
public static ICubismDeleter GetDeleterAsPath(string assetPath)
{
var deleterEntry = _registry.Find(e => assetPath.EndsWith(e.FileExtension));
// Return early in case no valid deleter is registered.
if (deleterEntry.DeleterType == null)
{
return null;
}
var deleter = Activator.CreateInstance(deleterEntry.DeleterType) as ICubismDeleter;
// Finalize deleter initialization.
if (deleter != null)
{
deleter.SetAssetPath(assetPath);
}
return deleter;
}
#region Registry
/// <summary>
/// Registry entry.
/// </summary>
private struct DeleterEntry
{
/// <summary>
/// Deleter type.
/// </summary>
public Type DeleterType;
/// <summary>
/// File extension valid for the deleter.
/// </summary>
public string FileExtension;
}
/// <summary>
/// List of registered <see cref="ICubismDeleter"/>s.
/// </summary>
private static List<DeleterEntry> _registry = new List<DeleterEntry>();
/// <summary>
/// Registers an deleter type.
/// </summary>
/// <typeparam name="T">The type of deleter to register.</typeparam>
/// <param name="fileExtension">The file extension the deleter supports.</param>
internal static void RegisterDeleter<T>(string fileExtension) where T : ICubismDeleter
{
_registry.Add(new DeleterEntry
{
DeleterType = typeof(T),
FileExtension = fileExtension
});
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17c4b0eaf67f7724686bebd85654cc38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using System;
namespace Live2D.Cubism.Editor.Deleters
{
/// <summary>
/// Base class for Cubism asset deleters.
/// </summary>
[Serializable]
public abstract class CubismDeleterBase : ICubismDeleter
{
/// <summary>
/// Gets the path to the imported asset.
/// </summary>
public string AssetPath { get; private set; }
/// <summary>
/// Imports the corresponding asset.
/// </summary>
public abstract void Delete();
#region ICubismDeleter
/// <summary>
/// Sets the asset path.
/// </summary>
void ICubismDeleter.SetAssetPath(string value)
{
AssetPath = value;
}
/// <summary>
/// Imports the corresponding asset.
/// </summary>
void ICubismDeleter.Delete()
{
Delete();
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57c6427b7fd90d840b6a9e6eb741055e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using Live2D.Cubism.Framework.Expression;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
namespace Live2D.Cubism.Editor.Deleters
{
/// <summary>
/// Handles importing of Cubism models.
/// </summary>
[Serializable]
public sealed class CubismExpressionAssetDeleter : CubismDeleterBase
{
#region Unity Event Handling
/// <summary>
/// Registers deleter.
/// </summary>
[InitializeOnLoadMethod]
// ReSharper disable once UnusedMember.Local
private static void RegisterDeleter()
{
CubismDeleter.RegisterDeleter<CubismExpressionAssetDeleter>(".exp3.asset");
}
#endregion
#region CubismDeleterBase
/// <summary>
/// Deleters the corresponding asset.
/// </summary>
public override void Delete()
{
var directoryName = Path.GetDirectoryName(AssetPath).ToString();
var modelDir = Path.GetDirectoryName(directoryName).ToString();
var modelName = Path.GetFileName(modelDir).ToString();
var expressionListPath = Path.GetDirectoryName(directoryName).ToString() + "/" + modelName + ".expressionList.asset";
var expressionList = AssetDatabase.LoadAssetAtPath<CubismExpressionList>(expressionListPath);
if (expressionList == null)
{
return;
}
var deleteAssetName = Path.GetFileName(AssetPath).Replace(".asset", "");
var expressionObjects = new List<CubismExpressionData>();
for (var i = 0; i < expressionList.CubismExpressionObjects.Length; ++i)
{
var expression = expressionList.CubismExpressionObjects[i];
if (expression == null || expression.name == deleteAssetName)
{
continue;
}
expressionObjects.Add(expression);
}
expressionList.CubismExpressionObjects = expressionObjects.ToArray();
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2aedf3527d9dff145b82c529ea9f0403
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using Live2D.Cubism.Framework.MotionFade;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
namespace Live2D.Cubism.Editor.Deleters
{
/// <summary>
/// Handles importing of Cubism models.
/// </summary>
[Serializable]
public sealed class CubismFadeAssetDeleter : CubismDeleterBase
{
#region Unity Event Handling
/// <summary>
/// Registers deleter.
/// </summary>
[InitializeOnLoadMethod]
// ReSharper disable once UnusedMember.Local
private static void RegisterDeleter()
{
CubismDeleter.RegisterDeleter<CubismFadeAssetDeleter>(".fade.asset");
}
#endregion
#region CubismDeleterBase
/// <summary>
/// Deleters the corresponding asset.
/// </summary>
public override void Delete()
{
var directoryName = Path.GetDirectoryName(AssetPath).ToString();
var modelDir = Path.GetDirectoryName(directoryName).ToString();
var modelName = Path.GetFileName(modelDir).ToString();
var fadeMotionListPath = Path.GetDirectoryName(directoryName).ToString() + "/" + modelName + ".fadeMotionList.asset";
var fadeMotionList = AssetDatabase.LoadAssetAtPath<CubismFadeMotionList>(fadeMotionListPath);
if (fadeMotionList == null)
{
return;
}
var deleteAssetName = Path.GetFileName(AssetPath).Replace(".asset", "");
var instanceIds = new List<int>();
var fadeMotionObjects = new List<CubismFadeMotionData>();
for (var i = 0; i < fadeMotionList.CubismFadeMotionObjects.Length; ++i)
{
var fadeMotion = fadeMotionList.CubismFadeMotionObjects[i];
if (fadeMotion == null || fadeMotion.name == deleteAssetName)
{
continue;
}
instanceIds.Add(fadeMotionList.MotionInstanceIds[i]);
fadeMotionObjects.Add(fadeMotion);
}
fadeMotionList.MotionInstanceIds = instanceIds.ToArray();
fadeMotionList.CubismFadeMotionObjects = fadeMotionObjects.ToArray();
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 348be0f4b9345a84faf3e4ac4f20aa1c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
namespace Live2D.Cubism.Editor.Deleters
{
/// <summary>
/// Common interface for Cubism asset deleter.
/// </summary>
public interface ICubismDeleter
{
/// <summary>
/// Sets the asset path.
/// </summary>
void SetAssetPath(string value);
/// <summary>
/// Delete the corresponding asset.
/// </summary>
void Delete();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e926ee76085263429cbbb4ddfe71513
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: