Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Line renderer for HoloLens

Discussion in 'AR/VR (XR) Discussion' started by hdin898, Jan 16, 2018.

  1. hdin898

    hdin898

    Joined:
    Jan 12, 2018
    Posts:
    6
    Hi

    I am trying to just render a basic line between 3 points and show it in HoloLens. Everything looks fine in the Unity Play but when I use it in HoloLens nothing but a pink square plane shows which kind of rotates as I change the position of my head. I have been googling and trying to fix this for a couple of days and I have no idea why this is happening please help. Code is below.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine.UI;
    4. using UnityEngine;
    5.  
    6. public class axisScript : MonoBehaviour
    7. {
    8.     public Color c2 = Color.white;
    9.     public Text ZeroText;
    10.     public const float xOffset = 0f;
    11.     public const float yOffset = 0f;
    12.     // Use this for initialization
    13.     void Start()
    14.     {
    15.         LineRenderer axisRenderer = gameObject.AddComponent<LineRenderer>();
    16.         axisRenderer.material = new Material(Shader.Find("Unlit/Texture"));
    17.         axisRenderer.startWidth = 0.02f;
    18.         axisRenderer.endWidth = 0.02f;
    19.         axisRenderer.positionCount = 3;
    20.  
    21.         axisRenderer.startColor = c2;
    22.         axisRenderer.endColor = c2;
    23.         axisRenderer.material.color = c2;
    24.  
    25.         axisRenderer.SetPosition(0, new Vector3(0 + xOffset, 0.25f + yOffset, 4));
    26.         axisRenderer.SetPosition(1, new Vector3(0 + xOffset, 0 + yOffset, 4));
    27.         axisRenderer.SetPosition(2, new Vector3(0.50f + xOffset, 0 + yOffset, 4));
    28.  
    29.     }
    30.  
    31.     // Update is called once per frame
    32.     void Update()
    33.     {
    34.  
    35.     }
    36. }
    37.  
     
  2. xowns5979

    xowns5979

    Joined:
    Oct 13, 2020
    Posts:
    2
    Same problem faced here, using Hololens 2