예제 #1
0
        // ---------------------------------------------------------------------
        //
        // Debug draw
        //
        // ---------------------------------------------------------------------

#if UNITY_EDITOR
        static void DrawTop(IsoWorld iso_world, Vector3 pos, Vector3 size, Vector3 rotate)
        {
            if (iso_world)
            {
                var points = new Vector3[]{
                    iso_world.IsoToScreen(pos),
                    iso_world.IsoToScreen(pos + IsoUtils.Vec3FromX(size.x)),
                    iso_world.IsoToScreen(pos + IsoUtils.Vec3FromXY(size.x, size.y)),
                    iso_world.IsoToScreen(pos + IsoUtils.Vec3FromY(size.y)),
                    iso_world.IsoToScreen(pos)
                };


                if(rotate.y > 0)
                {
                    // direita
                    Handles.DrawLine(points[0], points[1] - rotate);
                    // frente
                    Handles.DrawLine(points[1] - rotate, points[2] - rotate);
                    // esquerda 
                    Handles.DrawLine(points[2] - rotate, points[3]);
                    // traz
                    Handles.DrawLine(points[3], points[0]);
                }else if(rotate.x > 0)
                {

                    // direita
                    Handles.DrawLine(points[0] - new Vector3(0, rotate.x, 0), points[1] - new Vector3(0, rotate.x, 0));
                    // frente
                    Handles.DrawLine(points[1] - new Vector3(0, rotate.x, 0) , points[2] );
                    // esquerda 
                    Handles.DrawLine(points[2] , points[3]);
                    // traz
                    Handles.DrawLine(points[3] , points[0] - new Vector3(0, rotate.x, 0));

                }
                else
                {

                    //normal 

                    // direita
                    Handles.DrawLine(points[0], points[1]);
                    // frente
                    Handles.DrawLine(points[1], points[2]);
                    // esquerda 
                    Handles.DrawLine(points[2], points[3]);
                    // traz
                    Handles.DrawLine(points[3], points[0]);


                } 

                
                
                


            }
        }
예제 #2
0
 public static void DrawCube(IsoWorld iso_world, Vector3 center, Vector3 size, Color color, Vector3 rotate)
 {
     if (iso_world)
     {
         Handles.color = color;
         var pos = center - size * 0.5f;
         DrawTop(iso_world, pos, size, rotate);
         DrawTop(iso_world, pos + IsoUtils.Vec3FromZ(size.z), size, rotate);
         DrawVert(iso_world, pos, size);
         DrawVert(iso_world, pos + IsoUtils.Vec3FromX(size.x), size);
         DrawVert(iso_world, pos + IsoUtils.Vec3FromY(size.y), size);
         DrawVert(iso_world, pos + IsoUtils.Vec3FromXY(size.x, size.y), size);
     }
 }
        // ---------------------------------------------------------------------
        //
        // Debug draw
        //
        // ---------------------------------------------------------------------

        #if UNITY_EDITOR
        static void DrawIsoCubeTop(IsoWorld iso_world, Vector3 pos, Vector3 size)
        {
            if (iso_world)
            {
                var point0 = iso_world.IsoToScreen(pos);
                var point1 = iso_world.IsoToScreen(pos + IsoUtils.Vec3FromX(size.x));
                var point2 = iso_world.IsoToScreen(pos + IsoUtils.Vec3FromXY(size.x, size.y));
                var point3 = iso_world.IsoToScreen(pos + IsoUtils.Vec3FromY(size.y));
                Handles.DrawLine(point0, point1);
                Handles.DrawLine(point1, point2);
                Handles.DrawLine(point2, point3);
                Handles.DrawLine(point3, point0);
            }
        }