Decompressing sharedassets0.assets / Rebuilding lost project

Hey there.

I had some of the worst luck a few months ago.

For my first Unity project, I did: http://apps.facebook.com/asteroidracing . (I didn't do the art, :P)

Turns out, like two days, after I published and got it on Facebook, my whole computer crashed, and I did not have a backup. Yeah yeah...

I did have a backup of almost all the scripts.

My problem is learning how to decompress the sharedassets0.assets so I can get my graphics back out. I tried importing the file into Unity, with no avail. I would like to learn how to retrieve the graphics from sharedassets0.assets so I can pull them up in Maya and modify them.

If anyone has any knowledge of this, I would love some input. I've been all over Google with no avail. I don't know if it's something super simple, or it's complicated. BTW, I code in 15 languages, so complicated is not that bothersome for me.

/Assets/Editor/UnpackAssets.cs

using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditorInternal;
using System.IO;

public class UnpackAssets : MonoBehaviour
{
static void delRecursive(string path)
{
try
{
foreach (string d in Directory.GetFiles(path))
{
File.Delete(d);
}
foreach (string d in Directory.GetDirectories(path))
{
delRecursive(d);
}
Directory.Delete(path);
}
catch { }
}

[MenuItem("Assets/Unpack %u")]
static void Unpack()
{
string file = EditorUtility.OpenFilePanel("Select assets file to unpack", "", "assets");
if (file.Length == 0) return;
Object[] objs1 = AssetDatabase.LoadAllAssetsAtPath(file);
string ImportDir = @"/Import_" + Path.GetFileNameWithoutExtension(file) + "/";
delRecursive(Application.dataPath + ImportDir);
Directory.CreateDirectory(Application.dataPath + ImportDir);
foreach (Object obj in objs1)
{
if (obj == null) continue;
System.Type type = obj.GetType();
string ext = "asset";

if (type == typeof(Material) || (type.IsSubclassOf(typeof(Material))))
ext = "mat";
else if (type == typeof(AnimationClip) || (type.IsSubclassOf(typeof(AnimationClip))))
ext = "anim";
else if (type == typeof(GameObject) || (type.IsSubclassOf(typeof(GameObject))))
ext = "prefab";

if (type == typeof(Component) || (type.IsSubclassOf(typeof(Component))))
{
continue;
}
string ThisName = obj.name.Replace('/', '_');
if (string.IsNullOrEmpty(ThisName)) continue;
string f = @"Assets" + ImportDir + type.Name + @"/" + ThisName + "." + ext;
Object o = obj;
if (!Directory.Exists(Application.dataPath + ImportDir + type.Name))
Directory.CreateDirectory(Application.dataPath + ImportDir + type.Name);

if (type == typeof(GameObject) || (type.IsSubclassOf(typeof(GameObject))))
{
Object prefab = PrefabUtility.CreateEmptyPrefab(f);
if (obj == null)
{
Debug.LogError("NullException");
}
AssetDatabase.Refresh();
PrefabUtility.ReplacePrefab((GameObject)(obj), prefab);
continue;
}
else
{
try { o = Object.Instantiate(obj); } catch { o = obj; }
}

if (o == null) 
continue; 

AssetDatabase.CreateAsset(o, f);
}
AssetDatabase.Refresh();
File.Copy(file, Application.dataPath + ImportDir + Path.GetFileNameWithoutExtension(file) + ".asset");
AssetDatabase.Refresh();
Debug.Log("Done");
}
}

" I tried to post this as a comment but It wouldn’t allow me, but how would I run that script? "

" where should i put the sharedassets0.assets "

oke just put the unpack asset script in your asset/editor folders,
then in your menu under Assets down below you see “unpack”

click on it look where you put that " sharedassetsX.assets file, then clik on it and wait…

after some time you have a sub folder in your asset folder called the same as the asset file your just grabben to unpack…thats it

alt text

il hope it is clear now :wink:

enjoy it