It works except it doesn't... Why?

Hi all.

This has happened to me so many times and I am at a loss to explain why.

If I say

Everything compiles fine but at runtime I get unallocated object errors and it simply doesn’t work…

Then I do this:

	panels = new _PanelInfo[3];
	for (x= 0; x < panels.length; x++)
		panels[x] = new _PanelInfo();
	panels[1].side = eScreenSide.Right;

and now everything works just fine…

So I go an edit some other files and I compile the other files and I run the game a couple of times and then suddenly I get a compile time error saying :

Void? When does _PanelCode become a Void?

Why does it work one moment and then not the next? Even by restarting Unity it still recognizes this as an error… Why? How do I overcome this?

The problem is that your _PanelInfo function does not return _PanelInfo but returns void by its function declaration.
That is at least what the error indicates.

This might potentially be related to the missing new there as you call the constructor without new, at least if you are using C#

I actually do use the new. I took it out simply to test and forgot to put it back before I posted the message. Updated the post.

So I tried

	panels = new ArrayList();
	for (x= 0; x < 3; x++)
	{
		var o : Object = new _PanelInfo();  
		panels.Add(o);
	}

and still get the

Error message.

Also if I try:

	panels = new ArrayList();
	for (x= 0; x < 3; x++)
	{
		panels.Add(new _PanelInfo());
	}

so from this I deduced also that my class is returning void… but how does one specify the return value for a class in JavaScript?

Here is what I am doing at the moment:

class _PanelInfo extends Object
{

erm… never mind…

It was just me being stupid…

This is what happens when you are sick AND sleepy AND sitting in front of the iMac at midnight…

MyBad…