It is a direct swap in terms of bolt patterns and drive line lengths, however it is not a direct swap in terms of shifter location and shift rod style.
The G-Series is designed for a forward shift transfercase where the transfercase shift handle itself shifts remotly off the top of the G transmission. Whereas the W-Series is designed for a top shift transfercase where the transfercase shift handle shifts directly out the top of the transfercase itself.
Now you can do this even without having to change anything. Just keep your top shift transfercase and bolt it behind your G-Series (forward shift style) transmission keeping in mind that you will have a hole in the top of the transmission where a forward shifting style transfercase's shift lever would normally plug into. Simply cover this hole with anything possible or make some type of block off for it. This way you can keep your stock Transfercase and Transfercase shift handle location and still be able to use a G-Series transmission. Just remember that you need to really seal that empty hole atop the G-Series very well to prevent oil from shooting out and water/mud from getting in.
Also, you might want to know that a W series is a bit stronger than a G series. So you would be down-grading your transmission..