test : opti
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af40c02d10e408f40858ac9be2668106
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public static class EnableGPUInstancing
|
||||
{
|
||||
private const string MaterialPrefix = "M_";
|
||||
|
||||
[MenuItem("Tools/Optimization/Enable GPU Instancing On M_ Materials")]
|
||||
public static void EnableOnMPrefixMaterials()
|
||||
{
|
||||
string[] materialGuids = AssetDatabase.FindAssets("t:Material");
|
||||
|
||||
int changed = 0;
|
||||
int alreadyEnabled = 0;
|
||||
int skippedWrongPrefix = 0;
|
||||
int skippedInvalid = 0;
|
||||
|
||||
foreach (string guid in materialGuids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
Material mat = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
|
||||
if (mat == null || mat.shader == null || !mat.shader.isSupported)
|
||||
{
|
||||
skippedInvalid++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mat.name.StartsWith(MaterialPrefix))
|
||||
{
|
||||
skippedWrongPrefix++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mat.enableInstancing)
|
||||
{
|
||||
alreadyEnabled++;
|
||||
continue;
|
||||
}
|
||||
|
||||
mat.enableInstancing = true;
|
||||
EditorUtility.SetDirty(mat);
|
||||
changed++;
|
||||
}
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
Debug.Log(
|
||||
$"GPU Instancing terminé sur les matériaux commençant par '{MaterialPrefix}'. " +
|
||||
$"Activés : {changed}, " +
|
||||
$"déjà actifs : {alreadyEnabled}, " +
|
||||
$"ignorés mauvais préfixe : {skippedWrongPrefix}, " +
|
||||
$"ignorés invalides : {skippedInvalid}."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d7b767fc9ca8984ca9685fa864b4250
|
||||
Reference in New Issue
Block a user