//Refer MonoManager, ScriptAssetExporter, ScriptExportManager
        void DoExport(Func <MonoScript, bool> selector = null)
        {
            var managedPath            = Path.Combine(GameDir, "Managed");
            var globalgamemanagersPath = Path.Combine(GameDir, "globalgamemanagers.assets");
            var gameStructure          = GameStructure.Load(new string[]
            {
                globalgamemanagersPath,
                managedPath
            });

            fileCollection = gameStructure.FileCollection;
            if (selector == null)
            {
                selector = (o) => true;
            }
            var assets = fileCollection.FetchAssets().Where(o => o is MonoScript ms && selector(ms)).ToArray();
            ScriptExportManager scriptManager = new ScriptExportManager(ExportPath);
            Dictionary <Object, ScriptExportType> exportTypes = new Dictionary <Object, ScriptExportType>();

            foreach (Object asset in assets)
            {
                MonoScript       script     = (MonoScript)asset;
                ScriptExportType exportType = script.GetExportType(scriptManager);
                exportTypes.Add(asset, exportType);
            }
            foreach (KeyValuePair <Object, ScriptExportType> exportType in exportTypes)
            {
                string path = scriptManager.Export(exportType.Value);
            }
            //scriptManager.ExportRest();
        }
        void DoExportAll()
        {
            Util.PrepareExportDirectory(ExportPath);
            var managedPath            = Path.Combine(GameDir, "Managed");
            var globalgamemanagersPath = Path.Combine(GameDir, "globalgamemanagers.assets");
            var gameStructure          = GameStructure.Load(new string[]
            {
                globalgamemanagersPath,
                managedPath
            });

            fileCollection = gameStructure.FileCollection;
            fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono;
            var scripts = fileCollection.FetchAssets().Where(o => o is MonoScript ms).ToArray();

            foreach (Object asset in scripts)
            {
                MonoScript script = (MonoScript)asset;
                if (ScriptByName)
                {
                    using (MD5 md5 = MD5.Create())
                    {
                        var data    = md5.ComputeHash(Encoding.UTF8.GetBytes($"{script.AssemblyName}.{script.Namespace}.{script.ClassName}"));
                        var newGuid = new Guid(data);
                        Util.SetGUID(script, newGuid);
                    }
                }
            }
            fileCollection.Exporter.Export(ExportPath, fileCollection, scripts, options);
        }
示例#3
0
        public void Export(string path, FileCollection fileCollection, IEnumerable <Object> assets)
        {
            VirtualSerializedFile    virtualFile = new VirtualSerializedFile();
            List <IExportCollection> collections = new List <IExportCollection>();
            // speed up fetching a little bit
            List <Object>    depList = new List <Object>();
            HashSet <Object> depSet  = new HashSet <Object>();
            HashSet <Object> queued  = new HashSet <Object>();

            depList.AddRange(assets);
            depSet.UnionWith(depList);
            for (int i = 0; i < depList.Count; i++)
            {
                Object asset = depList[i];
                if (!queued.Contains(asset))
                {
                    IExportCollection collection = CreateCollection(virtualFile, asset);
                    foreach (Object element in collection.Assets)
                    {
                        queued.Add(element);
                    }
                    collections.Add(collection);
                }

#warning TODO: if IsGenerateGUIDByContent set it should build collections and write actual references with persistent GUIS, but skip dependencies
                if (Config.IsExportDependencies)
                {
                    foreach (Object dependency in asset.FetchDependencies(true))
                    {
                        if (dependency == null)
                        {
                            continue;
                        }

                        if (!depSet.Contains(dependency))
                        {
                            depList.Add(dependency);
                            depSet.Add(dependency);
                        }
                    }
                }
            }
            depList.Clear();
            depSet.Clear();
            queued.Clear();

            ProjectAssetContainer container = new ProjectAssetContainer(this, fileCollection.FetchAssets(), virtualFile, collections);
            foreach (IExportCollection collection in collections)
            {
                container.CurrentCollection = collection;
                bool isExported = collection.Export(container, path);
                if (isExported)
                {
                    Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported");
                }
            }
        }
        void DoExportAll()
        {
            Util.PrepareExportDirectory(ExportPath);
            var managedPath            = Path.Combine(GameDir, "Managed");
            var globalgamemanagersPath = Path.Combine(GameDir, "globalgamemanagers.assets");
            var gameStructure          = GameStructure.Load(new string[]
            {
                globalgamemanagersPath,
                managedPath
            });

            fileCollection = gameStructure.FileCollection;
            fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono;
            var scripts = fileCollection.FetchAssets().Where(o => o is MonoScript ms).ToArray();

            fileCollection.Exporter.Export(ExportPath, fileCollection, scripts, options);
        }
示例#5
0
    public static void Main(string[] args)
    {
        HashSet <uint>            paths = new HashSet <uint>();
        Dictionary <uint, string> bones = new Dictionary <uint, string>();

        foreach (var dir in args)
        {
            foreach (var fn in Directory.GetFiles(dir, "*.unity3d", SearchOption.TopDirectoryOnly))
            {
                var coll = new FileCollection();
                coll.Load(fn);
                foreach (var asset in coll.FetchAssets())
                {
                    var clip   = asset as AnimationClip;
                    var avatar = asset as Avatar;
                    if (clip != null)
                    {
                        foreach (var binding in clip.ClipBindingConstant.GenericBindings)
                        {
                            paths.Add(binding.Path);
                        }
                    }
                    if (avatar != null)
                    {
                        foreach (var kv in avatar.m_TOS)
                        {
                            bones[kv.Key] = kv.Value;
                        }
                    }
                }
            }
        }
        foreach (var pathid in paths)
        {
            if (bones.TryGetValue(pathid, out string path))
            {
                print($"{pathid} {path}");
            }
            else
            {
                print($"Unresolved {pathid}");
            }
        }
    }
        //Refer MonoManager, ScriptAssetExporter, ScriptExportManager
        void DoExport(Func <MonoScript, bool> selector = null)
        {
            var managedPath            = Path.Combine(GameDir, "Managed");
            var globalgamemanagersPath = Path.Combine(GameDir, "globalgamemanagers.assets");
            var gameStructure          = GameStructure.Load(new string[]
            {
                globalgamemanagersPath,
                managedPath
            });

            fileCollection = gameStructure.FileCollection;
            if (selector == null)
            {
                selector = (o) => true;
            }
            var assets = fileCollection.FetchAssets().Where(o => o is MonoScript ms && selector(ms)).ToArray();
            ScriptExportManager scriptManager = new ScriptExportManager(ExportPath);
            Dictionary <Object, ScriptExportType> exportTypes = new Dictionary <Object, ScriptExportType>();

            foreach (Object asset in assets)
            {
                MonoScript script = (MonoScript)asset;
                if (ScriptByName)
                {
                    using (MD5 md5 = MD5.Create())
                    {
                        var data    = md5.ComputeHash(Encoding.UTF8.GetBytes($"{script.AssemblyName}.{script.Namespace}.{script.ClassName}"));
                        var newGuid = new Guid(data);
                        Util.SetGUID(script, newGuid);
                    }
                }
                ScriptExportType exportType = script.GetExportType(scriptManager);
                exportTypes.Add(asset, exportType);
            }
            foreach (KeyValuePair <Object, ScriptExportType> exportType in exportTypes)
            {
                string path = scriptManager.Export(exportType.Value);
            }
            //scriptManager.ExportRest();
        }