Tutorial: Coroutines (pt. 1) – Waiting for Input.

Written by equalsequals

If you’re new to Unity, you may have heard some phrases being tossed around like “coroutine” and “yield”.

What is a coroutine you ask? Wait a minute, I can tell a method to pause for a frame and then continue doing whatever it was it was doing? Huh? I can specify an amount of time (in seconds) that I can pause the function for, too?

I know there are some people out there probably calling b/s but I’m being serious here. Yes, you can do all of the aforementioned with a coroutine.

When I first started I will admit I didn’t know what a coroutine was and even now I have come to learn that I have only seen the tip of that proverbial iceberg. But from what I do know – I am going to share what I have found out in some basic, but somewhat practical examples (both in C# and Unity’s Javascript dialect) and as time goes by I’ll make them more and more “real world” examples in the following versions of this tutorial.

Read the rest of this entry »

Categories: Tutorials
Nov
18

Asset Bundles and the headache I found therein

Written by equalsequals

So the last little bit I have been working on a web game that is comprised of 11 different scenes (10 levels and a main menu).

To make the game extremely lite-weight on initial load we decided to bundle the music for each level and each level themselves separately. This resulted in 21 separate asset bundles. (2 bundles per level + the main menu’s bg music)

To make things simple for programming, a basic asset loader component was constructed and placed along side each scene’s main managing script. On initial load of main menu, the music is loaded in. The user will then be able to navigate around the main menu and eventually choose a level. Upon selecting a level, a bundle containing the level that was selected is loaded in and then the Application.LoadLevel(“levelname”) is called. This works, to an extent.

Continuously upon returning to a scene that was already visited once before I received this exception:

The assetbundle ‘file_name_here.unity3d’ can’t be loaded because another asset bundle with the same files are already loaded
UnityEngine.WWW:get_assetBundle()

Okay – so… I can’t load in this bundle because it’s already been loaded. That’s fine, I’ll just check if the bundle has been loaded before I load it. Sounds simple enough. – Famous last words.

Read the rest of this entry »

Categories: Development
Tags:
Nov
18