Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CachedLineRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CachedLineRenderer : LineRendererBase
/// </summary>


void Awake()
void Start()
{
// Collect.
LineRendererCamera.AddCachedRenderer(this);
Expand Down
2 changes: 1 addition & 1 deletion DirectLineRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DirectLineRenderer : LineRendererBase

#region Events

void Awake()
void Start()
{
// Collect.
LineRendererCamera.AddDirectRenderer(this);
Expand Down
5 changes: 1 addition & 4 deletions Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ namespace EPPZ.Lines
[Serializable]
public class Line
{


public Vector3 from;
public Vector3 to;
public Color color;
public float width = 1;
}
}


2 changes: 1 addition & 1 deletion LineRendererBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ protected void DrawLineWithTransform(Vector2 from, Vector2 to, Color color, Tran


}
}
}
29 changes: 20 additions & 9 deletions LineRendererCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using UnityEngine;
using System.Collections;
using System.Collections.Generic;


Expand Down Expand Up @@ -55,7 +54,12 @@ public static void AddCachedRenderer(CachedLineRenderer renderer)

void Awake()
{
shared = this;
if (shared != null && shared != this)
{
Destroy(this);
return;
}
shared = this;
_camera = GetComponent<Camera>();
}

Expand Down Expand Up @@ -123,15 +127,22 @@ void DrawLines()
void DrawCall()
{
// Assign vertex color material.
material.SetPass(0); // Single draw call (set pass call)

// Send vertices in GL_LINES Immediate Mode.
GL.Begin(GL.LINES);
foreach (EPPZ.Lines.Line eachLine in lineBatch)
// Single draw call (set pass call)
material.SetPass(0);
// Draw with width
GL.Begin(GL.QUADS);
foreach (Line eachLine in lineBatch)
{
GL.Color(eachLine.color);
GL.Vertex(eachLine.from);
GL.Vertex(eachLine.to);

Vector3 v = eachLine.to - eachLine.from;
Vector3 u = new Vector3(-v.y, v.x, v.z).normalized * .1f * eachLine.width;
u.z = v.z;

GL.Vertex(eachLine.from - u);
GL.Vertex(eachLine.from + u);
GL.Vertex(eachLine.to + u);
GL.Vertex(eachLine.to - u);
}
GL.End();
}
Expand Down