示例#1
0
文件: Way.cs 项目: Cdrix/SM
    /// <summary>
    /// Defined a 3d  rectangle with current selection: onScreenPoly. Defines firstCorner and secondCorner too,
    /// _dir too
    /// </summary>
    /// <returns></returns>
    public void CreateWay()
    {
        //print("1st way p." + _firstWayPoint);
        //print("2st  way p corn." + _secondWayPoint);

        if (firstCorner == new Vector2())
        {
            firstCorner    = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y);
            _firstWayPoint = ClosestSubMeshVert;
        }
        else if (firstCorner != new Vector2())
        {
            secondCorner    = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y);
            _secondWayPoint = UPoly.RayCastTerrain(secondCorner).point;
            _secondWayPoint = m.Vertex.FindClosestVertex(_secondWayPoint, m.CurrentHoverVertices.ToArray());
            //direction was dragged on terrain
            _dir         = UDir.ReturnDragDir(_firstWayPoint, _secondWayPoint);
            onScreenPoly = UPoly.RetTerrainPoly(_firstWayPoint, _secondWayPoint, _dir);
        }
    }