live2D (sdk가 6.5 미지원으로 sprite로 대응)
This commit is contained in:
135
Assets/Live2D/Cubism/Plugins/Editor/CubismiOSPluginProcessor.cs
Normal file
135
Assets/Live2D/Cubism/Plugins/Editor/CubismiOSPluginProcessor.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* 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.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Live2D.Cubism.Plugins.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Configure iOS plugins before the build.
|
||||
/// </summary>
|
||||
public class CubismiOSPluginProcessor : IPreprocessBuildWithReport
|
||||
{
|
||||
/// <summary>
|
||||
/// Execution order.
|
||||
/// </summary>
|
||||
public int callbackOrder
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable the appropriate plugins from the SDK Type and SDK Version in the iOS Build Target before building.
|
||||
/// </summary>
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
// Skip the process if the build is not for iOS.
|
||||
if (report.summary.platform != BuildTarget.iOS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Detect the type of iOS plugin by SDK type and SDK version in the build settings.
|
||||
CubismiOSPlugin targetPlugin;
|
||||
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
if (EditorUserBuildSettings.iOSXcodeBuildConfig == XcodeBuildConfig.Debug)
|
||||
#else
|
||||
if (EditorUserBuildSettings.iOSBuildConfigType == iOSBuildType.Debug)
|
||||
#endif
|
||||
{
|
||||
targetPlugin = PlayerSettings.iOS.sdkVersion == iOSSdkVersion.DeviceSDK
|
||||
? CubismiOSPlugin.DebugIphoneos
|
||||
: PlayerSettings.iOS.simulatorSdkArchitecture == AppleMobileArchitectureSimulator.X86_64
|
||||
? CubismiOSPlugin.DebugIphoneSimulatorX64
|
||||
: CubismiOSPlugin.DebugIphoneSimulatorArm64;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPlugin = PlayerSettings.iOS.sdkVersion == iOSSdkVersion.DeviceSDK
|
||||
? CubismiOSPlugin.ReleaseIphoneos
|
||||
: PlayerSettings.iOS.simulatorSdkArchitecture == AppleMobileArchitectureSimulator.X86_64
|
||||
? CubismiOSPlugin.ReleaseIphoneSimulatorX64
|
||||
: CubismiOSPlugin.ReleaseIphoneSimulatorArm64;
|
||||
}
|
||||
|
||||
if (PlayerSettings.iOS.sdkVersion ==iOSSdkVersion.SimulatorSDK
|
||||
&& PlayerSettings.iOS.simulatorSdkArchitecture == AppleMobileArchitectureSimulator.Universal)
|
||||
{
|
||||
Debug.LogWarning("Arm64 Core will be used for `Universal`. If you want to check on x86_64 devices(Rosetta 2), please build for `x86_64`.");
|
||||
}
|
||||
|
||||
|
||||
// Extract the Cubism iOS plugin from the plugin.
|
||||
var pluginImporters = PluginImporter.GetAllImporters()
|
||||
.Where(pluginImporter =>
|
||||
Regex.IsMatch(
|
||||
pluginImporter.assetPath,
|
||||
@"^.*/iOS/.*/libLive2DCubismCore.a$"
|
||||
)
|
||||
)
|
||||
.ToArray();
|
||||
|
||||
|
||||
// Enable only the appropriate plugins.
|
||||
foreach (var pluginImporter in pluginImporters)
|
||||
{
|
||||
pluginImporter.SetCompatibleWithPlatform(
|
||||
BuildTarget.iOS,
|
||||
pluginImporter.assetPath.Contains(targetPlugin.DirectoryName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Defines the type of plugin for iOS.
|
||||
/// </summary>
|
||||
private class CubismiOSPlugin
|
||||
{
|
||||
public readonly string DirectoryName;
|
||||
|
||||
public static CubismiOSPlugin DebugIphoneos
|
||||
{
|
||||
get { return new CubismiOSPlugin("Debug-iphoneos"); }
|
||||
}
|
||||
public static CubismiOSPlugin DebugIphoneSimulatorArm64
|
||||
{
|
||||
get { return new CubismiOSPlugin("Debug-iphonesimulator-arm64"); }
|
||||
}
|
||||
public static CubismiOSPlugin DebugIphoneSimulatorX64
|
||||
{
|
||||
get { return new CubismiOSPlugin("Debug-iphonesimulator-x86_64"); }
|
||||
}
|
||||
public static CubismiOSPlugin ReleaseIphoneos
|
||||
{
|
||||
get { return new CubismiOSPlugin("Release-iphoneos"); }
|
||||
}
|
||||
public static CubismiOSPlugin ReleaseIphoneSimulatorArm64
|
||||
{
|
||||
get { return new CubismiOSPlugin("Release-iphonesimulator-arm64"); }
|
||||
}
|
||||
public static CubismiOSPlugin ReleaseIphoneSimulatorX64
|
||||
{
|
||||
get { return new CubismiOSPlugin("Release-iphonesimulator-x86_64"); }
|
||||
}
|
||||
|
||||
private CubismiOSPlugin(string directoryName)
|
||||
{
|
||||
DirectoryName = directoryName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 054532c6e6d4e44a1a4a6799a359eb43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reference": "GUID:e5d337e0b3581c343aafde08e6e1727e"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b3a69a921e20e94fa6991fe3d945403
|
||||
AssemblyDefinitionReferenceImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user