Unityception!, Load content created in unity from a build made with unity to Unity!

July 5 | 11

Problem we have:

We need a way to create and edit supermarkets as fast as possible with different products (more than 1500 kind of products) for marketing research and the created scenes need to be lightmaped and tweaked so they look as real as possible at the end.

Facts:

1) Unity doesnt offer an “out of the box” solution for placing specific products on shelfs (and it would be weird to have it).

2) A simple unity project with all the products that reside on our asset database  for a single supermarket has is not feasible as load times will take a lot (projects of 10+GB) and we want to keep file sizes as small as possible.

3) After creating all the products and placing them in each shelf we need to lightmap the whole scene  and do some tweaks as our environment needs to be as realistic as possible.

4) our asset library is huge so we need to organize it and load only the needed assets in each project.

Solution

I came with a fairly easy solution and it was that I “Duplicated” our library. one made of asset bundles and the other made of unitypackages. The one that contained asset bundles was going to be used in an editor that we created and the use of this editor was solely for placing the products/shelfs in the world.

Now when we save the file it saves the address of each asset in a VCS system so we can easily with an editor script download all the packaged assets (this is where we use the unitypackages), import them and place them according to the positions/rotations the editor has.

So finally I ended with 3 Unity Projects, 1 DataBase for assetBundles and one VCS that contained the UnityPackages for importing them.

The unity Projects:

-Supermarket Editor: This project is the one that is in charge for creating and loading all the asset bundles contained in the database and placing them accordingly. it also manages all the logic of the shelfs like you cannot put a product in the floor (only in a shelf), etc.

Its also the one in charge of  creating proceduraly the floor and delimiting the supermarket by creating walls for it. In this project goes all the logic for restricting the user for placing products correctly and also goes all the logic for serializing the data that is going to be loaded after in the Unity Editor.

-SuperMarket Library Creator: This project is used for creating both an asset bundle and an Unity package for the library. The asset bundle is used by the SuperMarket editor and the unity package is used by the Supermarket Scene Loader for loading the created scene inside unity.

-SuperMarket Scene Loader: This is a simple editor script that loads the created scene in the Supermarket Editor into the unity editor for further tweaking like lightmapping, occlusion culling,etc.

So the idea of how this works is like this:

Now after all this is done, this is how it works. Checkout a video I made.

PS3Print: Console Printer for PS3.

January 26 | 11

I started to grow some interest in console programming back when I was working at Unity Technologies but there was just not enough time to start learning; now that I’m not working there, that I own a PS3 and that the PS3 was jail broken I started to read lots of forum posts from psx-scene and started to learn about how to create some home brew apps.

My current goal is to create a simple app that recognizes all the buttons of the PS3 controller and show their values on the screen. Sadly PSL1GHT doesn’t include any quick library to start writing letters on the screen.

After some research over the internets I found this blog post about printing strings on the PS3 which caught my attention and this is how PS3Print started.

So basically PS3Print is  a simple static class written in C++ and it helps you out visualizing strings on the PS3 screen.

This library works with PSL1GHT but its not tied to it so is pretty easy to port.

This simple library only has 3 files:

  1. PS3Printer.h: Which contains all the prototypes and the and some pre-defined Font colors.
  2. PS3Printer.cpp: Which contains the implementation of all the prototypes.
  3. console_fonts.h: Which is a simple Array of arrays of integers which contains almost all the ASCII characters (at least the most used ones).

Using PS3Print:

Using PS3Print is pretty simple just place the 3 source files and you are almost ready.

To start using it just include PS3Printer.h:

#include "PS3Printer.h"

Then you just need to initialize the library with “Init”. The syntax:

static void Init(int screenWidth, int screenHeight);

screenWidth and height correspond to your TV/Monitor resolution where the PS3 is connected.

After this, you are pretty much ready to do print whatever you want with these functions:


static void Print(float x, float y, std::string text, uint32_t* buffer);
static void PrintError(float x, float y, std::string errorMsg, uint32_t* buffer);
static void PrintWarning(float x, float y, std::string warnMsg, uint32_t* buffer);

Where:

  • x and y: Represent the positioning of the text on the screen. These values go from 0 to 1 where (0,0) is the top left corner of the screen and (1,1) is the botom right side of the screen.
  • text / errorMsg / warnMsg: Represent the text you are wanting to print in the screen.
  • buffer: Represents the frame buffer that the ps3 is currently rendering on the screen.

The main difference between Print/PrintError and PrintWarning is that you can set the font color and the background color on the Print function while in the PrintError it always draws the messages in a yellow font color with a red backgroun, and the PrintWarning will draw the message in a yellow font color with a transparent background.

Now that you are able to print you can change the font color with these 2 functions:

static void SetFontColor(int _bgColor, int _fgColor);
static void SetFontColor(int _fgColor);

Where:

  • _bgColor: Represents the back ground color of the font
  • _fgColor: Represents the font color.

The colors are in the 0xAARRGGBB. (alpha channel not available yet). you can always check in PS3Printer.h for a few defined colors.

If you are still reading here and want to see a working example, you can always check the project here in GitHub for both getting the source code and the example.

Happy Coding! :D

Thanks to:

Scognito and Bitmaps fonts (courtesy of libogc).

Emacs mode for Javascript in Unity 3.x

January 11 | 11

It has been almost a year since I released an emacs mode for Javascript in Unity 2.x , now I’m releasing the same mode for Unity 3.x, the main difference between this mode and the old one are mainly additions of reserved words of the API (as there have been lots of additions to it) and also now it  colors the  ”case” word.

This mode supports both Runtime and Editor API functions. Feel free to modify it and also if you do anything interesting that can be added to the mode just let me know!

To make it work, just add this to your .emacs:

;; UnityJS mode for emacs
(autoload ‘unityjs-mode “unityjs-mode” “Major mode for editing Unity script code.” t)
(require ‘unityjs-mode)

And make sure to load the path where you are going to store the .el file.

The mode can be found here.

Any suggestions/feedback/bugs let me know!
;)

Project Cloudwitch

December 29 | 09

Project Cloudwitch is one of the games  I used to work on at C2Estudio and is one of the games I feel most proud of. The game is about an invasion of aliens trying to take over the control of different planets and your mission is to kill them all and survive as much as you can. Sadly the game didn’t have more levels/story because of budget problems.

Read the rest of this entry »