MD Package Technical & APi Documentation
MD_MeshProEditor
Namespace: MDPackage
Essential component for general mesh processing and a bridge between Mesh Deformation modifiers.
Read more here (Online documentation slide)
Public Methods
// Mesh-essentials

// Update current mesh state (sync generated points with the mesh vertices) & recalculate normals + bounds
public void MPE_UpdateMesh()
// Recalculate current mesh normals and bounds
public void MPE_RecalculateMeshNormalsAndBounds()

// Mesh Editor Vertices

// Hide/Show generated points on the mesh
public void MPE_ShowHideGeneratedPoints(bool activeState)
// Set 'Ignore Raycast' layer to all generated points
public void MPE_IgnoreRaycastForGeneratedPoints(bool ignoreRaycast)
// Create a points/vertex editor on the current mesh
public void MPE_CreatePointsEditor(bool bypassVertexLimit = false)
// Create a points/vertex editor on the current mesh with custom point object pattern
public void MPE_CreatePointsEditor(GameObject customPatternObjectReference, float sizeMultiplier = 1f, bool bypassVertexLimit = false)
// Create a points/vertex editor on the current mesh with custom point color
public void MPE_CreatePointsEditor(Color customPointColor, float sizeMupliplier = 1f, bool bypassVertexLimit = false)
// Clear points/vertex editor if possible
public void MPE_ClearPointsEditor()

// Mesh Combine

// Combine all sub-meshes with the current mesh. This will create a brand new gameObject & notification will popup
public void MPE_CombineMeshAndCreateNewInstance()
// Combine all sub-meshes with current the mesh. This will NOT create a new gameObject & notification will not popup
public void MPE_CombineMeshImmediately()

// Mesh References

// Create a brand new object with a new mesh reference. All your components on the object will be lost!
public void MPE_CreateNewReference()
// Restore current mesh to its initial state
public void MPE_RestoreMeshToOriginal()
// Convert skinned mesh renderer to a mesh renderer & mesh filter. This will create a new object, so none of the components will remain
public void MPE_ConvertFromSkinnedToFilter()

// Internal mesh-features

// Internal modifier - mesh smooth HC Filter
public void MPE_SmoothMesh(float intensity = 0.5f)
// Internal modifier - mesh subdivision
public void MPE_SubdivideMesh(int Level)
Public Fields and Properties
// Subscribe to this action field to get notified of the MeshProEditor initialization. This is recommended especially if you are adding the component at runtime via AddComponent. There is actually one-frame delay while initializing.
public Action onMeshProEditorInitialized

public bool meshCreateNewReferenceAfterCopy = true;
public bool meshUpdateEveryFrame = true;
public bool meshAnimationMode = false;
public bool meshSmoothAngleNormalsRecalc = false;
public float meshNormalsSmoothAngle = 90.0f;

public bool MeshAlreadyAwake { get; }
public bool MeshBornAsSkinnedMesh { get; }
public MeshFilter MeshCachedMeshFilter { get; }

public IReadOnlyList<Transform> GeneratedMeshPoints { get; }
public Transform GeneratedPointsRootContainer { get; }
public bool HasGeneratedVerticePoints { get; }

public bool HasCustomPointPatternReference { get; }
public bool HasCustomPointPatternColor { get; }
Examples
The following paragraphs contain MeshProEditor used in a practical example. Generate mesh-vertices as gameObjects through the MeshProEditor and modify these points at runtime.
using UnityEngine;
using MDPackage;

[RequireComponent(typeof(MeshFilter))]
public class SampleScript : MonoBehaviour
{
public bool hideGeneratedPoints = true;

private MD_MeshProEditor meshProEditor;

private void Start()
 {
  // Add MPE to the current meshFilter gameObject
  meshProEditor = gameObject.AddComponent<MD_MeshProEditor>();
  // Create/ generate points on the mesh vertices
  meshProEditor.MPE_CreatePointsEditor();
  // Set the points active state
  meshProEditor.MPE_ShowHideGeneratedPoints(!hideGeneratedPoints);
  // Enable Smooth-angle normals recalculation for smoother results
  meshProEditor.meshSmoothAngleNormalsRecalc = true;
  // We will animate/keep the vertices during the playtime
  meshProEditor.meshAnimationMode = true;
 }

private void Update()
 {
  // Check if the generated points exist
  if (meshProEditor.GeneratedMeshPoints == null || meshProEditor.GeneratedMeshPoints.Count == 0)
   return;
  // Now you can modify the generated points!
  // This is not recommended as it takes twice of the performance. This is just an example of the MeshProEditor APi.
  // Use the mesh vertices directly for advanced mesh manipulation!
  foreach(Transform t in meshProEditor.GeneratedMeshPoints)
   t.localPosition += ((Mathf.Sin(Time.time * 1.5f) * 0.5f) * Mathf.Abs(t.localPosition.y)) * Time.deltaTime * Vector3.up;
 }
}