-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: major c# build code refactor
- Loading branch information
1 parent
e04121a
commit bb1f560
Showing
13 changed files
with
1,145 additions
and
566 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
examples/unity/DemoApp/Assets/FlutterUnityIntegration/Editor/BaseBuild.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
examples/unity/DemoApp/Assets/FlutterUnityIntegration/Editor/BaseBuild.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.