Skip to content

Commit

Permalink
refactor: major c# build code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
juicycleff committed Jan 15, 2024
1 parent e04121a commit bb1f560
Show file tree
Hide file tree
Showing 13 changed files with 1,145 additions and 566 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;

// uncomment for addressables
//using UnityEditor.AddressableAssets;
//using UnityEditor.AddressableAssets.Settings;

namespace FlutterUnityIntegration.Editor
{
public record FuwBuildOptions
{
public string OutputDir { get; set; }
public string BuildPath { get; set; }
public bool PackageMode { get; set; }
public bool Release { get; set; }
}

public class BaseBuild
{
public string ProjectPath;
public string APKPath;
public string OutputDir { get; set; }
public string BuildDir { get; set; }

public void Bootstrap(FuwBuildOptions options)
{
ProjectPath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));
APKPath = Path.Combine(ProjectPath, "Builds/" + Application.productName + ".apk");
OutputDir = Path.GetFullPath(Path.Combine(ProjectPath, options.OutputDir));
}

protected void Copy(string source, string destinationPath)
{
if (Directory.Exists(destinationPath))
Directory.Delete(destinationPath, true);

Directory.CreateDirectory(destinationPath);

foreach (var dirPath in Directory.GetDirectories(source, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(source, destinationPath));

foreach (var newPath in Directory.GetFiles(source, "*.*",
SearchOption.AllDirectories))
File.Copy(newPath, newPath.Replace(source, destinationPath), true);
}

protected string[] GetEnabledScenes()
{
var scenes = EditorBuildSettings.scenes
.Where(s => s.enabled)
.Select(s => s.path)
.ToArray();

return scenes;
}

protected void ExportAddressables()
{
// Debug.Log("Start building player content (Addressables)");
// Debug.Log("BuildAddressablesProcessor.PreExport start");
//
// AddressableAssetSettings.CleanPlayerContent(
// AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder);
//
// AddressableAssetProfileSettings profileSettings = AddressableAssetSettingsDefaultObject.Settings.profileSettings;
// string profileId = profileSettings.GetProfileId("Default");
// AddressableAssetSettingsDefaultObject.Settings.activeProfileId = profileId;
//
// AddressableAssetSettings.BuildPlayerContent();
// Debug.Log("BuildAddressablesProcessor.PreExport done");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bb1f560

Please sign in to comment.