Wednesday, March 18, 2015

Splashing Around

In the final 2 hours last night before I headed to slumberland, I managed to rework all the assets for Pitch, and build the Splash Scene over from scratch, and I think that it turned out pretty well. I am going to give a quick rundown/tutorial on things here both to add more non-rant content to my blog, and to have it as a reference for myself for future projects. :D

First things first, I auto-cropped all of my texture pieces individually with GIMP, leaving me with a folder of images which I then tossed into CodeAndWeb's TexturePacker Pro (Which is worth every penny for the Pro license!) and exported a Unity - Texture2D sprite sheet and packed PNG texture file.

Then I grabbed the TexturePackerImporter C# script from the Unity Asset Store. It's available for Free, and simplifies the process of getting your sprites into Unity greatly. Once I had the TexturePackerImporter.cs file in my Unity Project under the Editor folder, I was then able to drag in my sprite sheet and packed texture files (textures.tpsheet and textures.png) right into my Assets and the TexturePackerImporter script went to work and sliced up the packed textures into nice little sprites for me to use in Unity. Excellent. HUGE time-saver.

The last iteration of this project I had sliced my textures manually, and it took me a couple hours to do. This iteration took me all of 3 minutes, and that time was mostly for my LAN folder browsing! Thank you to CodeAndWeb GmbH!

Now, with the sprites in my Unity project,  I now started with a fresh scene, and added a UI Image to my project which adds in the Canvas and EventSystem objects which are necessary to drive things with the new Unity UI.

Next, I dragged my splash sprite from my imported assets into the Image Component's Source Image field and clicked on the Set Native Size button to quickly set the Rect Transform's dimensions to my source image's dimensions.

Then I opened the Animation window with Ctrl+6 and clicked on Add Property button and added a key frame to the Image.Color property, and then tweened the Color.a property from 0.0 to 1.0 to fade in, then a few seconds later in the animation, a tween from 1.0 to 0.0 to create a fade out.

At this point, all I need to do (and have not done yet) is toss a new Script on my Main Camera and use a Coroutine to wait the duration of my animation and then call Application.LoadLevel to load in my next scene. And Boom, my Splash Scene is complete.

(The Splash Scene in Pitch is actually more complicated than this, but the same techniques shown here were used for all the elements. I'm just using several animations and Images in the Pitch Splash Scene)


No comments:

Post a Comment