Sunday, 19 January 2014

Absolute and Relative Positions

Laying out Unity menus using GUITexture and GUIText has been a bit confusing.

I'm not entirely sure I understand it yet but the basics are that everything is relative to it's parent.
I've been trying to calculate absolute pixel positions and this has been difficult.  Rarely has anything ended up where it was intended.

It wasn't until I read the following post that it sunk in that Unity is trying to scale everything to fit the screen or viewport:

As far as I can tell Unity is designed to allow for any resolution on different screen sizes on different platforms.  It scales to fit the screen automatically.

If I am doing it manually and Unity is doing it automatically I end up with the wrong result.

I haven't worked it all out myself yet but it might give others reading this a head start if they try to work with the Unity methods rather than bypass them!


Follow-up:  Since writing the above I have become more confused.  If I try to save screen positions in the OnGUI() method to line up with the text or graphic positions on the screen and then process actions based on them in the Update() method I frequently find that the positions are no longer valid.

My results are not consistent.  At the moment if I want an input position to line up with text, like processing my own version of a mouse over event, my only reliable solution is to carry out all the processing in the OnGUI() method.

Odd, perhaps someone can tell me why.

Tuesday, 7 January 2014

MonoDevelop Preferences

I've grown to like MonoDevelop over the last few weeks.

It has a few differences to Visual Studio, that I have been using for decades but so far nothing that makes me long to go back.

Visual Studio (VS) feels like a more robust implimentation and I think is a little faster at picking up context sensitive colouring but that's it.  MonoDevelop has hung a couple of times but never lost any of my work.

I've always been happy to swap and change Integrated Development Environments (IDE), text editor and language so I am not the most critical about the cosmetics of my tools.  I do however expect them to allow me to work without getting in the way.

MonoDevelop allows me to get on with my work, provides some useful tools, like the refactor option which now I am used to it I prefer over the little drop down available in VS.

So far I have only found two preferences that I have changed.  One is simply the choice of colour coding style.  The other is more important.  By default MonoDevelop opens up the previous session when you start.  Like I have done for Unity, this does not suit me as I swap between projects.

There is a tick box to turn off this behaviour:
It's in the Tools -> Options menu under Projects -> Load/Save.