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;
servant.BodyMain = go;
} }
break;
} }
else if (asset.GetType() == typeof(Texture2D)) case Texture2D tex:
{ {
Texture2D tex = asset as Texture2D;
servant.Textures.Add(tex); servant.Textures.Add(tex);
break;
} }
else if (asset.GetType() == typeof(Material)) case Material mat:
{ {
servant.Materials.Add(asset as Material); servant.Materials.Add(mat);
break;
} }
else if (asset.GetType() == typeof(TextAsset)) case TextAsset text:
{ case AnimationClip anim:
} default:
else if (asset.GetType() == typeof(AnimationClip))
{
}
else
{
//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)
{
case GameObject go:
{ {
if (asset.name.StartsWith("chr_")) if (asset.name.StartsWith("chr_"))
{ {
servant.BodyMain = asset as GameObject; servant.BodyMain = go;
} }
else if (asset.name.StartsWith("model_")) else if (asset.name.StartsWith("model_"))
{ {
Instantiate(asset, servant.transform); Instantiate(asset, servant.transform);
} }
break;
} }
else if (asset.GetType() == typeof(Texture2D)) case Texture2D tex:
{ {
Texture2D tex = asset as Texture2D;
servant.Textures.Add(tex); servant.Textures.Add(tex);
break;
} }
else if (asset.GetType() == typeof(Material)) case Material mat:
{ {
servant.Materials.Add(asset as Material); servant.Materials.Add(mat);
break;
} }
else if (asset.GetType() == typeof(TextAsset)) case TextAsset tex:
{ case AnimationClip anim:
} default:
else if (asset.GetType() == typeof(AnimationClip))
{
}
else
{ {
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--)
{ {