// If enabled, the Update method will check for generic input automatically publicbool UseControls { get; set; }
publicCamera MainCameraInstance { get; set; }
// Y_Only - slime will be affected only on Y axis, TowardsObjectsPivot - towards objects pivot point, CrossProduct - cross product, NormalsDirection - towards vertices normals publicDragAxisType CurrentDragAxisType { get; set; }
// Modify mesh on the specific world point with current mesh slime settings publicvoid MeshSlime_ModifyMesh(Vector3 worldPoint)
Examples
The following paragraphs contain Mesh Slime modifier used in a practical example. Hence the custom input handling.
using UnityEngine; using MDPackage.Modifiers;
[RequireComponent(typeof(MeshFilter))] publicclassSampleScript : MonoBehaviour { // Cache main camera in the inspector! [SerializeField] privateCamera mainCam;
privateMDM_MeshSlime slime;
privatevoid Start() { // Add/Create a Mesh Slime modifier to this object right after start slime = gameObject.AddComponent<MDM_MeshSlime>(); // Enable useNormalSmoothingAngle for 'smoother' looking normals slime.MbUseNormalSmoothingAngle = true;
// Add mesh collider for raycast detection gameObject.AddComponent<MDPackage.MD_MeshColliderRefresher>(); }
privatevoid Update() { // Main camera must be initialized if (!mainCam || !slime) return;
// Additional extensions for mesh // If Space is pressed, subdivide mesh if possible if (Input.GetKeyDown(KeyCode.Space)) slime.MDModifier_SubdivideMesh(); // If S is pressed, smooth mesh if (Input.GetKeyDown(KeyCode.S)) slime.MDModifier_SmoothMesh(); // If R is pressed, restore mesh if (Input.GetKeyDown(KeyCode.R)) slime.MDModifier_RestoreMesh();
// Mesh Slime modifier has already a built-in raycast detection, all is left is the input. Pass the input via Input-Hookups: