Skip to content

Commit 83daf66

Browse files
Improve behavior on importing SDK at first time
1 parent 8367d46 commit 83daf66

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Assets/Live2D/Cubism/Core/CubismMoc.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
using Live2D.Cubism.Core.Unmanaged;
1212
using UnityEngine;
1313

14+
#if UNITY_EDITOR
15+
using UnityEditor;
16+
#endif
17+
1418

1519
namespace Live2D.Cubism.Core
1620
{
@@ -71,6 +75,10 @@ private byte[] Bytes
7175

7276
private int ReferenceCount { get; set; }
7377

78+
#if UNITY_EDITOR
79+
private static int CoreNotFoundCallCount { get; set; }
80+
#endif
81+
7482

7583
/// <summary>
7684
/// True if instance is revived.
@@ -93,7 +101,22 @@ public CubismUnmanagedMoc AcquireUnmanagedMoc()
93101
++ReferenceCount;
94102

95103

96-
Revive();
104+
#if UNITY_EDITOR
105+
try
106+
{
107+
#endif
108+
Revive();
109+
#if UNITY_EDITOR
110+
}
111+
catch (DllNotFoundException)
112+
{
113+
if (CoreNotFoundCallCount == 0)
114+
{
115+
EditorUtility.DisplayDialog("Live2D CubismCore is not loaded", "Please reboot this Unity project if it is just after import of the SDK. If it's not, please check if platform settings of dll is correct. dll cannot be used on platform which is different from its own build settings.", "ok", "cancel");
116+
}
117+
++CoreNotFoundCallCount;
118+
}
119+
#endif
97120

98121

99122
return UnmanagedMoc;

0 commit comments

Comments
 (0)