VR Line Creator (that can be hacked for other uses, but good for demonstration purposes)

Avatar
  • updated
  • Declined

Would it be possible to create a script similar to this to add and a demo scene?
(Havent tried it yet, but assume it wont work because it didnt before, will try again soon) - I also think all points would need to be worldspace)). 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Shapes;

public class VRShape_Polyline : MonoBehaviour
{
public List Lines;
public GameObject VRLineHolder; // S E T U P EARLY
public GameObject myObject;

Transform StoredTransform; // VR- Specified controller. // or ext ref
Vector3 ThisPosition;
Vector3 LastPosition;
float theDistance;

bool Initiated = false;
bool Active = false;
bool skipAll = true;

bool VRControl1; // will replace later
bool VRControl2; // will replace later
bool VRControl3; // will replace later

public void Update()
{
if (Active == true)
{
if (VRControl1 == true && Initiated == false)
{
myObject = new GameObject("Line");
myObject.AddComponent();
myObject.transform.SetParent(VRLineHolder.transform);
Lines.Add(myObject);

Initiated = true;
skipAll = true;
}
if (skipAll == false && VRControl2 == true && Initiated == true)
{
LastPosition = ThisPosition;
ThisPosition = StoredTransform.position;
if (theDistance > Vector3.Distance(ThisPosition, LastPosition))
{
myObject.GetComponent().AddPoint(ThisPosition); // In Update // And In World Space
}
skipAll = true;
}

if (skipAll == false && VRControl3 == true && Initiated == true)
{
Initiated = false;
}
skipAll = false;
}
}

public void Create_VRLine()
{
Active = true;
}
}

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
-1
Freya Holmér creator
  • Answer
  • Declined

I won't be adding this as an example scene, as VR is pretty specific and endemic to certain platforms. this could be relatively easily made using the polylines though, since it has support for adding points!

Avatar
-1
Freya Holmér creator
  • Answer
  • Declined

I won't be adding this as an example scene, as VR is pretty specific and endemic to certain platforms. this could be relatively easily made using the polylines though, since it has support for adding points!