Skip to content

Commit

Permalink
修复无physics情况
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfare committed Oct 23, 2019
1 parent 25276b6 commit 93eefe6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions UnityLive2DExtractor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,28 @@ static void Main(string[] args)
}
var assets = assetsManager.assetsFileList[0].Objects.Values.ToList();
var name = Path.GetFileName(path);
var destPath = @"live2d\" + name + @"\";
var destTexturePath = @"live2d\" + name + @"\textures\";
var destAnimationPath = @"live2d\" + name + @"\motions\";
var destPath = Path.Combine("live2d", name) + Path.DirectorySeparatorChar;
var destTexturePath = Path.Combine(destPath, "textures") + Path.DirectorySeparatorChar;
var destAnimationPath = Path.Combine(destPath, "motions") + Path.DirectorySeparatorChar;
Directory.CreateDirectory(destPath);
Directory.CreateDirectory(destTexturePath);
Directory.CreateDirectory(destAnimationPath);
Console.WriteLine($"Extract {name}");
//MonoBehaviour
var monoBehaviours = assets.OfType<MonoBehaviour>().ToArray();
//physics
var physics = monoBehaviours.First(x =>
var physics = monoBehaviours.FirstOrDefault(x =>
{
if (x.m_Script.TryGet(out var m_Script))
{
return m_Script.m_ClassName == "CubismPhysicsController";
}
return false;
});
File.WriteAllText($"{destPath}{name}.physics3.json", ParsePhysics(physics));
if (physics != null)
{
File.WriteAllText($"{destPath}{name}.physics3.json", ParsePhysics(physics));
}
//moc
var moc = monoBehaviours.First(x =>
{
Expand Down Expand Up @@ -223,11 +226,15 @@ static void Main(string[] args)
{
Moc = $"{name}.moc3",
Textures = textures.ToArray(),
Physics = $"{name}.physics3.json",
//Physics = $"{name}.physics3.json",
Motions = job
},
Groups = groups.ToArray()
};
if (physics != null)
{
model3.FileReferences.Physics = $"{name}.physics3.json";
}
File.WriteAllText($"{destPath}{name}.model3.json", JsonConvert.SerializeObject(model3, Formatting.Indented));
}
Console.WriteLine("Done!");
Expand Down

0 comments on commit 93eefe6

Please sign in to comment.