Ray's Pointless Software

October 30, 2012

NGUI dynamic table contents

Filed under: Uncategorized — Tags: , , — admin @ 11:28 pm

If you’re looking to have dynamic tables in your UI and you’re using NGUI for Unity3d, here’s how I’ve been able to do it:

In this example I have a table that contains a data driven list of available levels for a level select screen.

Create a UITable within your panel, and set the columns/padding/etc. Create a prefab to represent one of the items in your UI, and set it to a member variable of your UI script.

public GameObject AvailableLevelPrefab;

In the code that populates the table, create a reference to the table GameObject, loop over the items that you want to include in the table, and instantiate a prefab for each level.

//table game object
var levelsPanel = GameObject.Find("LevelsTable");
foreach(var level in levelsForPlanet){
 var levelUIFragment = Instantiate(AvailableLevelPrefab, levelsPanel.transform.position, levelsPanel.transform.rotation) as GameObject;

//change the level name according to how you want the table items sorted.
 levelUIFragment.name = level.SceneName;

//parent the table item to the table game object
 levelUIFragment.transform.parent = levelsPanel.transform;
 //parenting the item will change its scale. Change it back to whatever it was before
 levelUIFragment.transform.localScale = Vector3.one;
//once the table item exists, you can alter the UI elements so that they match the item. 
//in this case, I'm changing the property of a button so that when clicked, it will bring the player to the correct level
var buttonGameObject = levelUIFragment.transform.Find("Button");
 var button = buttonGameObject.GetComponent<SelectLevelButton>();
 button.PlanetName = level.SceneName;
 }

//once everything is instantiated, call the reposition method in the levels panel
 levelsPanel.GetComponent<UITable>().Reposition();

I’ve used this method a few times, and it seems to work pretty well. Anyone out there have any other methods for creating data-driven UI?

Edit: Cody just commented with an easier way to add the item to the table. Most everything stays the same, but instead of instantiating the prefab, parenting, and changing the scale, NGUI has a helper method that does all of that for you. This is how it would look:

var levelUIFragment = NGUITools.AddChild(levelsPanel, AvailableLevelPrefab);

Thanks for the tip Cody!

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

October 27, 2012

Awesome review for Embiggen Plus

Filed under: Uncategorized — Tags: — admin @ 1:57 am

Android user Ade just posted a great review with yet another use case for Embiggen Plus:

“Was at a gig by my favourite artist, used this to show him a message, he read it and gave me a shout out. My life is complete. Amazing app. Thank you.”

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

October 17, 2012

Cluster Missile

Filed under: Uncategorized — Tags: , , — admin @ 1:02 am

One of the in-game weapons I want to have for the player is some sort of cluster missile – basically, you fire one projectile, and it explodes and creates a couple more projectiles, which explode, and so on. I’m trying to document how I do this, so here goes:

I created a simple projectile in blender that sorta looks like a missile (it’s really just a cylinder with the center vert pulled out of one of the ends. I imported the model and created an empty game object to contain the model. This way, it’s easy to transform the model and attach custom scripts to it.

  • ClusterMissileEmpty
    • ClusterMissileModel

The empty object has the actual script attached to it. You can find it here: http://pastebin.com/yZpRyJkq

Basically, each missile spawns copies of itself and rotates the copies. I’ll probably add some sort of explosion effect, and change the model so that it doesn’t look so terrible.

Here’s what it looks like:

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

October 16, 2012

Scrap Rocket (working title)

Filed under: Uncategorized — Tags: — admin @ 12:47 am

A couple of months ago, I started working on a new game using Unity3d. It’s a little late in the process, but I figure I should start documenting the process of making the game – hopefully I’ll be able to look back on it and see the progress I’ve made on the game.

So here’s what I’ve made so far:

  • A working spacepod which can be controlled on a touchscreen
  • The start of a couple of levels
  • A few enemies with basic AI
  • A title/level select screen which is missing a bunch of functionality,  but I think it looks fairly decent.
  • The main game mechanic – which is the ability for the spacepod to tow scrap back to the start of the level
  • An equipment selection mechanic
  • A few different weapons
  • A shield for the spacepod

I’m probably forgetting some stuff, but there will be more posts to come. Here are a few initial screenshots:

Scrap Rocket Title Screen

Level 1

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

September 29, 2012

Unity spiral effect

Filed under: Uncategorized — Tags: , , — admin @ 10:53 pm

I just found a pretty cool spiral effect for unity – just hook it up to some legacy particle emitters and it works great: http://wiki.unity3d.com/index.php?title=Particle_Spiral_Effect

One note, make sure you un-check the Emit setting in the emitter, otherwise it’ll use the default emission setting

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

September 18, 2012

Embiggen with Tasker

Filed under: Uncategorized — admin @ 12:00 am

Embiggen user Tim just asked me if there was a way to use Tasker with Embiggen, and it turns out there is. Lets say we wanted to have the contents of a text message show up in Embiggen when you get a text message. Here’s what you do:

  1. Create a profile that listens for an incoming text message (New profile -> Event -> Phone -> Received Text)
  2. Create a new Send Intent task with the following settings:

Extra:
Text:%SMSRB

Package:
com.briercan.embiggen
(com.briercan.embiggenplus if you’re using Embiggen Plus)

Class:
com.briercan.embiggen.BigWordsActivity
(com.briercan.embiggenplus.BigWordsActivity if you’re using Embiggen Plus)

It should look something like this:

If you want to show different text for the app, just use a different variable in the Extras field instead of %SMSRB. For example, if you want the name of the person who texted you, put the following in the Extras field:

Text:%SMSRF

I hope this helps! Post a comment if you have any questions or if you have a good idea for how to use Tasker with Embiggen!

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

April 14, 2012

New embiggen updates

Filed under: Uncategorized — admin @ 1:10 pm

Version 1.5.1:

  • Keyboard now shows when clicking back from the embiggened text screen (thanks for the idea Duncan!)
  • New animations in Embiggen Plus!

 

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

March 6, 2012

OverLand V 0.1.5

Filed under: Uncategorized — admin @ 3:00 am
  • Throw attack animation
  • tower projectiles
Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

March 3, 2012

Overland v 0.1.4

Filed under: Uncategorized — Tags: , — admin @ 2:59 pm

 

  • Stat based attacks
  • Armor actually protects you!
  • Run game in landscape mode (switching back and forth is still an issue)
  • Removed status bar in gameplay window
  • Bouncy Balls move faster
  • Fixed quest list screen
  • Adjusted experience/levels
Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg

March 1, 2012

Dry-clean only shirts

Filed under: Uncategorized — admin @ 12:13 am

The late comedian Mitch Hedberg once said:

My shirt is dry-clean only, which means that it is dirty.

This is one of his many funny one-liners, but it has significance when making software. If it’s a pain to take a shirt to a dry cleaners, you’re not likely to clean the shirt at all. The same goes for unit testing, making reliable backups, having a branching strategy, etc. Sometimes the tools you’re using make it hard to follow these best practices, so they don’t get done.

If you find yourself saying things like: “Branching, oh no, we use VSS, merging is a nightmare!” or “I can’t unit test, our code has so many dependencies”, maybe it’s time to start looking into fixing the reasons why you can’t branch or unit test. Maybe switch to git, or a recent version of TFS if you can. Set up some dependency injection so that your code is easier to test. Sometimes it’s not easy to make these types of changes, but it’s usually worth it.

What are some other “Dry-clean only shirts” in the software world, and how can you fix them?

Share and Enjoy:
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Twitter
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Digg
Older Posts »

Get a free blog at WordPress.com