Exemple #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]);


                } 

                
                
                


            }
        }
Exemple #2
0
		void ZMoveSlider() {
			var iso_world = GameObject.FindObjectOfType<IsoWorld>();
			if ( iso_world ) {
				Handles.color = Handles.zAxisColor;
				var delta = Handles.Slider(_viewCenter, IsoUtils.vec3OneY) - _viewCenter;
				if ( Mathf.Abs(delta.y) > Mathf.Epsilon ) {
					float tmp_y = ZMoveIsoObjects((_viewCenter.y - _center.y + delta.y) / iso_world.tileHeight);
					_viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.tileHeight);
				}
			}
		}
Exemple #3
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);
            }
        }
Exemple #5
0
 void ZMoveSliderTool()
 {
     foreach (var iso_world in _viewCenters.Keys.ToList())
     {
         EditorGUI.BeginChangeCheck();
         var old_center = _viewCenters[iso_world];
         var new_center = IsoEditorUtils.GizmoSlider(
             Handles.zAxisColor,
             old_center,
             IsoUtils.vec3OneY);
         if (EditorGUI.EndChangeCheck())
         {
             var old_delta = new_center - old_center;
             var new_delta = IsoEditorUtils.ZMoveIsoObjects(
                 true,
                 iso_world,
                 _isoObjects,
                 _otherObjects,
                 old_delta.y / iso_world.tileHeight) * iso_world.tileHeight;
             _viewCenters[iso_world] = old_center + IsoUtils.Vec3FromY(new_delta);
         }
     }
 }