Skip to content

Commit

Permalink
Target lines update their positions as objects move
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jul 30, 2018
1 parent 0120f6f commit e1c93ef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ public class EntityReferenceLine : MonoBehaviour
public int i;
public Entity sourceEntity;
public Entity targetEntity;
private LineRenderer line;

void Start()
{
if (sourceEntity == null || targetEntity == null)
return;
Color color = ColorI(i);
LineRenderer line = gameObject.AddComponent<LineRenderer>();
line = gameObject.AddComponent<LineRenderer>();
line.startWidth = line.endWidth = 0.1f;
line.material = _lineMaterial;
line.startColor = line.endColor = color;
UpdatePositions();
}

public void UpdatePositions()
{
line.SetPosition(0, sourceEntity.PositionInEditor());
line.SetPosition(1, targetEntity.PositionInEditor());
}
Expand Down Expand Up @@ -186,6 +192,11 @@ void Update()
}
return; // wait a frame to let the new/deleted objects update
}
else
{
foreach (Transform child in transform)
child.GetComponent<EntityReferenceLine>().UpdatePositions();
}

if (currentEntity != null)
EntityPreviewManager.UpdateEntityPosition(currentEntity);
Expand Down

0 comments on commit e1c93ef

Please sign in to comment.