SHARE
TWEET

Untitled

a guest Aug 14th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void OnSceneGUI()
  2.     {
  3.         path = target as AIPatrolPath;
  4.         handleTransform = path.transform;
  5.  
  6.         DrawPath(path.GetPath);
  7.     }
  8.  
  9.     private void DrawPath(List<PathNode> nodes)
  10.     {
  11.         // Do not draw empty path
  12.         if (nodes.Count == 0) return;
  13.  
  14.         // Setup drawing properties
  15.         Handles.color = Color.white;
  16.  
  17.         PathNode lastNode = nodes[0];
  18.         nodes.ForEach(node =>
  19.         {
  20.             Vector3 p0 = handleTransform.TransformPoint(lastNode.position);
  21.             Vector3 p1 = handleTransform.TransformPoint(node.position);
  22.  
  23.             Debug.Log("Before handles " + node.position);
  24.  
  25.             Handles.DrawAAPolyLine(10f, p0, p1);
  26.  
  27.             // Handle node move
  28.             EditorGUI.BeginChangeCheck();
  29.             p1 = Handles.DoPositionHandle(p1, Quaternion.identity);
  30.  
  31.             if (EditorGUI.EndChangeCheck())
  32.             {
  33.                 Undo.RecordObject(path, "Move Node");
  34.                 EditorUtility.SetDirty(path);
  35.                 node.position = handleTransform.InverseTransformPoint(p1);
  36.                 Debug.Log("After handles " + node.position);
  37.             }
  38.  
  39.             lastNode = node;
  40.         });
  41.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top