Skip to content

Commit

Permalink
Fix memory leak warnings; Fix existing LOD group warning
Browse files Browse the repository at this point in the history
  • Loading branch information
amirebrahimi committed Aug 30, 2019
1 parent d5513b7 commit cdc00f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Scripts/Editor/ModelImporterLODGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void OnPostprocessModel(GameObject go)
AssetDatabase.SaveAssets();

// Process dependencies first
var jobDependencies = new NativeArray<JobHandle>(preprocessMeshes.Count, Allocator.Temp);
var jobDependencies = new NativeArray<JobHandle>(preprocessMeshes.Count, Allocator.Persistent);
var i = 0;
meshLODs.RemoveAll(ml =>
{
Expand Down Expand Up @@ -272,7 +272,7 @@ void OnPostprocessModel(GameObject go)
lods.Add(lod);
}

if (importerLODLevels.arraySize != 0 && maxLODFound != importerLODLevels.arraySize)
if (importerLODLevels.arraySize != 0 && maxLODFound != importerLODLevels.arraySize - 1)
Debug.LogWarning("The model has an existing lod group, but it's settings will not be used because " +
"the specified lod count in the AutoLOD settings is different.");

Expand Down
4 changes: 2 additions & 2 deletions Scripts/Helpers/MeshLOD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public JobHandle Generate(NativeArray<JobHandle>? jobDependencies = null)
MonoBehaviourHelper.ExecuteOnMainThread(() => { });

var job = new GenerateMeshLODJob();
job.inputMesh = inputMesh.ToWorkingMesh(Allocator.TempJob);
job.inputMesh = inputMesh.ToWorkingMesh(Allocator.Persistent);
job.quality = quality;
var typeNameBytes = Encoding.UTF8.GetBytes(meshSimplifierType.AssemblyQualifiedName);
job.meshSimplifierTypeName = new NativeArray<byte>(typeNameBytes, Allocator.TempJob);
job.meshSimplifierTypeName = new NativeArray<byte>(typeNameBytes, Allocator.Persistent);
job.outputMesh = new WorkingMesh(Allocator.Persistent, inputMesh.vertexCount, inputMesh.GetTriangleCount(),
inputMesh.subMeshCount, inputMesh.blendShapeCount);

Expand Down

0 comments on commit cdc00f8

Please sign in to comment.