Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed very heavy process when there are many assets in the project #162

Open
wants to merge 10 commits into
base: 1.7/release
Choose a base branch
from
Prev Previous commit
Next Next commit
Fixed some issue
momoma-null committed Apr 21, 2021
commit 5558e3aead7361ec1b9194839abefedf4d4a7c56
Binary file modified Editor/SettingTemplate/setting.fbx
Binary file not shown.
61 changes: 49 additions & 12 deletions Editor/SettingTemplate/setting.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 24 additions & 10 deletions Editor/System/Importers/ModelImporterConfigurator.cs
Original file line number Diff line number Diff line change
@@ -158,8 +158,15 @@ private bool IsEqual(ModelImporter target, ModelImporter reference)
if (Math.Abs(target.clipAnimations[i].additiveReferencePoseFrame -
reference.clipAnimations[i].additiveReferencePoseFrame) > kTOLERANCE)
return false;
if (target.clipAnimations[i].curves != reference.clipAnimations[i].curves)
if (target.clipAnimations[i].curves.Length != reference.clipAnimations[i].curves.Length)
return false;
for (var j = 0; j < target.clipAnimations[i].curves.Length; ++j)
{
if (target.clipAnimations[i].curves[j].name != reference.clipAnimations[i].curves[j].name)
return false;
if (!target.clipAnimations[i].curves[j].curve.Equals(reference.clipAnimations[i].curves[j].curve))
return false;
}
if (Math.Abs(target.clipAnimations[i].cycleOffset - reference.clipAnimations[i].cycleOffset) >
kTOLERANCE)
return false;
@@ -326,12 +333,15 @@ private bool IsEqual(ModelImporter target, ModelImporter reference)
return false;

#if UNITY_2019_2_OR_NEWER
if (target.maxBonesPerVertex != reference.maxBonesPerVertex)
return false;
if (reference.skinWeights == ModelImporterSkinWeights.Custom)
{
if (target.maxBonesPerVertex != reference.maxBonesPerVertex)
return false;
if (Math.Abs(target.minBoneWeight - reference.minBoneWeight) > kTOLERANCE)
return false;
}
if (target.meshOptimizationFlags != reference.meshOptimizationFlags)
return false;
if (Math.Abs(target.minBoneWeight - reference.minBoneWeight) > kTOLERANCE)
return false;
if (target.skinWeights != reference.skinWeights)
return false;
if (target.sortHierarchyByName != reference.sortHierarchyByName)
@@ -427,9 +437,6 @@ private void OverwriteImportSettings(ModelImporter target, ModelImporter referen

target.animationType = reference.animationType;
target.animationWrapMode = reference.animationWrapMode;
#if UNITY_2019_3_OR_NEWER
target.avatarSetup = reference.avatarSetup;
#endif

target.bakeIK = reference.bakeIK;
if (reference.importAnimation && m_overwriteAnimationClipSettings)
@@ -475,14 +482,17 @@ private void OverwriteImportSettings(ModelImporter target, ModelImporter referen
target.materialSearch = reference.materialSearch;

#if UNITY_2019_2_OR_NEWER
target.maxBonesPerVertex = reference.maxBonesPerVertex;
if (reference.skinWeights == ModelImporterSkinWeights.Custom)
{
target.maxBonesPerVertex = reference.maxBonesPerVertex;
target.minBoneWeight = reference.minBoneWeight;
}
#endif

target.meshCompression = reference.meshCompression;

#if UNITY_2019_2_OR_NEWER
target.meshOptimizationFlags = reference.meshOptimizationFlags;
target.minBoneWeight = reference.minBoneWeight;
#endif
target.motionNodeName = reference.motionNodeName;

@@ -517,6 +527,10 @@ private void OverwriteImportSettings(ModelImporter target, ModelImporter referen
target.useFileUnits = reference.useFileUnits;
target.useSRGBMaterialColor = reference.useSRGBMaterialColor;
target.weldVertices = reference.weldVertices;

#if UNITY_2019_3_OR_NEWER
target.avatarSetup = reference.avatarSetup;
#endif
}
}
}
637 changes: 384 additions & 253 deletions Editor/System/Node/Buitin/AssetGenerator.cs

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions Editor/System/Node/Buitin/ImportSetting.cs
Original file line number Diff line number Diff line change
@@ -514,16 +514,10 @@ private void ApplyImportSetting(BuildTarget target, Model.NodeData node, IEnumer
var importer = AssetImporter.GetAtPath(asset.importFrom);
if (configurator.IsModified(referenceImporter, importer, target, groupKey))
{
using (var importerSO = new SerializedObject(importer))
{
configurator.Configure(referenceImporter, importer, target, groupKey);
AssetProcessEventRecord.GetRecord().LogModify(asset);
if (importerSO.UpdateIfRequiredOrScript())
{
importer.SaveAndReimport();
asset.TouchImportAsset();
}
}
configurator.Configure(referenceImporter, importer, target, groupKey);
AssetProcessEventRecord.GetRecord().LogModify(asset);
importer.SaveAndReimport();
asset.TouchImportAsset();
}
}
}
10 changes: 9 additions & 1 deletion Editor/System/Node/Buitin/Modifier.cs
Original file line number Diff line number Diff line change
@@ -344,11 +344,14 @@ public override void Build(BuildTarget target,
}
}
}
asset.ReleaseData();
}
}
}
}
catch
{
throw;
}
finally
{
AssetDatabase.StopAssetEditing();
@@ -360,6 +363,11 @@ public override void Build(BuildTarget target,
AssetDatabase.SaveAssets();
}

foreach (var assets in aggregatedGroups.Values)
foreach (var asset in assets)
if (asset.assetType == targetType)
asset.ReleaseData();

if (incoming != null && Output != null)
{
// Modifier does not add, filter or change structure of group, so just pass given group of assets