74 lines
1.2 KiB
C#
74 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("Modifiers/Selection/Material")]
|
|
public class MegaMatSelect : MegaSelectionMod
|
|
{
|
|
public int matnum;
|
|
|
|
private float[] modselection;
|
|
|
|
public float gizSize = 0.01f;
|
|
|
|
public bool displayWeights = true;
|
|
|
|
public bool update = true;
|
|
|
|
public float weight = 1f;
|
|
|
|
public float otherweight;
|
|
|
|
public override MegaModChannel ChannelsReq()
|
|
{
|
|
return MegaModChannel.Tris;
|
|
}
|
|
|
|
public override string ModName()
|
|
{
|
|
return "Material Select";
|
|
}
|
|
|
|
public override string GetHelpURL()
|
|
{
|
|
return "?page_id=1305";
|
|
}
|
|
|
|
public float[] GetSel()
|
|
{
|
|
return modselection;
|
|
}
|
|
|
|
public override void GetSelection(MegaModifiers mc)
|
|
{
|
|
if (!ModEnabled)
|
|
{
|
|
return;
|
|
}
|
|
if (modselection == null || modselection.Length != mc.verts.Length)
|
|
{
|
|
modselection = new float[mc.verts.Length];
|
|
}
|
|
if (update)
|
|
{
|
|
update = false;
|
|
if (matnum < 0)
|
|
{
|
|
matnum = 0;
|
|
}
|
|
if (matnum >= mc.mesh.subMeshCount)
|
|
{
|
|
matnum = mc.mesh.subMeshCount - 1;
|
|
}
|
|
int[] triangles = mc.mesh.GetTriangles(matnum);
|
|
for (int i = 0; i < modselection.Length; i++)
|
|
{
|
|
modselection[i] = otherweight;
|
|
}
|
|
for (int j = 0; j < triangles.Length; j++)
|
|
{
|
|
modselection[triangles[j]] = weight;
|
|
}
|
|
}
|
|
mc.selection = modselection;
|
|
}
|
|
}
|