/// <summary> /// 绘制选择对象的控制 /// </summary> /// <param name="i">点对象索引值</param> private void DrawSelectionHandle(TileTarget data, int i) { if (Event.current.button != 0) { return; } MyVector3Int myV3Int = data.TileDataLst[i].MyV3Int; Handles.color = data.Color; var v3Int = myV3Int.ToVector3Int(); var pos = _fromMap.GetPos(v3Int); var pointSize = GetPointSize(myV3Int, data); if (Handles.Button(new Vector3(pos.x, -1f, pos.z), Quaternion.identity, pointSize, pointSize, Handles.SphereHandleCap) && fromMapWindow.DetailReorderableList.index != i) { fromMapWindow.DetailReorderableList.index = i; InternalEditorUtility.RepaintAllViews(); } DrawPointAxisLine(myV3Int, Vector3.right, Color.red, data); DrawPointAxisLine(myV3Int, Vector3.up, Color.green, data); DrawPointAxisLine(myV3Int, Vector3.forward, Color.blue, data); // TODO 报错 //Handles.BeginGUI(); //GUILayout.BeginArea(LabelRect(pos)); //guiStyle.normal.textColor = data.Color; //guiStyle.fontSize = data.IndexFontSize; //GUILayout.Label(new GUIContent(i.ToString(), string.Format("Point {0}\nPosition: {1}", i, myV3Int)), guiStyle); //GUILayout.EndArea(); //Handles.EndGUI(); }
/// <summary> /// 绘制点对象自身的轴 /// </summary> /// <param name="i">索引</param> /// <param name="dir">方向</param> /// <param name="color">颜色</param> private void DrawPointAxisLine(MyVector3Int myV3Int, Vector3 dir, Color color, TileTarget data) { var v3Int = myV3Int.ToVector3Int(); var pos = _fromMap.GetPos(v3Int); Handles.color = color; if (_fromMap.Use_ScreenSize) { Handles.DrawLine(pos, pos + dir * AxisLength * GetPointSize(myV3Int, data)); } else { Handles.DrawLine(pos, pos + dir * AxisLength); } }
/// <summary> /// 根据是否使用屏幕大小,获取点大小 /// </summary> /// <param name="myV3Int">点的位置</param> /// <returns>点的实际大小</returns> private float GetPointSize(MyVector3Int myV3Int, TileTarget data) { float pointSize; var v3Int = myV3Int.ToVector3Int(); var pos = _fromMap.GetPos(v3Int); if (_fromMap.Use_ScreenSize) { pointSize = HandleUtility.GetHandleSize(pos) * data.PointSize; } else { pointSize = data.PointSize; } return(pointSize); }