Skip to content

Commit

Permalink
build: change the default AssetLoader type (#1247)
Browse files Browse the repository at this point in the history
* build: change the default AssetLoader type to StreamingAssets

* ci: set Local to AssetLoader Type when exporting packages
  • Loading branch information
homuler authored Aug 13, 2024
1 parent e9b1fe4 commit ab78d5c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
34 changes: 15 additions & 19 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,7 @@ jobs:
run: |
rm MediaPipeUnityPlugin-all.zip
- name: Export tarball
run: |
cd Packages/com.github.homuler.mediapipe
npm pack
mv com.github.homuler.mediapipe-*.tgz ../..
- name: Upload the tarball package
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-tarball
path: |
com.github.homuler.mediapipe-*.tgz
retention-days: 7

# avoid "No space left on device" error
- name: Remove uploaded files to free up space
run: |
rm com.github.homuler.mediapipe-*.tgz
# NOTE: this step will overwrite AppSettings.asset
- name: Export unitypackage
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
run: |
Expand All @@ -316,6 +298,20 @@ jobs:
*.unitypackage
retention-days: 7

- name: Export tarball
run: |
cd Packages/com.github.homuler.mediapipe
npm pack
mv com.github.homuler.mediapipe-*.tgz ../..
- name: Upload the tarball package
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-tarball
path: |
com.github.homuler.mediapipe-*.tgz
retention-days: 7

clean:
runs-on: ubuntu-latest
needs:
Expand Down
13 changes: 13 additions & 0 deletions Assets/MediaPipeUnity/Editor/PackageExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public static class PackageExporter
[MenuItem("Tools/Export Unitypackage")]
public static void Export()
{
// Default Asset Loader Type is Local
OverwriteAssetLoaderType(Mediapipe.Unity.Sample.AppSettings.AssetLoaderType.Local);

var packageRoot = Path.Combine(Application.dataPath, "..", "Packages", "com.github.homuler.mediapipe");
var version = GetVersion(packageRoot);

Expand Down Expand Up @@ -101,6 +104,16 @@ private static string GetVersion(string packagePath)
return version;
}

private static void OverwriteAssetLoaderType(Mediapipe.Unity.Sample.AppSettings.AssetLoaderType assetLoaderType)
{
var appSettings = AssetDatabase.LoadAssetAtPath<Mediapipe.Unity.Sample.AppSettings>("Assets/MediaPipeUnity/Samples/Scenes/AppSettings.asset");
appSettings.assetLoaderType = assetLoaderType;

EditorUtility.SetDirty(appSettings);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}

public class PackageJson
{
public string name;
Expand Down
6 changes: 5 additions & 1 deletion Assets/MediaPipeUnity/Samples/Common/Scripts/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public enum AssetLoaderType

public ImageSourceType defaultImageSource => _defaultImageSource;
public InferenceMode preferableInferenceMode => _preferableInferenceMode;
public AssetLoaderType assetLoaderType => _assetLoaderType;
public AssetLoaderType assetLoaderType
{
get => _assetLoaderType;
set => _assetLoaderType = value;
}
public Logger.LogLevel logLevel => _logLevel;

public void ResetGlogFlags()
Expand Down
2 changes: 1 addition & 1 deletion Assets/MediaPipeUnity/Samples/Scenes/AppSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
_defaultImageSource: 0
_preferableInferenceMode: 0
_assetLoaderType: 2
_assetLoaderType: 0
_logLevel: 5
_glogMinloglevel: 0
_glogStderrthreshold: 2
Expand Down

0 comments on commit ab78d5c

Please sign in to comment.