The Infernicore: Flash Game to Unity Game Part 2

This is the second part of the two-part post where I’m describing my experience with transferring a Flash game into Unity. In the first part I went over the differences in the physics and overall coding structure between the two pieces of software. In this part I’ll talk about creating objects dynamically, as well as my findings with transferring graphical assets.


Unless I’ve overlooked something, in Unity you can’t spawn objects from your project panel directly into your game scene without having had a reference to them already at compile time. But I really don’t think this should be a deal-breaker for any game. It’s quite simple to do. For example, in The Infernicore, I created a script called ICMain and attached it directly to the Main Camera object as a Component (the Main Camera is created in every scene by default). Within the ICMain script itself, I declared a variable called oreObject. Upon saving the script and returning to the Unity editor, I saw that “Ore Object” became a property in the Inspector Panel of the Main Camera object. I could then drag my Ore prefab from my project Panel directly onto the “Ore Object” section of the Inspector Panel. Voila! My main then had a reference to an Ore object, in code, that it could create at will. When I needed to do just that, I called Unity’s Instantiate()method and a new Ore object was created.

Referencing Objects to Instantiate
Create a variable and drag the object from your Project Panel to this field in the Properties Panel.

Like I said, I don’t think being required to have a reference to an object at compile-time is necessarily a really bad thing. I can understand how someone, especially a programmer, may balk at the idea at first, perhaps claiming that it limits control over the project, but I think the way Unity handles it will work in the vast majority of situations.

UPDATE: It turns out there actually is a way to instantiate objects without having a direct reference to them at compile-time. Simply place them into a Resources folder and use Instantiate(Resources.Load(“Object”)) instead. This method does have its own pros and cons, however. See this page for more information.


Since The Infernicore was originally a Flash project, all of its graphics were vector-based. Fortunately, however, converting vectors to bitmaps is quite simple with the newest version of Flash Professional.

One thing I want to talk about is utilizing textures with alpha channels, despite their irrelevance to this particular game. When we first started developing this project in Unity, we weren’t sure if we wanted to do everything in 2D or 3D. We settled on 3D eventually, which meant that alpha textures were more or less not needed, due to the 3D models using form-fitting skin textures instead. When I first searched for the answer of how to use alpha textures, I was met with directions that told me to install plug-ins for Photoshop. That seemed like a pretty janky solution, and it confused me as to why something like that would be on Unity’s site when it actually wasn’t necessary.

In order to use alpha textures, you simply have to ensure that the background of your image is removed (such as by deleting the background layer in Photoshop and cropping the image accordingly), save it as a PNG, import it into Unity, create a material for it, and set the material’s shader to Transparent/Diffuse. This worked like a charm for me.

We still plan on using 2D images for things like backgrounds and GUI elements, obviously. And when it comes to all of the different screen sizes for the myriad of Android phones out there, I definitely have some testing to do. I may post my findings on that adventure later on, but for now I’ll leave it at this: the transition from Flash game to Unity game has been relatively painless, and I hope others can say the same.