Procedural Mesh by aadebdeb - 1

Procedural

Procedural Mesh for Unity

Unity 2018.2.4f1MIT LicenseUpdated 234 days agoCreated on August 6th, 2018
Go to source

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
        );
    }
}
Show all projects by aadebdeb