MD Package Technical & APi Documentation
MD_ModifierBase :: MD_MeshBase
Namespace: MDPackage.Modifiers
Base modifier class for all the modifier instances. Implement this base class to any script that should behave like a 'mesh-modifier'.
Please read the APi below carefully as the setup for classes that inherit from this base class is slightly different.
Properties
public bool MbIsInitialized { get; }

// Does the current mesh-modifier support multithreading feature?
public bool MbMultithreadedModifier { get; }
public Thread ThreadInstance { get; }
public ManualResetEvent ThreadEvent { get; protected set; }

// Does the current modifier support base-mesh features such as 'Bake, Subdivide, Smooth' etc?
public bool MbUseModifierMeshFeatures = true;

// Not all mesh data will be initialized upon the modifier's creation - some modifiers don't need a backup or initial mesh data. See the 'MbMeshData' struct for more
public MbMeshData MbInitialMeshData { get; }
public MbMeshData MbBackupMeshData { get; }
public MbMeshData MbWorkingMeshData { get; }

// Called once the modifier has been successfully initialized. There is actually one-frame delay before the modifier is fully initialized
public Action OnModifierInitialized;

// Subscribe to delegate action when mesh is restored
public event Action OnMeshRestored;
// Subscribe to delegate action when mesh is baked
public event Action OnMeshBaked;
// Subscribe to delegate action when mesh is subdivided
public event Action OnMeshSubdivided;
// Subscribe to delegate action when mesh is smoothed
public event Action OnMeshSmoothed;
// Subscribe to delegate action when new mesh reference is created
public event Action OnNewMeshReferenceCreated;
Public Methods
// Essential methods for scripts that inherit from this class

// Create a new modifier of a specific type - you can also create a modifier simply calling the gameObject.AddComponent<Modifier>(). This static method allows you to define a mesh reference type
public static T CreateModifier<T>(GameObject entry, MeshReferenceType meshReferenceType)

// Override current working mesh data directly
protected void MDModifier_InitializeWorkingMeshData(MbMeshData workingMeshData)

// Clear individual mesh data units (initial data, backup data, working data)
public void MDModifier_ClearInitialMeshData()
public void MDModifier_ClearBackupMeshData()
public void MDModifier_ClearWorkingMeshData()

// Inheritation

// Base modifier initialization - is required to invoke for every class that inherits from the ModifierBase
protected virtual void MDModifier_InitializeBase(MeshReferenceType meshReferenceType = MeshReferenceType.GetFromPreferences, bool forceInitialization = false, bool affectUpdateEveryFrameField = true)
// Base mesh data initialization & caching - this will initialize essential mesh data (vertices, triangles, uvs etc)
protected virtual void MDModifier_InitializeMeshData(bool initialMeshData = true, bool backupMeshData = true, bool workingMeshData = true)
// Modifier implementation for main processing - use this method for processing the specific modifier
public abstract void MDModifier_ProcessModifier();

// Cross-modifier mesh features

// Restore current mesh from the initial mesh data
public void MDModifier_RestoreMesh()
// Increase mesh vertex count
public void MDModifier_SubdivideMesh(SubdivisionLevel level = SubdivisionLevel.x2)
// Make the mesh edges rounded
public void MDModifier_SmoothMesh(float intensity = 0.5f)
// Bake current mesh - initial mesh data will be overrided by the current mesh data
public void MDModifier_BakeMesh(bool forceInitialMeshData = false, bool forceBackupMeshData = false, bool forceWorkingMeshData = false)
// Create a brand new mesh reference
public void MDModifier_CreateNewMeshReference(string meshName = "")

// Threading features

// Start current thread and initialize the thread event. Enter custom thread name
public virtual void MDModifierThreading_StartThread(string threadName = "DefaultMDThread")
// Stop current thread and destroy all the events related to this thread
public virtual void MDModifierThreading_StopThread()
Example Implementation
All the modifiers that inherit from this base class must be initialized in a certain way.
You can either simply call gameObject.AddComponent() or call a static method MD_ModifierBase.CreateModifier(Advanced data...).
using UnityEngine;

using MDPackage.Modifiers;

public class SampleScript : MonoBehaviour
{
private MDM_Bend modifier;

private void Start()
 {
  // Create a Bend modifier for this object with mesh filter
  modifier = MD_ModifierBase.CreateModifier<MDM_Bend>(gameObject, MD_ModifierBase.MeshReferenceType.GetFromPreferences);
  // Or:
  // modifier = gameObject.AddComponent<MDM_Bend>();
 }
}