Harald
Hi and thank you for responding. Here is a snippet, note again this is in non-play mode for prefabs only, as I understand UpdateMesh() not Initialize() is not required at the end correct?
Another suggestion: from my custom code i want to call static methods DetectMaterial() and DetectBlendModeMaterials() but they are inside SkeletonGraphicInspector and private, using reflection for me is fine as its editor only anyway. I would suggest bringing them out to some public EditorUtility as its really not inspector only related and blocks from custom automation, just my 2 cents, thank you.
public bool autoDetectMaterial = true;
public bool autoDetectBlendModeMaterials = true;
public MeshGenerator.Settings settings = new MeshGenerator.Settings {
pmaVertexColors = false,
zSpacing = 0f,
useClipping = true,
tintBlack = false,
calculateTangents = false,
addNormals = false,
immutableTriangles = false,
canvasGroupCompatible = true
};
public bool allowMultipleCanvasRenderers = true;
public bool startingLoop = false;
public bool raycastTarget = false;
t.MeshGenerator.settings = settings;
t.allowMultipleCanvasRenderers = allowMultipleCanvasRenderers;
t.startingLoop = startingLoop;
t.raycastTarget = raycastTarget;
if (autoDetectMaterial)
{
TryAutoDetect("DetectMaterial", t);
}
if (autoDetectBlendModeMaterials)
{
TryAutoDetect("DetectBlendModeMaterials", t);
}
t.UpdateMesh();
private static void TryAutoDetect(string methodName, SkeletonGraphic skeletonGraphic)
{
var type = typeof(SkeletonGraphicInspector);
// Find the private static method
var method = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static);
if (method != null)
{
// Pass arguments as an object array
object[] parameters = { skeletonGraphic };
method.Invoke(null, parameters);
}
else
{
Debug.LogError($"Could not find method '{methodName}'!");
}
}