Drawing a custom graphics line between two objects in 2D space.


My goal is to visually connect two objects with a line (draw a line between them).
The line is not meant for debugging purposes, it’s gonna be visible in the final product.
Therefore the line should be appear as a custom image in the end, i.e. Debug.DrawLine and the likes aren’t a solution.

As far as I know, perhaps it could be created basing on a provided .png with a fragment of it, just like GUI panels (sliced/tiled mode - the designer provides just a sample, off which the program creates the whole graphic).

c# highly preferred.

The line contains visual effects, it’s not a plain black strap. Therefore stretching the image and rotating it is not a solution.
Seed (sample) of the line. Black background added for increased visiblity.

To ease the situation, the line should be perfectly straight (any tips regarding curved variations would be approved aswell).

I’m thankful for any guidance towards the solution.

Can’t help you much, but I have a small C# script i found in the internet that can maybe give you a little help. I use it in the editor, but I’m looking to add a custom line too.

using UnityEngine;
using System.Collections;

public class Line : MonoBehaviour {

    public GameObject gameObject1;          // Reference to the first GameObject
    public GameObject gameObject2;          // Reference to the second GameObject

    private LineRenderer line;  						 // Line Renderer

	// Use this for initialization
	void Start () {
        // Add a Line Renderer to the GameObject
        line = this.gameObject.AddComponent<LineRenderer>();
        // Set the width of the Line Renderer
        line.SetWidth(0.05F, 0.05F);
        // Set the number of vertex fo the Line Renderer
	// Update is called once per frame
	void Update () {
        // Check if the GameObjects are not null
        if (gameObject1 != null && gameObject2 != null)
            // Update position of the two vertex of the Line Renderer
            line.SetPosition(0, gameObject1.transform.position);
            line.SetPosition(1, gameObject2.transform.position);