cancel
Showing results for 
Search instead for 
Did you mean: 

[QUEST] Freeze with use of lineRenderers

romain_quessada
Honored Guest
Hi everyone,

I'm beginner on Unity development and oculus quest development.
I would like to try to display different perimeters. Each perimeter is the same that the outer boundary and i apply it rotations.

So, i reuse an oculus script I have modified. And, to display perirmeter, i reuse lineRenderer.
Problem: with more than one lineRenderer, on the oculus Quest, the application freezes!

Do you know why? Is LineRendrer so resource intensive?

Thanks so much for help 

Here the code:
  1. public class GuardianBoundaryDisplayCustom : MonoBehaviour
  2. {
  3.     // Depending on the demo manager only for reorient notifications.
  4.     public GuardianBoundaryEnforcer m_enforcer;
  5.  
  6.     // So that we can easily render the rectangular play area and
  7.     // the more exact outer bounds.
  8.     public OVRBoundary.BoundaryType m_boundaryType;
  9.  
  10.     // Something to tell the user their guardian bounds aren't configured.
  11.     // This isn't a solution a shipping app would use-- it's just because
  12.     // the demo makes no sense without bounds.
  13.     public GameObject m_errorDisplay;
  14.  
  15.     void Start()
  16.     {
  17.         m_enforcer.TrackingChanged += RefreshDisplay;
  18.         RefreshDisplay();
  19.     }
  20.  
  21.     void RefreshDisplay()
  22.     {
  23.         bool configured = OVRManager.boundary.GetConfigured();
  24.         if (configured)
  25.         {
  26.             LineRenderer lr = GetComponent<LineRenderer>();
  27.             lr.positionCount = 0;
  28.  
  29.             // Note that these points are returned in (the newly reoriented) tracking space.
  30.             // So rendering them correctly aligned with your guardian bounds in VR is
  31.             // straightforward, and does not require additional transformations as long
  32.             // as this is parented to the TrackingSpace node.
  33.             Vector3[] boundaryPoints = OVRManager.boundary.GetGeometry(m_boundaryType);
  34.             lr.positionCount = boundaryPoints.Length + 1;
  35.             Vector3 v;
  36.             for (int i = 0; i < boundaryPoints.Length; ++i)
  37.             {
  38.                 v = boundaryPoints;
  39.                 v.y = 0.0f;
  40.                 lr.SetPosition(i, v);
  41.             }
  42.             v = boundaryPoints[0];
  43.             v.y = 0.0f;
  44.             lr.SetPosition(boundaryPoints.Length, v);
  45.             lr.startColor = Color.blue;
  46.             lr.endColor = Color.blue;
  47.  
  48.             LineRenderer lr2 = Instantiate(lr);
  49.             lr2.startColor = Color.red;
  50.             lr2.endColor = Color.red;
  51.             lr2.transform.Rotate(0.0f,180.0f,0.0f, Space.Self);
  52.  
  53.             LineRenderer lr3 = Instantiate(lr);
  54.             lr3.startColor = Color.yellow;
  55.             lr3.endColor = Color.yellow;
  56.             lr3.transform.Rotate(0.0f, 180.0f, 0.0f, Space.Self);
  57.             //TODO utiliser lr3.bounds.center pour décaler le périmètre
  58.         }
  59.         if (m_errorDisplay)
  60.         {
  61.             m_errorDisplay.SetActive(!configured);
  62.         }
  63.     }
  64.  
  65.     // Update is called once per frame
  66.     void Update()
  67.     {
  68.        
  69.     }
  70. }
0 REPLIES 0