All characters are now rotated to 0,0,0 when spawned

Fixed texture deletion error
This commit is contained in:
Katboi01 2024-03-30 12:29:20 +01:00
parent 3b4ec2ba92
commit 07e2c4d88c
2 changed files with 58 additions and 55 deletions

View File

@ -128,32 +128,33 @@ public class FateModelBuilder : MonoBehaviour
foreach (var asset in assetBundle.LoadAllAssets()) foreach (var asset in assetBundle.LoadAllAssets())
{ {
if (asset == null) { continue; } if (asset == null) { continue; }
else if (asset.GetType() == typeof(GameObject)) switch (asset)
{ {
if((asset as GameObject).name == "chr") case GameObject go:
{ {
servant.BodyMain = asset as GameObject; if (go.name == "chr")
} {
} go.transform.eulerAngles = Vector3.zero;
else if (asset.GetType() == typeof(Texture2D)) servant.BodyMain = go;
{ }
Texture2D tex = asset as Texture2D; break;
servant.Textures.Add(tex); }
} case Texture2D tex:
else if (asset.GetType() == typeof(Material)) {
{ servant.Textures.Add(tex);
servant.Materials.Add(asset as Material); break;
} }
else if (asset.GetType() == typeof(TextAsset)) case Material mat:
{ {
} servant.Materials.Add(mat);
else if (asset.GetType() == typeof(AnimationClip)) break;
{ }
} case TextAsset text:
else case AnimationClip anim:
{ default:
//Error.Log(Color.yellow, asset.GetType().ToString()); //Error.Log(Color.yellow, asset.GetType().ToString());
//Debug.LogWarning(asset.GetType()); //Debug.LogWarning(asset.GetType());
break;
} }
} }
@ -276,36 +277,38 @@ public class FateModelBuilder : MonoBehaviour
foreach (var asset in assetBundle.LoadAllAssets()) foreach (var asset in assetBundle.LoadAllAssets())
{ {
if (asset == null) { continue; } if (asset == null) { continue; }
else if (asset.GetType() == typeof(GameObject)) switch (asset)
{ {
if (asset.name.StartsWith("chr_")) case GameObject go:
{ {
servant.BodyMain = asset as GameObject; if (asset.name.StartsWith("chr_"))
} {
else if (asset.name.StartsWith("model_")) servant.BodyMain = go;
{ }
Instantiate(asset, servant.transform); else if (asset.name.StartsWith("model_"))
} {
} Instantiate(asset, servant.transform);
else if (asset.GetType() == typeof(Texture2D)) }
{ break;
Texture2D tex = asset as Texture2D; }
servant.Textures.Add(tex); case Texture2D tex:
} {
else if (asset.GetType() == typeof(Material)) servant.Textures.Add(tex);
{ break;
servant.Materials.Add(asset as Material); }
} case Material mat:
else if (asset.GetType() == typeof(TextAsset)) {
{ servant.Materials.Add(mat);
} break;
else if (asset.GetType() == typeof(AnimationClip)) }
{ case TextAsset tex:
} case AnimationClip anim:
else default:
{ {
Error.Log(Color.yellow, asset.GetType().ToString()); Error.Log(Color.yellow, asset.GetType().ToString());
Debug.LogWarning(asset.GetType()); Debug.LogWarning(asset.GetType());
break;
}
} }
} }

View File

@ -130,7 +130,7 @@ public class FateServantContainer : MonoBehaviour
} }
for (int i = Textures.Count - 1; i >= 0; i--) 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--) for (int i = InstantiatedObjects.Count - 1; i >= 0; i--)
{ {