MDG_TunnelCreator
Namespace: MDPackage.Geometry
Complete tunnel-creator with node-based editor in Unity Engine in editor & at runtime. Apply this script to any gameObject with meshFilter.
Read more here (Online documentation slide)
Public Methods
public void Tunnel_AddNode(Vector3 positionInWorldSpace, bool groupTogetherOnAdd = true)
public void Tunnel_RemoveLastNode()
public void Tunnel_RemoveAll()
public void Tunnel_RefreshNodes()
public void Tunnel_ApplyResolution()
public void Tunnel_GroupAllNodesTogether()
public void Tunnel_UngroupAllNodes(Transform detachToOtherParent = null)
public void Tunnel_UpdateUVsWithUVMode(MDG_TunnelNodeUVData.UVType uvMode)
public static void CreateGeometry()
Public Fields and Properties
[Range(4, 64)] public int tunnelResolution = 16;
public int tunnelResolutionBackup = 0;
public float tunnelRadius = 1.0f;
public float tunnelNodeSize = 0.2f;
public bool tunnelHemi = false;
public bool tunnelHemiVertical = false;
public bool tunnelReverseFaces = false;
public bool tunnelApplyNodeLocalScale = false;
public bool tunnelUpdateEveryFrame = true;
public bool tunnelUseSmartRotation = true;
public bool tunnelUseCustomUVData = false;
public MDG_TunnelNodeUVData.UVType tunnelUVType = MDG_TunnelNodeUVData.UVType.uvZX;
public bool tunnelEnableGizmos = true;
public List<Transform> TunnelCurrentNodes { get; }
Examples
The following paragraphs contain Tunnel Creator used in a practical example. Create a tunnel creator at runtime and add custom tunnel nodes.
using UnityEngine;
using MDPackage.Geometry;
public class SampleScript : MonoBehaviour
{
private MDG_TunnelCreator tunnelCreator;
private Vector3 currentNodePos;
private void Start()
{
tunnelCreator = gameObject.AddComponent<MDG_TunnelCreator>();
tunnelCreator.transform.position = Vector3.zero;
tunnelCreator.Tunnel_ApplyResolution();
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.W))
AddNode(Vector3.forward);
if (Input.GetKeyDown(KeyCode.D))
AddNode(Vector3.right);
if (Input.GetKeyDown(KeyCode.S))
AddNode(Vector3.back);
if (Input.GetKeyDown(KeyCode.A))
AddNode(Vector3.left);
void AddNode(Vector3 pos)
{
currentNodePos += pos;
tunnelCreator.Tunnel_AddNode(currentNodePos);
}
}
}