diff --git a/Assets/Scripts/FateModelBuilder.cs b/Assets/Scripts/FateModelBuilder.cs index 4203320..3d3a5e7 100644 --- a/Assets/Scripts/FateModelBuilder.cs +++ b/Assets/Scripts/FateModelBuilder.cs @@ -128,32 +128,33 @@ public class FateModelBuilder : MonoBehaviour foreach (var asset in assetBundle.LoadAllAssets()) { if (asset == null) { continue; } - else if (asset.GetType() == typeof(GameObject)) + switch (asset) { - if((asset as GameObject).name == "chr") - { - servant.BodyMain = asset as GameObject; - } - } - else if (asset.GetType() == typeof(Texture2D)) - { - Texture2D tex = asset as Texture2D; - servant.Textures.Add(tex); - } - else if (asset.GetType() == typeof(Material)) - { - servant.Materials.Add(asset as Material); - } - else if (asset.GetType() == typeof(TextAsset)) - { - } - else if (asset.GetType() == typeof(AnimationClip)) - { - } - else - { - //Error.Log(Color.yellow, asset.GetType().ToString()); - //Debug.LogWarning(asset.GetType()); + case GameObject go: + { + if (go.name == "chr") + { + go.transform.eulerAngles = Vector3.zero; + servant.BodyMain = go; + } + break; + } + case Texture2D tex: + { + servant.Textures.Add(tex); + break; + } + case Material mat: + { + servant.Materials.Add(mat); + break; + } + case TextAsset text: + case AnimationClip anim: + default: + //Error.Log(Color.yellow, asset.GetType().ToString()); + //Debug.LogWarning(asset.GetType()); + break; } } @@ -276,36 +277,38 @@ public class FateModelBuilder : MonoBehaviour foreach (var asset in assetBundle.LoadAllAssets()) { if (asset == null) { continue; } - else if (asset.GetType() == typeof(GameObject)) + switch (asset) { - if (asset.name.StartsWith("chr_")) - { - servant.BodyMain = asset as GameObject; - } - else if (asset.name.StartsWith("model_")) - { - Instantiate(asset, servant.transform); - } - } - else if (asset.GetType() == typeof(Texture2D)) - { - Texture2D tex = asset as Texture2D; - servant.Textures.Add(tex); - } - else if (asset.GetType() == typeof(Material)) - { - servant.Materials.Add(asset as Material); - } - else if (asset.GetType() == typeof(TextAsset)) - { - } - else if (asset.GetType() == typeof(AnimationClip)) - { - } - else - { - Error.Log(Color.yellow, asset.GetType().ToString()); - Debug.LogWarning(asset.GetType()); + case GameObject go: + { + if (asset.name.StartsWith("chr_")) + { + servant.BodyMain = go; + } + else if (asset.name.StartsWith("model_")) + { + Instantiate(asset, servant.transform); + } + break; + } + case Texture2D tex: + { + servant.Textures.Add(tex); + break; + } + case Material mat: + { + servant.Materials.Add(mat); + break; + } + case TextAsset tex: + case AnimationClip anim: + default: + { + Error.Log(Color.yellow, asset.GetType().ToString()); + Debug.LogWarning(asset.GetType()); + break; + } } } diff --git a/Assets/Scripts/FateServantContainer.cs b/Assets/Scripts/FateServantContainer.cs index 998dc4e..14479a9 100644 --- a/Assets/Scripts/FateServantContainer.cs +++ b/Assets/Scripts/FateServantContainer.cs @@ -130,7 +130,7 @@ public class FateServantContainer : MonoBehaviour } for (int i = Textures.Count - 1; i >= 0; i--) { - Destroy(Textures[i]); + DestroyImmediate(Textures[i], true); } for (int i = InstantiatedObjects.Count - 1; i >= 0; i--) {