private void OnSceneGUI()
    {
        CurvedLineRenderer curvedLineRenderer = target as CurvedLineRenderer;
        Transform          handleTransform    = curvedLineRenderer.transform;
        Quaternion         handleRotation     = handleTransform.rotation;

        Handles.color = Color.white;

        for (int i = 0; i < linePoints.arraySize; i++)
        {
            //convert the local space points to global space
            Vector3 point = handleTransform.TransformPoint(linePoints.GetArrayElementAtIndex(i).vector3Value);

            EditorGUI.BeginChangeCheck();
            Vector3 handlePos = Handles.DoPositionHandle(point, handleRotation);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(curvedLineRenderer, "Move Array Point");
                EditorUtility.SetDirty(curvedLineRenderer);
                //convert the global space point from the handle to locaal space
                curvedLineRenderer.SetPointElement(i, handleTransform.InverseTransformPoint(handlePos));
                curvedLineRenderer.UpdateLineRenderer();
            }
        }
    }
 // Start is called before the first frame update
 void Awake()
 {
     lineRenderer    = GetComponent <CurvedLineRenderer>();
     defaultMaterial = Resources.Load("LineMaterials/CurvedLineMaterial") as Material;
     lineRenderer.SetLineWidth(defaultLineWidth);
     lineRenderer.SetLineMaterial(defaultMaterial);
 }
Exemple #3
0
    //update parent line when this point moved
    void OnDrawGizmosSelected()
    {
        CurvedLineRenderer curvedLine = this.transform.parent.GetComponent <CurvedLineRenderer>();

        if (curvedLine != null)
        {
            curvedLine.Update();
        }
    }
        void Awake()
        {
            CurvedLineRenderer clr = gameObject.AddComponent <CurvedLineRenderer>();

            clr.lineWidth       = 0.01f;
            clr.lineSegmentSize = 0.01f;
            clr.showGizmos      = false;

            LineRenderer lr = gameObject.GetComponent <LineRenderer>();

            lr.startWidth = 0.01f;
            lr.endWidth   = 0.01f;

            curvedLinePoints = new CurvedLinePoint[4];

            initialized = false;
        }
Exemple #5
0
 void Start()
 {
     cam = GetComponent <Camera>();
     lr  = GetComponent <LineRenderer>();
     clr = GetComponent <CurvedLineRenderer>();
 }