Monday, May 11, 2015

A problem with Unity3D and downloading/caching AssetBundles

(This post is in reference to Unity 5.0.0f4.)
Anyone who has struggled with Unity’s asset bundle solution may have faced these issues, and hopefully can provide a solution.  Here is what I want out of the APIs surrounding Unity’s asset bundle system, specifically, the discrete abilities to:
- Download an asset bundle
- Load an asset bundle
- Cache an asset bundle
- Check if an asset bundle is cached

But instead, as is all too common with Unity’s APIs, we get bits and pieces of this hobbled together in a way that seems to assume a very specific (and often not ideal) workflow.  Here’s essentially what Unity offers via API:

- Load an asset bundle from cache, or download it if it’s not in the cache and be forced to load it if you want to use it
- Download an asset bundle but don’t cache it
- Check if an asset bundle is cached
Long story short, I cannot do what I need to do with these APIs.  So instead I need to create a convoluted façade over them which results in much more work than should be required.  Further adding a [very large] wrinkle to the problem is that the loading of an asset bundle is intimately tied to the download operation; namely, if I want to use an asset bundle that I’ve just downloaded, I need to load it right away from the download code (since an asset bundle is loaded via accessing the assetBundle property of WWW--no joke).  I can’t easily download it, pass it along to another object, and then load it when I’m ready without worrying about the IDisposable nature of the WWW object.

If any of what I’ve said sounds like nonsense, I’d love to hear the solutions to these issues.

Sunday, July 20, 2014

Regarding if/else versus if/implicit else

I have my own particular C# coding style which for the most part is fully in-line with the most popular style guidelines, but there's one thing I do that I've received criticism for:

Let's suppose you have an if statement with a return statement in the block:

if (someCondition)
{
    return x;
}

return y;

There's no need to write an else block, because it's implied that the only time return y will be executed is if the if condition is false.  Nevertheless, I prefer writing:

if (someCondition)
{
    return x;
}
else
{
    return y;
}

Why?  Because it's more resistant to change.  What if I (or someone else) suddenly modifies the true block, eliminating the return statement?  In the first code snippet, this may result in a bug.  The second one, however, is protected from this.


Sunday, September 8, 2013

Some life updates

Wow, I was so down on myself about Ludum Dare 27, but looking at that little video in my last entry, it’s kind of cute.  I’m excited that Unity announced a bunch of new 2D stuff, including Box2D integration (which should make those rope physics simpler). So we’ll see how that plays out.

I recently got an awesome new job as a game developer at a company I have always had a ton of respect for.  This really is an incredible situation and I’m almost afraid to boast about it for fear of jinxing it.  It’s so nice to be excited to come to work every day.  I won’t share the details of my employment out of an irrational fear that I’ll say something objectionable in my blog some day that will come back to haunt me. Smile

 

The only problematic consequence of having my new awesome job is that I can’t feasibly work on my own independent game projects except as a hobby.  I may still work on non-game apps and that sort of thing, which I’ll post about here.  And I’m sure I’ll have plenty of demos I work on in Unity just for fun.

Sunday, August 25, 2013

In case anyone’s wondering why it won’t be done in time…

Same ol'

Well, I'm at that point in the competition at which I realize that I'm not going to get this thing done in time, having spent too much time browsing Reddit and watching YouTube videos, etc.  I can either keep working on it, or make better use of my time by cleaning my house, etc.

I think I'd rather do the latter, as defeatist as that sounds.  I don't feel too bad though, because I learned a lot about dynamically generating a rope/grappling hook using Unity's built-in physics.

I would say "next time", but I know I'll just feel the same way then too.

Saturday, August 24, 2013

Simple rope slinging

Okay, progress has been slow, I know.

But here’s the beginnings of the rope slinging, with no physics or termination or anything.  I haven’t decided yet but I may turn this game into pure rope slinging, no running and/or jumping.

My work so far

As always, I’ve been slacking, Redding, eating, walking, etc. when I should be working.  But I’ve got a little stick figure that can jump around and land on platforms and sometimes not fall through them: