Skip to content

xiongxingplus/ProceduralMesh

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProceduralMesh

Procedural Mesh for Unity

Plane

add Plane Mesh Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.Plane(
            new Vector2(4, 3), // size
            new Vector2Int(4, 3) // segments
        );
    }
}

Box

add Plane Box Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.Box(
            new Vector3(2f, 1.5f, 1f), // size
            new Vector3Int(4, 3, 2) // segments
        );
    }
}

Sphere

add Plane Sphere Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.Sphere(
            1.0f, // radius
            8, // thetaSegments
            12 // phiSegments
        );
    }
}

Icosphere

add Plane Icosphere Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.Icosphere(
            1, // radius
            1 // divisions
        );
    }
}

Torus

add Plane Torus Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.Torus(
            3f, // majorRadius
            1f, // minorRadius
            12, // thetaSegment
            8 // phiSegment
        );
    }
}

Cylinder

add Plane Cylinder Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.Cylinder(
            2.0f, // height
            1.0f, // radius
            5, // heightSegments
            8 // angleSegments
        );
    }
}

Inflated Plane

add Plane Inflated Plane Creator component or add a script below to empty GameObject

using UnityEngine;

[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class ProceduralMeshScript : MonoBehaviour
{
    private void Awake()
    {
        GetComponent<MeshFilter>().mesh = ProceduralMesh.InflatedPlane(
            new Vector3(3.0f, 2.0f, 1.0f), // size
            2.0f, // exp
            new Vector2Int(15, 10) // segments
        );
    }
}

About

Procedural Mesh for Unity

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%