Skip to content

Commit 74eca48

Browse files
Merge pull request Live2D#26 from Live2D/original_workflow_beta
Add MotionController and refactoring code.
2 parents 09f1ed5 + bf5429c commit 74eca48

File tree

57 files changed

+2090
-782
lines changed

Some content is hidden

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

57 files changed

+2090
-782
lines changed

Assets/Live2D/Cubism/Core/ArrayExtensionMethods.cs

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
*/
77

88

9-
using System;
10-
using System.Runtime.InteropServices;
119
using Live2D.Cubism.Core.Unmanaged;
10+
using System;
1211
using UnityEngine;
1312

1413

@@ -29,9 +28,22 @@ public static class ArrayExtensionMethods
2928
/// <returns>Parameter on success; <see langword="null"/> otherwise.</returns>
3029
public static CubismParameter FindById(this CubismParameter[] self, string id)
3130
{
32-
return (self != null)
33-
? Array.Find(self, i => i.name == id)
34-
: null;
31+
if (self == null)
32+
{
33+
return null;
34+
}
35+
36+
for (var i = 0; i < self.Length; ++i)
37+
{
38+
if (self[i].name != id)
39+
{
40+
continue;
41+
}
42+
43+
return self[i];
44+
}
45+
46+
return null;
3547
}
3648

3749

@@ -101,9 +113,22 @@ internal static void ReadFrom(this CubismParameter[] self, CubismUnmanagedModel
101113
/// <returns>Part if found; <see langword="null"/> otherwise.</returns>
102114
public static CubismPart FindById(this CubismPart[] self, string id)
103115
{
104-
return (self != null)
105-
? Array.Find(self, i => i.name == id)
106-
: null;
116+
if (self == null)
117+
{
118+
return null;
119+
}
120+
121+
for (var i = 0; i < self.Length; ++i)
122+
{
123+
if (self[i].name != id)
124+
{
125+
continue;
126+
}
127+
128+
return self[i];
129+
}
130+
131+
return null;
107132
}
108133

109134

@@ -154,9 +179,22 @@ internal static void WriteTo(this CubismPart[] self, CubismUnmanagedModel unmana
154179
/// <returns>Part if found; <see langword="null"/> otherwise.</returns>
155180
public static CubismDrawable FindById(this CubismDrawable[] self, string id)
156181
{
157-
return (self != null)
158-
? Array.Find(self, i => i.name == id)
159-
: null;
182+
if (self == null)
183+
{
184+
return null;
185+
}
186+
187+
for (var i = 0; i < self.Length; ++i)
188+
{
189+
if (self[i].name != id)
190+
{
191+
continue;
192+
}
193+
194+
return self[i];
195+
}
196+
197+
return null;
160198
}
161199

162200

Assets/Live2D/Cubism/Core/CubismDrawable.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
*/
77

88

9-
using Live2D.Cubism.Framework;
10-
using System;
11-
using System.Runtime.InteropServices;
129
using Live2D.Cubism.Core.Unmanaged;
10+
using Live2D.Cubism.Framework;
1311
using UnityEngine;
1412

1513

Assets/Live2D/Cubism/Core/CubismDynamicDrawableData.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77

88

9-
using System;
10-
using System.Runtime.InteropServices;
119
using Live2D.Cubism.Core.Unmanaged;
1210
using UnityEngine;
1311

Assets/Live2D/Cubism/Core/CubismLogging.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88

99
using AOT;
10+
using Live2D.Cubism.Core.Unmanaged;
1011
using System;
1112
using System.Runtime.InteropServices;
12-
using Live2D.Cubism.Core.Unmanaged;
1313
using UnityEngine;
1414

1515

Assets/Live2D/Cubism/Core/CubismMoc.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright(c) Live2D Inc. All rights reserved.
33
*
44
* Use of this source code is governed by the Live2D Open Software license
@@ -7,7 +7,6 @@
77

88

99
using System;
10-
using System.Runtime.InteropServices;
1110
using Live2D.Cubism.Core.Unmanaged;
1211
using UnityEngine;
1312

Assets/Live2D/Cubism/Core/CubismModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ private bool CanRevive
194194
get { return Moc != null; }
195195
}
196196

197-
198197
/// <summary>
199198
/// Revives instance.
200199
/// </summary>

Assets/Live2D/Cubism/Core/CubismParameter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
*/
77

88

9-
using Live2D.Cubism.Framework;
10-
using System;
11-
using System.Runtime.InteropServices;
129
using Live2D.Cubism.Core.Unmanaged;
10+
using Live2D.Cubism.Framework;
1311
using UnityEngine;
1412

1513

Assets/Live2D/Cubism/Core/CubismPart.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
*/
77

88

9-
using Live2D.Cubism.Framework;
10-
using System;
11-
using System.Runtime.InteropServices;
129
using Live2D.Cubism.Core.Unmanaged;
10+
using Live2D.Cubism.Framework;
1311
using UnityEngine;
1412

1513

Assets/Live2D/Cubism/Core/CubismTaskableModel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
*/
77

88

9-
using System;
10-
using System.Runtime.InteropServices;
11-
using System.Threading;
129
using Live2D.Cubism.Core.Unmanaged;
10+
using System.Threading;
1311

1412

1513
namespace Live2D.Cubism.Core

Assets/Live2D/Cubism/Editor/CubismAssetProcessor.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*/
77

88

9+
using Live2D.Cubism.Editor.Deleters;
10+
using Live2D.Cubism.Editor.Importers;
911
using Live2D.Cubism.Rendering;
1012
using Live2D.Cubism.Rendering.Masking;
1113
using System.IO;
1214
using System.Linq;
1315
using System.Xml.Linq;
14-
using Live2D.Cubism.Editor.Importers;
15-
using Live2D.Cubism.Editor.Deleters;
1616
using UnityEditor;
1717
using UnityEngine;
1818
using UnityEngine.Rendering;
@@ -50,11 +50,11 @@ private static void OnPostprocessAllAssets(
5050
string[] movedAssetPaths,
5151
string[] movedFromAssetPaths)
5252
{
53-
// Make sure builtin resources are available.
54-
GenerateBuiltinResources();
53+
// Make sure builtin resources are available.
54+
GenerateBuiltinResources();
5555

5656

57-
// Handle any imported Cubism assets.
57+
// Handle any imported Cubism assets.
5858
foreach (var assetPath in importedAssetPaths)
5959
{
6060
var importer = CubismImporter.GetImporterAtPath(assetPath);
@@ -148,7 +148,7 @@ private static void AllowUnsafeCode()
148148

149149
#endregion
150150

151-
#region Resources Generation
151+
#region Resources Generation
152152

153153
/// <summary>
154154
/// Sets Cubism-style normal blending for a material.
@@ -203,29 +203,29 @@ private static void EnableMasking(Material material)
203203
shaderKeywords.RemoveAll(k => k == "CUBISM_MASK_OFF");
204204

205205

206-
if (!shaderKeywords.Contains("CUBISM_MASK_ON"))
207-
{
208-
shaderKeywords.Add("CUBISM_MASK_ON");
209-
}
206+
if (!shaderKeywords.Contains("CUBISM_MASK_ON"))
207+
{
208+
shaderKeywords.Add("CUBISM_MASK_ON");
209+
}
210210

211211

212-
material.shaderKeywords = shaderKeywords.ToArray();
212+
material.shaderKeywords = shaderKeywords.ToArray();
213213
}
214214

215215

216216
/// <summary>
217217
/// Generates the builtin resources as necessary.
218218
/// </summary>
219-
private static void GenerateBuiltinResources()
220-
{
221-
var resourcesRoot = AssetDatabase
222-
.GetAssetPath(CubismBuiltinShaders.Unlit)
223-
.Replace("/Shaders/Unlit.shader", "");
219+
private static void GenerateBuiltinResources()
220+
{
221+
var resourcesRoot = AssetDatabase
222+
.GetAssetPath(CubismBuiltinShaders.Unlit)
223+
.Replace("/Shaders/Unlit.shader", "");
224224

225225

226-
// Create materials.
227-
if (CubismBuiltinMaterials.Mask == null)
228-
{
226+
// Create materials.
227+
if (CubismBuiltinMaterials.Mask == null)
228+
{
229229
var materialsRoot = resourcesRoot + "/Materials";
230230

231231

@@ -305,23 +305,23 @@ private static void GenerateBuiltinResources()
305305
AssetDatabase.CreateAsset(material, string.Format("{0}/{1}.mat", materialsRoot, material.name));
306306

307307

308-
EditorUtility.SetDirty(CubismBuiltinShaders.Unlit);
309-
AssetDatabase.SaveAssets();
310-
}
308+
EditorUtility.SetDirty(CubismBuiltinShaders.Unlit);
309+
AssetDatabase.SaveAssets();
310+
}
311311

312312

313-
// Create global mask texture.
314-
if (CubismMaskTexture.GlobalMaskTexture == null)
315-
{
313+
// Create global mask texture.
314+
if (CubismMaskTexture.GlobalMaskTexture == null)
315+
{
316316
var globalMaskTexture = ScriptableObject.CreateInstance<CubismMaskTexture>();
317317

318318
globalMaskTexture.name = "GlobalMaskTexture";
319319

320320

321321
AssetDatabase.CreateAsset(globalMaskTexture, string.Format("{0}/{1}.asset", resourcesRoot, globalMaskTexture.name));
322-
}
323-
}
322+
}
323+
}
324324

325-
#endregion
325+
#endregion
326326
}
327327
}

0 commit comments

Comments
 (0)