Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question How do I extrude a 2d plane to a 3d mesh?

Discussion in 'Scripting' started by Philip2809, Mar 30, 2023.

  1. Philip2809


    Jan 14, 2022
    Hey! I have a plane mesh and I am trying to figure out how to extrude it. Can someone please help me? this is my mesh and I have tried to use MeshExtrusion.cs but I am getting an error.

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. MeshExtrusion.ExtrudeMesh (UnityEngine.Mesh srcMesh, UnityEngine.Mesh extrudedMesh, UnityEngine.Matrix4x4[] extrusion, MeshExtrusion+Edge[]


    MeshExtrusion.cs is from github and discussed here:
    But I cant really wrap my head around how to use it, can someone please help me?

    Any help is appreciated!
    Thanks Philip!
  2. orionsyndrome


    May 4, 2014
    How we're supposed to know what produced that error? If I'm preparing Crème Brûlée and then show you an Instagram picture of some burnt toast, can you tell what I did wrong?
  3. Kurt-Dekker


    Mar 16, 2013
    Here are some notes on IndexOutOfRangeException and ArgumentOutOfRangeException:

    Steps to success:
    - find which collection it is and what line of code accesses it <--- critical first step!)
    - find out why it has fewer items than you expect
    - fix whatever logic is making the indexing value exceed the collection size
    - remember that a collection with ZERO elements cannot be indexed at all: it is empty
    - remember you might have more than one instance of this script in your scene/prefab
    - remember the collection may be used in more than one location in the code
    - remember that indices start at ZERO (0) and go to the count / length minus 1.

    This means with three (3) elements, they are numbered 0, 1, and 2 only.

    If you would like an example of extrusion, I have one in my MakeGeo project... look for

    MakeGeo is presently hosted at these locations: