GithubHelp home page GithubHelp logo

Comments (1)

ds5678 avatar ds5678 commented on September 25, 2024

I have a general idea of how I would want this implemented. There's three parts.

Infrastructure

https://github.com/AssetRipper/AssetRipper/blob/49e9b98a1b1c1b994c26fc4ff431d4bbf017f8f4/Source/AssetRipper.Assets/Bundles/GameBundle.FromPaths.cs#L21C2-L21C211

could be changed to

public static GameBundle FromPaths(IEnumerable<string> paths, AssetFactoryBase assetFactory, IFileLoader? fileLoader = null)

with the following implementations:

public interface IFileLoader
{
    IDependencyProvider? DependencyProvider => null;
    IResourceProvider? ResourceProvider => null;
    UnityVersion DefaultVersion => default;
    void OnCreated(GameBundle gameBundle, AssetFactoryBase assetFactory) { }
    void OnPathsLoaded(GameBundle gameBundle, AssetFactoryBase assetFactory) { }
    void OnDependenciesInitialized(GameBundle gameBundle, AssetFactoryBase assetFactory) { }
}
public record class DefaultFileLoader(IDependencyProvider? DependencyProvider = null, IResourceProvider? ResourceProvider = null, UnityVersion DefaultVersion = default)
{
    public virtual void OnCreated(GameBundle gameBundle, AssetFactoryBase assetFactory) { }
    public virtual void OnPathsLoaded(GameBundle gameBundle, AssetFactoryBase assetFactory) { }
    public virtual void OnDependenciesInitialized(GameBundle gameBundle, AssetFactoryBase assetFactory) { }
}

However, I'm not fond of the IFileLoader name and am very open to alternative naming suggestions.

Injection

//Create an internal or private nested class that inherits from DefaultFileLoader in the AssetRipper.Import project
private sealed record class MyCustomFileLoader : DefaultFileLoader
{
    private sealed class InjectedEngineCollection : VirtualAssetCollection
    {
        //Flags should be TransferInstructionFlags.SerializeGameRelease | TransferInstructionFlags.IsBuiltinResourcesFile

        //AssetCollection.AddAsset needs to be changed private protected -> protected

        //https://github.com/AssetRipper/AssetRipper/blob/3fa347a3deef9d8ea1c6f7a46daf4fab2e818d2a/Source/AssetRipper.Assets/Collections/VirtualAssetCollection.cs#L23-L56
        //That can all be moved to ProcessedAssetCollection
    }

    private sealed class InjectedEngineBundle : VirtualBundle<InjectedEngineCollection>
    {
        public InjectedEngineBundle() => Name = "Generated Engine Collections";
    }

    public override void OnPathsLoaded(GameBundle gameBundle, AssetFactoryBase assetFactory)
    {
        //Check if "unity default resources" or "unity_default_resources" exists in the project. The same for "unity_builtin_extra" / "unity builtin extra"
        //If not exist, add a new InjectedEngineBundle
        //Inject missing engine collections to that bundle. Use the maximum Unity version of the project
        //Load the appropriate engine resource data from the source generation assembly
        //Foreach entry in the resource data, create a new asset with the correct type id, path id, and ideally name
    }
}

Export

The engine asset exporter should be modified to recognize the engine files by name when an asset is assessed. If recognized, it will export the asset without checking any properties.

from assetripper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.