Skip to content

A component to procedurally generate pipe-like meshes in Unity

License

Notifications You must be signed in to change notification settings

xiongxingplus/unity-plumber

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnityPlumber

(a component to procedurally generate pipe-like meshes in Unity)

Screenshot

Important Information

This repository contains an example project. These files are distributed here only as part of the example scene to demonstrate the capabilities of UnityPlumber. If you are not interested in that and only want the component itself to test it out in your own project, feel free to proceed to copy only the PipeMeshGenerator.cs file and the Math3D.cs file to the Scripts directory and nothing else.

Installation

Getting UnityPlumber running is pretty easy. You simply need to get a copy of the PipeMeshGenerator.cs and Math3D.cs files in the Scripts directory and copy them to your project. Once there, simply add the PipeMeshGenerator component to an empty GameObject, set the options and you are good to go!

What do the options mean?

Almost all of the settings are pretty much self explanatory, but here are the details:

  • points: A list of Vector3 containing all points the pipe should connect.
  • pipeRadius: The radius for the cross section of the pipe.
  • elbowRadius: The radius for the elbows that are automatically generated between each segment.
  • pipeSegments: The number of faces in each pipe segment. Higher numbers mean smoother (rounder) looking pipes. Recommended values: 8 to 16.
  • elbowSegments: The number of cross-sections to generate in each elbow where the pipe bends. Recommended values: 6 to 10.
  • pipeMaterial: An Unity Material that will be applied to the MeshRenderer component in order to render the mesh.
  • flatShading: Enabling this option will disable smoothing and make a flat-shaded low-poly style pipe. Enabling this will increase vertex count greatly!
  • avoidStrangling: Enabling this option will cause the algorithm to try to avoid twists in elbows. This usually fixes some problems and causes new ones, so experiment to see what works best in your particular case.
  • generateEndCaps: Enabling this option will automatically generate circular end caps on each end of the pipe.
  • generateOnStart: Enabling this option will make the component generate the mesh automatically when started. Disable it if you need to set the points manually in runtime first and generate the mesh later.

Public Methods

RenderPipe()

Generates the pipe mesh with the specified options. Automatically adds MeshFilter and MeshRenderer components to the object if they are not present.

Math 3D Helper Class

This project makes use of the Math3D.cs file, which has been obtained from https://github.com/kristofe/UnityVolumeOculus, another project distributed under the MIT License.

About

A component to procedurally generate pipe-like meshes in Unity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%