Unity Android compression – ETC2 vs. ETC1

I’ve been working on a Unity project for Android and iOS lately. For Android we had been using ETC2 for the texture compression. The ETC2 benefits were:

  • Better performance on devices where it’s supported.
  • Supports non power of 2 textures.
  • Works with all Unity UI canvas types.

The UI canvas support was particularly important to us as the project uses Unity UI extensively and almost entirely built with it.

Continue reading

Creating a grid of objects

Here’s some stripped down code I use to create a grid of objects in Unity. I’ve used this setup in my Android game Block Blaze when the level is initialised. It’s attached to a Generator object, which also has some other functionality like determining what type of object is created, whether an object needs to be regenerated if its destroyed, what object types are neighbouring, etc.,

Continue reading

Unity3D Development – Rigidbody Reset Force / Motion Code

In my new game I need to be able to give an object in motion a new force (same magnitude) in a random direction with a button press. Here’s my C# solution using Coroutines.
Its working perfectly for me and solves the weird physics problem with stopping/starting using rigidbody.isKinematic.

All these code snippets are in the script attached to the object:

Continue reading

C# – Object Oriented Programming – Lab 5

You are required to develop an App, which acts as a fashion advisor. The program will have a form where you can type in the colour of your top, your pants and your shoes. The program will then give advice on whether the colours match. The program can use any feedback mechanism desirable.

The rules the program should implement are as follows:

The program only understands the colours black, red, blue, green, pink, brown or orange. The program should generate an error if any other colour is typed.

Black top, pants and shoes are fine
Brown shoes, blue pants and any coloured top is fine
Black shoes, blue pants and any coloured top is fine
Brown shoes, brown pants and blue top is fine
Brown shoes, black pants and red top is fine
Black shoes, brown pants and blue top is fine
Black shoes, black pants and blue top is fine
Any coloured shoes with orange pants are fine
Green shoes with any coloured pants and any coloured top, so long as its not red are fine.
All pink is fine.
Never have pink shoes with green pants, but pink shoes with red pants are fine.

Anything other combinations, the program should indicate that the particular combination of colours is not recommended.

Here’s my solution using a WPF app:

This is what the app looks like:

Here’s my solution for it:

Continue reading

C# – Object Oriented Programming – Lab 4

Here is the scenario we want to test:

– Write a “if else” statement that checks to see if bx and by are INSIDE the box. If the point (bx,by) is inside the box, print “Inside” otherwise print “Not inside”. (Hint use && in your answer)

– Test your IF statements with different values of bx and by

Values for the points:

x1,y1 = 100,100, x2, y2 = 120,150, bx, by = 115, 120

Here’s my solution for it:

Continue reading