UsedAssets.GetLists C# (CSharp) Method

GetLists() public static method

public static GetLists ( List &assetResult, List &dependencyResult ) : void
assetResult List
dependencyResult List
return void
	public static void GetLists(ref List<string> assetResult, ref List<string> dependencyResult)
	{
		assetResult.Clear();
		dependencyResult.Clear();
		
		string LocalAppData = string.Empty;
		string UnityEditorLogfile = string.Empty;
		
		if (Application.platform == RuntimePlatform.WindowsEditor)
		{
			LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
			UnityEditorLogfile = LocalAppData + "\\Unity\\Editor\\Editor.log";
		}
		else if (Application.platform == RuntimePlatform.OSXEditor)
		{
			LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			UnityEditorLogfile = LocalAppData + "/Library/Logs/Unity/Editor.log";
		}
		
		try
		{
			// Have to use FileStream to get around sharing violations!
			FileStream FS = new FileStream(UnityEditorLogfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
			StreamReader SR = new StreamReader(FS);
			
			
			string line;
			while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains("Mono dependencies included in the build"));
			while (!SR.EndOfStream && (line = SR.ReadLine()) != "")
			{
				dependencyResult.Add(line);
			}
			while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains("Used Assets,"));
			while (!SR.EndOfStream && (line = SR.ReadLine()) != "")
			{
				
				line = line.Substring(line.IndexOf("% ") + 2);
				assetResult.Add(line);
			}
		}
		catch (Exception E)
		{
			Debug.LogError("Error: " + E);
		}
	}
}

Usage Example

    private void loadEditorLog()
    {
        UsedAssets.GetLists(ref usedAssets, ref includedDependencies);

        if (usedAssets.Count == 0)
        {
            needToBuild = true;
        }
        else
        {
            foreach (string s in usedAssets)
            {
                //if (assets.Contains(s))
                {
                    UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(s, typeof(UnityEngine.Object));
                    if (obj != null)
                    {
                        usedObjects.Add(new KeyValuePair <string, UnityEngine.Object>(s, obj));
                    }
                }
            }

            groupEnabled = true;
            needToBuild  = false;
        }
    }
All Usage Examples Of UsedAssets::GetLists