Skip to main content
added 902 characters in body
Source Link
Kevin
  • 7k
  • 1
  • 12
  • 32

Using Gizmos, you can draw lines in different ways using the following commands:

  • Gizmos.DrawLine()
  • Gizmos.DrawLineList()
  • Gizmos.DrawWireCube()
  • Gizmos.DrawWireMesh()
  • Gizmos.DrawWireSphere()

It sounds like you want to be able to draw a complex wireframe without having to draw individual lines or using any of the helpful functions that Unity has provided for drawing complex wireframes without drawing individual lines. You can't do that. You could theoretically write your own function to simplify the process of drawing some shape made up of individual lines, but it would still have to draw the individual lines, and your custom function would probably end up doing the same thing as one of the built-in functions.

As for drawing a triangle specifically, you've already figured out what I would say is the best way to draw a triangle. If you wanted to write your own helpera more general function to do onefor drawing a series of these things that's already built in to the Editorpoints, it would look something like this:

public function DrawPath(List<Vector3> points, bool loop) {
    // Connect each point to the previous point
    for (int i = 1; i < points.Count; i++) {
        Gizmos.DrawLine(points[i], points[i - 1]);
    }
    if (loop) {
        // Connect last to first
        Gizmos.DrawLine(points[points.Count - 1], points[0]);
    }
}

If you're we'd need to know what specifically you wanted to drawonly. The algorithm would vary depending on whether you're drawing a mesh or a path or something else. You are refusing to tell us what you want trying to draw (it sounds likea triangle, that function is overkill because it has functionality you don't actually have anything in mind), so there's nothing we can offerneed. If you're trying to helpdraw other kinds of paths, it could be useful, except that it's really completely unnecessary since you could just as easily use one of the built-in functions that does the same thing.


Some advice: don't invent unnecessary problems "for the sake of learning". Time that you spend trying to solve arbitrary hypothetical problems like this is time that you could have spent learning something useful or actually developing your game.

Using Gizmos, you can draw lines in different ways using the following commands:

  • Gizmos.DrawLine()
  • Gizmos.DrawLineList()
  • Gizmos.DrawWireCube()
  • Gizmos.DrawWireMesh()
  • Gizmos.DrawWireSphere()

It sounds like you want to be able to draw a complex wireframe without having to draw individual lines or using any of the helpful functions that Unity has provided for drawing complex wireframes without drawing individual lines. You can't do that. You could theoretically write your own function to simplify the process of drawing some shape made up of individual lines, but it would still have to draw the individual lines, and your custom function would probably end up doing the same thing as one of the built-in functions.

If you wanted to write your own helper function to do one of these things that's already built in to the Editor, we'd need to know what specifically you wanted to draw. The algorithm would vary depending on whether you're drawing a mesh or a path or something else. You are refusing to tell us what you want to draw (it sounds like you don't actually have anything in mind), so there's nothing we can offer to help.


Some advice: don't invent unnecessary problems "for the sake of learning". Time that you spend trying to solve arbitrary hypothetical problems like this is time that you could have spent learning something useful or actually developing your game.

Using Gizmos, you can draw lines in different ways using the following commands:

  • Gizmos.DrawLine()
  • Gizmos.DrawLineList()
  • Gizmos.DrawWireCube()
  • Gizmos.DrawWireMesh()
  • Gizmos.DrawWireSphere()

It sounds like you want to be able to draw a complex wireframe without having to draw individual lines or using any of the helpful functions that Unity has provided for drawing complex wireframes without drawing individual lines. You can't do that. You could theoretically write your own function to simplify the process of drawing some shape made up of individual lines, but it would still have to draw the individual lines, and your custom function would probably end up doing the same thing as one of the built-in functions.

As for drawing a triangle specifically, you've already figured out what I would say is the best way to draw a triangle. If you wanted a more general function for drawing a series of points, it would look something like this:

public function DrawPath(List<Vector3> points, bool loop) {
    // Connect each point to the previous point
    for (int i = 1; i < points.Count; i++) {
        Gizmos.DrawLine(points[i], points[i - 1]);
    }
    if (loop) {
        // Connect last to first
        Gizmos.DrawLine(points[points.Count - 1], points[0]);
    }
}

If you're only trying to draw a triangle, that function is overkill because it has functionality you don't need. If you're trying to draw other kinds of paths, it could be useful, except that it's really completely unnecessary since you could just as easily use one of the built-in functions that does the same thing.


Some advice: don't invent unnecessary problems "for the sake of learning". Time that you spend trying to solve arbitrary hypothetical problems like this is time that you could have spent learning something useful or actually developing your game.

Source Link
Kevin
  • 7k
  • 1
  • 12
  • 32

Using Gizmos, you can draw lines in different ways using the following commands:

  • Gizmos.DrawLine()
  • Gizmos.DrawLineList()
  • Gizmos.DrawWireCube()
  • Gizmos.DrawWireMesh()
  • Gizmos.DrawWireSphere()

It sounds like you want to be able to draw a complex wireframe without having to draw individual lines or using any of the helpful functions that Unity has provided for drawing complex wireframes without drawing individual lines. You can't do that. You could theoretically write your own function to simplify the process of drawing some shape made up of individual lines, but it would still have to draw the individual lines, and your custom function would probably end up doing the same thing as one of the built-in functions.

If you wanted to write your own helper function to do one of these things that's already built in to the Editor, we'd need to know what specifically you wanted to draw. The algorithm would vary depending on whether you're drawing a mesh or a path or something else. You are refusing to tell us what you want to draw (it sounds like you don't actually have anything in mind), so there's nothing we can offer to help.


Some advice: don't invent unnecessary problems "for the sake of learning". Time that you spend trying to solve arbitrary hypothetical problems like this is time that you could have spent learning something useful or actually developing your game.