Ejemplo n.º 1
0
        public static GameCollection CreateGameCollection()
        {
            var layoutInfo = new LayoutInfo(new Version(), Platform.StandaloneWin64Player, TransferInstructionFlags.NoTransferInstructionFlags);
            var layout     = new AssetLayout(layoutInfo);
            var parameters = new GameCollection.Parameters(layout);

            parameters.ScriptBackend = ScriptingBackend.Mono;
            var gameCollection = new GameCollection(parameters);

            return(gameCollection);
        }
Ejemplo n.º 2
0
        private static object LoadScheme(FileScheme scheme)
        {
            object file = null;

            if (scheme is SerializedFileScheme serializedFileScheme)
            {
                var platform = serializedFileScheme.Metadata != null &&
                               serializedFileScheme.Metadata.TargetPlatform != 0 ?
                               serializedFileScheme.Metadata.TargetPlatform
                                        : Platform.StandaloneWin64Player;
                var version = serializedFileScheme.Metadata != null ?
                              serializedFileScheme.Metadata.UnityVersion
                                        : new Version();
                var layoutInfo = new LayoutInfo(version, platform, serializedFileScheme.Flags);
                var layout     = new AssetLayout(layoutInfo);
                var parameters = new GameCollection.Parameters(layout);
                var collection = new GameCollection(parameters);
                file = Util.CreateInstance <SerializedFile>(collection, scheme);
                typeof(SerializedFile).GetMethod("ReadData", AllBindingFlags)
                .Invoke(file, new object[] { serializedFileScheme.Stream });
            }
            if (scheme is BundleFileScheme bundleFileScheme)
            {
                file = Util.CreateInstance <BundleFile>(scheme);
                AddScheme((BundleFile)file, bundleFileScheme);
            }
            if (scheme is ArchiveFileScheme archiveFileScheme)
            {
                file = Util.CreateInstance <ArchiveFile>(scheme);
                AddScheme((ArchiveFile)file, archiveFileScheme);
            }
            if (scheme is WebFileScheme webFileScheme)
            {
                file = Util.CreateInstance <WebFile>(scheme);
                AddScheme((WebFile)file, webFileScheme);
            }
            if (scheme is ResourceFileScheme resourceFileScheme)
            {
                file = Util.CreateInstance <ResourceFile>(scheme);
            }
            return(file);
        }
Ejemplo n.º 3
0
        public static object LoadFile(string filepath)
        {
            var    scheme = GameCollection.LoadScheme(filepath, Path.GetFileName(filepath));
            object file   = null;

            if (scheme is SerializedFileScheme serializedFileScheme)
            {
                var platform = serializedFileScheme.Metadata != null &&
                               serializedFileScheme.Metadata.Hierarchy.Platform != 0 ?
                               serializedFileScheme.Metadata.Hierarchy.Platform
                                        : Platform.StandaloneWin64Player;
                var version = serializedFileScheme.Metadata != null ?
                              serializedFileScheme.Metadata.Hierarchy.Version
                                        : new Version();
                var layoutInfo = new LayoutInfo(version, platform, serializedFileScheme.Flags);
                var layout     = new AssetLayout(layoutInfo);
                var parameters = new GameCollection.Parameters(layout);
                var collection = new GameCollection(parameters);
                file = Util.CreateInstance <SerializedFile>(collection, scheme);
                typeof(SerializedFile).GetMethod("ReadData", AllBindingFlags)
                .Invoke(file, new object[] { serializedFileScheme.Stream });
            }
            if (scheme is BundleFileScheme bundleFileScheme)
            {
                file = Util.CreateInstance <BundleFile>(scheme);
            }
            if (scheme is ArchiveFileScheme archiveFileScheme)
            {
                file = Util.CreateInstance <ArchiveFile>(scheme);
            }
            if (scheme is WebFileScheme webFileScheme)
            {
                file = Util.CreateInstance <WebFile>(scheme);
            }
            if (scheme is ResourceFileScheme resourceFileScheme)
            {
                file = Util.CreateInstance <ResourceFile>(scheme);
            }
            scheme.Dispose();
            return(file);
        }