Skip to content

Commit

Permalink
Added warning messages for missing textures and shaders. Missing shad…
Browse files Browse the repository at this point in the history
…ers now handled.
  • Loading branch information
BobDoleOwndU committed Oct 25, 2018
1 parent 8e9029a commit dead0cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion FMDL-Studio-v2/Assets/Fmdl Studio/Scripts/Classes/Fmdl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ public void Write(GameObject gameObject, string filePath)

private void GetFmdlData(GameObject gameObject)
{
FoxModel foxModel = gameObject.GetComponent<FoxModel>();// ? gameObject.GetComponent<FoxModel>() : null;
FoxModel foxModel = gameObject.GetComponent<FoxModel>();
Transform rootBone = gameObject.transform;
List<Transform> bones = new List<Transform>(0);
List<BoxCollider> boundingBoxes = new List<BoxCollider>(0);
Expand Down
19 changes: 13 additions & 6 deletions FMDL-Studio-v2/Assets/Fmdl Studio/Scripts/Classes/FmdlImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void Read(Fmdl fmdl, GameObject mainObject, FoxModel foxModel, Transform
textures[i] = LoadTextureDXT($"{Globals.texturePath}\\{name}");
else
{
Debug.Log($"Could not find {Globals.texturePath}\\{name}");
Debug.LogWarning($"Could not find {Globals.texturePath}\\{name}");

Texture2D texture = new Texture2D(512, 512);

Expand All @@ -216,8 +216,7 @@ private void Read(Fmdl fmdl, GameObject mainObject, FoxModel foxModel, Transform

textures[i] = texture;
} //else

//ctx.AddObjectToAsset($"Texture {i}", textures[i]);

textures[i].name = name;
} //for

Expand All @@ -240,8 +239,17 @@ private void Read(Fmdl fmdl, GameObject mainObject, FoxModel foxModel, Transform
materialName = Hashing.TryGetStringName(fmdl.fmdlStrCode64s[fmdlMaterialInstance.nameIndex]);
} //else

materials[i] = new Material(Shader.Find($"FoxShaders/{shaderName}"));
//ctx.AddObjectToAsset($"Material {i}", materials[i]);
//Some ombs models have broken, unused, materials in them. Try catch here is necessary to handle them.
try
{
materials[i] = new Material(Shader.Find($"FoxShaders/{shaderName}"));
} //try
catch
{
materials[i] = new Material(Shader.Find($"FoxShaders/fox3DDF_Blin_LNM"));
Debug.LogWarning($"Material {materialName} trying to use missing shader: {shaderName}! Defaulting to fox3DDF_Blin_LNM!");
} //catch

materials[i].name = materialName;

//Link textures.
Expand Down Expand Up @@ -300,7 +308,6 @@ private void Read(Fmdl fmdl, GameObject mainObject, FoxModel foxModel, Transform
for (int i = 0; i < meshCount; i++)
{
meshes[i] = new Mesh();
//ctx.AddObjectToAsset($"Mesh {i}", meshes[i]);
GameObject gameObject = new GameObject();
gameObject.transform.parent = mainObject.transform;
SkinnedMeshRenderer skinnedMeshRenderer = gameObject.AddComponent<SkinnedMeshRenderer>();
Expand Down

0 comments on commit dead0cf

Please sign in to comment.