Ejemplo n.º 1
0
 private void OnDrawGizmos()
 {
     if (!EditorApplication.isPlaying)
     {
         startPos           = transform.position;
         startPoint.Anchore = startPos;
     }
     Gizmos.color = Color.white;
     Gizmos.DrawLine(startPoint.Anchore, startPoint.Anchore + startPoint.Handle2);
     Gizmos.DrawLine(startPoint.Anchore + endPoint.Anchore, startPoint.Anchore + endPoint.Anchore + endPoint.Handle1);
     GizmosExtensions2D.DrawBezierCurve2D(startPoint.Anchore, startPoint.Anchore + startPoint.Handle2, startPoint.Anchore + endPoint.Anchore + endPoint.Handle1, startPoint.Anchore + endPoint.Anchore);
     Gizmos.color = Color.red;
     GizmosExtensions2D.DrawWireRect2D(startPoint.Anchore + startPoint.Handle2, 1, 1);
     GizmosExtensions2D.DrawWireRect2D(startPoint.Anchore + endPoint.Anchore + endPoint.Handle1, 1, 1);
 }
Ejemplo n.º 2
0
    private void OnDrawGizmos()
    {
        /*
         * //処理中のイベントからマウスの位置取得
         * mousePosition = Event.current.mousePosition;
         *
         * //シーン上の座標に変換
         * mousePosition.y = SceneView.currentDrawingSceneView.camera.pixelHeight - mousePosition.y;
         * mousePosition = SceneView.currentDrawingSceneView.camera.ScreenToWorldPoint(mousePosition);
         *
         * //Debug.Log("座標 : " + mousePosition.x.ToString("F2") + ", " + mousePosition.y.ToString("F2"));
         *
         *
         * if (!EditorApplication.isPlaying)
         * {
         *  pivot = transform.position;
         * }
         * //GizmosExtensions2D.DrawArrow2D(startPos, startPos + new Vector3(speedX, speedY));
         * if (path.Count > 0)
         * {
         *  Vector3 point = new Vector3(0,0,float.MaxValue);
         *  Vector3 from = pivot + (Vector3)path[0].Anchore;
         *  Vector3 to;
         *  Gizmos.color = Color.white;
         *  for (int i = 1; i < path.Count; i++)
         *  {
         *      to = pivot + (Vector3)path[i].Anchore;
         *      //GizmosExtensions2D.DrawBezierCurve2D(from, from + (Vector3)path[i - 1].Handle2, to + (Vector3)path[i].Handle1, to);
         *      //GizmosExtensions2D.DrawBezierCurveArrow2D(from, from + (Vector3)path[i - 1].Handle2, to + (Vector3)path[i].Handle1, to);
         *      Vector3 tmpVec = GizmosExtensions2D.GetNearestPointBezierCurveArrow2D(from, from + (Vector3)path[i - 1].Handle2, to + (Vector3)path[i].Handle1, to, mousePosition);
         *      if(tmpVec.z<1 && tmpVec.z < point.z)
         *      {
         *          point = tmpVec;
         *      }
         *      from = to;
         *  }
         *  if (openEnded)
         *  {
         *      to = pivot + (Vector3)path[0].Anchore;
         *      //GizmosExtensions2D.DrawBezierCurveArrow2D(from, from + (Vector3)path[path.Count - 1].Handle2, to + (Vector3)path[0].Handle1, to);
         *      Vector3 tmpVec = GizmosExtensions2D.GetNearestPointBezierCurveArrow2D(from, from + (Vector3)path[path.Count - 1].Handle2, to + (Vector3)path[0].Handle1, to, mousePosition);
         *      if (tmpVec.z < 1 && tmpVec.z < point.z)
         *      {
         *          point = tmpVec;
         *      }
         *  }
         *  if (point.z < 1)
         *  {
         *      point.z = 0;
         *      GizmosExtensions2D.DrawWireCircle2D(point, 0.1f);
         *      if (Event.current == null || Event.current.type != EventType.MouseUp)
         *      {
         *          return;
         *      }
         *      //今は無理,力が足りない
         *      //path.Add(new ControlPoint(point));
         *  }
         * }
         */

        Vector3 point = new Vector3(0, 0, float.MaxValue);
        Vector3 from  = pivot + (Vector3)path[0].Anchore;
        Vector3 to;

        Gizmos.color = Color.white;
        for (int i = 1; i < path.Count; i++)
        {
            to = pivot + (Vector3)path[i].Anchore;
            GizmosExtensions2D.DrawBezierCurve2D(from, from + (Vector3)path[i - 1].Handle2, to + (Vector3)path[i].Handle1, to);
            GizmosExtensions2D.DrawBezierCurveArrow2D(from, from + (Vector3)path[i - 1].Handle2, to + (Vector3)path[i].Handle1, to);
            Vector3 tmpVec = GizmosExtensions2D.GetNearestPointBezierCurveArrow2D(from, from + (Vector3)path[i - 1].Handle2, to + (Vector3)path[i].Handle1, to, mousePosition);
            from = to;
        }
        if (openEnded)
        {
            to = pivot + (Vector3)path[0].Anchore;
            GizmosExtensions2D.DrawBezierCurveArrow2D(from, from + (Vector3)path[path.Count - 1].Handle2, to + (Vector3)path[0].Handle1, to);
        }
    }