Unity Editor - Missing animation references

Unity – Broken animation property references

So, for a while now this has been bugging me, when you update the name of an object in Unity3D, it breaks the reference to the object’s properties in the timeline if you are animating them.

The only way to fix it seemed to be to create a new property from the renamed object and then copy the keyframes to it, which is really time-consuming and not ideal. The ideal solution would be that you rename the layer and it recovers the reference, or drag and drop an object to the missing object or right click and select a new object.

Well, today I found a slight ray of hope, in my frustration at having some more broken references, I discovered after double clicking the objects name 3 times, it actually became selectable and it is possible to edit the field name and recover the link to the object! Although the selection is broken, I’m glad it exists and hopefully this is something Unity will fix soon 🙂

Unity3D - animation property broken (missing parameters)

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.

Unfortunately it turned out that there are still quite a few modern, popular, low end devices that don’t support ETC2 (it’s supported on OpenGL ES 3.0 devices), like the Samsung J1.

When a device doesn’t support ETC2 the textures are uncompressed and because they are low end or old devices it increases the likelyhood that they will run out of memory when you load alot of assets in a scene. Not a good scenario.

Realistically this makes ETC1 the better choice for now as it’s supported by all devices. However ETC1 does come with its own pitfalls:

  • Doesn’t work with Unity UI Overlay Canvas types
  • Can’t be loaded from Resources with Alpha intact
  • Requires a packing tag to support alpha channel
  • Renders alpha channel seperately making packed sheets hard to preview.
  • Performance is not as good as ETC2, but this won’t matter as much for devices that support ETC2 as they should be capable of handling it since they are better devices.

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.,

public GameObject sampleObj;
public GameObject[,] array = new GameObject[5,4];

private int columns = 4,rows = 5;
private float Xpos = 2.0f;
private float Xoffset = 2.0f;
private float Ypos = 1.0f;
private float Yoffset = 2.0f;

void Start ()
for (int j = 0; j < rows; ++j)
for (int i = 0; i < columns; ++i)
if(array[j,i] == null)
sampleObj.name = j + " " + i;
array[j,i] = (GameObject) Instantiate (sampleObj, new Vector3(Xpos * (Xoffset * i),Ypos * (Yoffset * i),0), Quaternion.identity);

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:

Vector3 eulers = Vector3.zero;
private bool waiter;

IEnumerator shotRedirect()
yield return new WaitForSeconds(0.0f);
eulers = transform.eulerAngles;
eulers.x = Random.Range(0,360);
transform.eulerAngles = eulers;
rigidbody.isKinematic = true;

IEnumerator shotRedirectPart2()
yield return new WaitForSeconds(0.01f);
rigidbody.isKinematic = false;
rigidbody.AddForce(transform.forward * shotPower);

private void Waits()
waiter = true;

void Update()
if(waiter == true)
if (Input.GetKeyDown(KeyCode.A))
waiter = false;

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:

This is my code:
Continue reading