iOS build error in Unity3D and How to recover all data!

There is a huge bug in unity3d but most of us are not aware of. That is if your iOS build process stuck in the middle the unity will go unresponsive and delete all the contents up to the very root of that folder. That means think you have a project AAA at a certain location like D:/Project/MyProjects/Unity3d/AAA/. If you get stuck it will delete all the files inside D:/Projects folder. Scary right? There are numerous discussions about this in the unity forums too. See the below link.

So I myself also got in to this very unfortunate incident and lost a total close to 700GB of data. But fear not! Unlike the users are complaining, it won't delete your files. They are there but you just can't access them. Which means all the hard links to those files are being deleted but not actually the physical data itself. So in a nut shell it hides all the data or clear for god's sake. So easiest way is to use Recurva from Piriform. Download it via this link! This will redirect to their official download page and you can download the latest version from there. I was able to recover all those data back. Yay! But remember to use another hard disk to store recovered data. Don't use the same hard drive because it overlaps already remaining data. So use an empty hard disk.

But how  can we stay away from the bug?

1) Update to the latest release ( Unity 4.5.5 ). They said they have solved the issue. But there are some people in who are still having issues.

2) Store and work you projects in desktop. For whatever the reason if you store your projects on data and it get stuck it wont delete all the data in C and Desktop. No idea why. But currently that's the only way to work safely in unity3D with iOS if you are using windows.

If there are other ways please comment and let me know too. See ya :)

Analog meter for Dashboard in Unity3D

Finally research project is completed and all exams and whatnot are over. So next is finding a job. Sigh! I want to go backpacking but seems like there is no other time. Anyway got our research paper published and you can view it here. Also I have uploaded a prototype build of the system, if you guys fancy, might wanna check out that multiplayer simulation awesomeness :D Download link here! Well it's not much, but basically a prototype level mutiplayer video game. Port is 25002 and you may want to forward the port to play via internet.

Anyway back to topic. This is actually the refined way for "Dear Diary : Day 7" post. The issue with that method is when your point of origin changes animation tends to go round, not around the pivot making a weird animation. But with this code, it works perfectly. You can position in anywhere you want and can change the meter reading my changing the angle. Can be used to make a dashboard or so. We used this code to implement all the gauges in the flight simulator. Code comments are there to explain everything. This code handles only the needle of a meter. To display the meter itself use a GUITexture with the image of meter background and attach this script and drag and drop the needle texture to script's variable assigning column.

 using UnityEngine;  
 using System.Collections;  
 using System.IO;  
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Diagnostics;  
 using System.ComponentModel;  
 public class AnalogMeer : MonoBehaviour  
   public Texture2D texture = null;  
   //rotation angle to rotate around pivot  
   public float angle = 0;  
   //resolution of the needle for meter  
   Vector2 sizeOfNeedle = new Vector2(12, 70);  
   Vector2 position = new Vector2(0, 0);  
   Rect rect;  
   Vector2 pivot;  
   void Start()  
     //position the needle to start position  
     gameObject.transform.position = new Vector3(Screen.width / 1.9999f, Screen.height / 1.68f, 0);  
     //refresh variables with current position and rotation values  
   void Update()  
     //change this angle to change the meter reading, this is a scalar value. Use your source of information, like speed amount for a speedometer  
     angle = (float)2.8f;  
   void UpdateSettings()  
     //translate to local axis postition relative to screen size  
     position = new Vector2(transform.localPosition.x, transform.localPosition.y);  
     //create and reset to the middle point of the rectangle  
     rect = new Rect(position.x - sizeOfNeedle.x * 0.5f, position.y - sizeOfNeedle.y * 0.5f, sizeOfNeedle.x, sizeOfNeedle.y);  
     //pivot point for rotation  
     pivot = new Vector2(rect.xMin + rect.width * 0.5f, rect.yMin + rect.height * 0.5f);  
   void OnGUI()  
     if (Application.isEditor)  
     { //call update settings and refresh 60 times a minute   
     //backup initial rotation (0 reading) to a matrix  
     Matrix4x4 matrixBackup = GUI.matrix;  
     //rotate around pivot  
     GUIUtility.RotateAroundPivot(angle, pivot);  
     //Draw the texture which you supplied for meter's needle  
     GUI.DrawTexture(rect, texture);  
     //reset the texture rotation to 0 meter reading.  
     GUI.matrix = matrixBackup;  

PC case : Dead silent!

Okay came here to put a post after some time. I stopped writing the Dear Diary series because I got some work to do. We had our research work and research paper draft submissions and mid review presentation. I barely slept 4 hours a day for last couple of days. So what I realized is there is no point of writing my shit in this blog crying that I didn't work. Instead I should work better. Sigh!

Anyway all presentations and shit finished yesterday. So yesterday afternoon I started modding the PC. If you have read my previous posts you should have known that I'm bit of a noise freak. I'm so sensitive to sound that I can hear the slightest wind moving. So this fan sounds in my PC are quite unbearable. So my first idea was to make an open bench case. So only the inbuilt fans will be included and no extra case fans will be needed as it's properly ventilated. But the problem is what if accidentally someone spill any drinks or food? Or some small insect goes into circuits in the PC? So I gave up that idea. Instead I had two choices. Get a silent case like Corsair 750D which is unreasonably expensive in Sri Lanka for a case. Or DIY mods to silent my PC. Actually Corsair 750D price is not seller's issue. It's that importing such a case takes a great amount of tax and shipping. Otherwise I would love to get a Corsair 750D for myself. It's such a lovely case! <3

So even though I can't exactly replicate Corsair 750D's design features, I could do that to some extend. So I chose the DIY path. I purchased foam sheets of 1cm density for $2. And that's for four of them. Dirt cheap! :D So last night I cut them for pieces and pasted inside my case for noise dampening. Soft materials reflect sound waves and hard materials absorb them. So I did basically the same thing which studios does. I used rough foam sheets to absorb sound inside the case. And included a fan controller plus a switch to control 2 case fans.

And results are marvelous! Absolutely lovely to say :) At 5v ( Lowest in fan controller ) I can't hear anything now. It's dead silent. CPU fan runs around 1150RPM it's noise is dampened by the foam sheets too. Intel stock cooler is shit! It's noisy. I will replace it with a Cooler master 412 soon. Don't like the look of 212 so waiting for a 412 which currently no one has stocks available :(

And also made a small stool to keep the PC under the table. So it should reduce noise when it produce under the load also. And I'm very happy with the end result now. Sweet. I can code peacefully now :D

So this is my desk now. PC gone under the table and only laptop and monitor and stuff are remaining. Simple and elegant! :)

Dear Diary : Day 7 ( Individual GUI Component Rotation in Unity3D )

Finally a somewhat productive day! I did some work on my project and what can I say it was a success. So I thought like this, if I get to know something cool, will add along the Dear Diary post series without making any new posts. I'm lazy what can I say :)

Lot of people have searched in Unity forums how to change rotation of individual GUI elements in Unity3D. Most of answers are using custom shaders and changing Matrix to do that. Well there's an easier way. Change the GUIUtility factors. Then they will be global to every GUI elements and every element would start to rotate. Now the fix is easy. You don't have to use complex matrix calculations.

1) In whatever the function ( in my case OnGUI() ) used to drive the code, execute the rotating ones first and then re rotate the Global GUIUtility factor by multiplying (-1).
2) use different script files for each GUI element.

And I decided not to do the skeleton build. I'm going to put a hold for that for now. Just because I'm broke. My HDD and CPU cooler are failing so I need to buy them asap. So no money to waste on metal strips and paints it seems. May be another time. And need to buy a keyboard too. From the day my asshole relative liquid damaged my DAS Model S, I've been using a Logitech wireless rubber dome keyboard. Now that one of my good friends revived my feeling for a mechanical keyboard, I think it's time to get one again. I guess I'll go with the Cooler Master Quick fire rapid. Because it's made by Filco which is one of the best mechanical keyboard makers in the world!

Nothing much for the day. Me out :)

Dear Diary : Day 6

Today was exhausting! I finished watching an entire TV series in one day. The Tomorrow People, very nice story. I always had a thing for genetics based stories. Real nice. Shame it has no any sequel. Another day wasted!

Anyway I'm planing to buy metal stripes for my DIY open air bench PC case. I already ordered PCI express extender cables. Need ti buy two decent wood boards and nut/bolts for tighten them up. And rubber sheets too. This is going to be awesome and my mind just sings for that :D

I'm going to get some sleep. Eyes are like burning :D