-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: export unitypackage + tarball (#531)
* feat: export as a unitypackage * lint * rename Mediapipe -> MediaPipeUnity * fix version * move the FontAwesome directory * export sample scenes and include dependencies * doc: add Third Party Notices * feat: run each sample scene directly (#528) * refactor: add StartSceneController * choose which Bootstrap instance to use * remove Hello World * attach Bootstrap to Solution objects * use LocalAssetLoader by default * fix: missing scripts * parse package.json * npm pack
- Loading branch information
Showing
359 changed files
with
3,847 additions
and
4,530 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
/[Cc]ode[Cc]overage/ | ||
*.csproj | ||
*.sln | ||
*.unitypackage | ||
|
||
*.aar | ||
*.bc | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,29 @@ | ||
// Copyright (c) 2021 homuler | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
using System.IO; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
#if UNITY_EDITOR | ||
|
||
public class CreateAssetBundles | ||
{ | ||
[MenuItem("Assets/Build AssetBundles")] | ||
internal static void BuildAllAssetBundles() | ||
{ | ||
var assetBundleDirectory = Application.streamingAssetsPath; | ||
if (!Directory.Exists(assetBundleDirectory)) | ||
{ | ||
var _ = Directory.CreateDirectory(assetBundleDirectory); | ||
} | ||
_ = BuildPipeline.BuildAssetBundles(assetBundleDirectory, | ||
BuildAssetBundleOptions.None, | ||
EditorUserBuildSettings.activeBuildTarget); | ||
} | ||
} | ||
|
||
#endif |
File renamed without changes.
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,140 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2019 Yoshifumi Kawai / Cysharp, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#if UNITY_EDITOR | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
public static class PackageExporter | ||
{ | ||
[MenuItem("Tools/Export Unitypackage")] | ||
public static void Export() | ||
{ | ||
var packageRoot = Path.Combine(Application.dataPath, "..", "Packages", "com.github.homuler.mediapipe"); | ||
var version = GetVersion(packageRoot); | ||
|
||
var fileName = string.IsNullOrEmpty(version) ? "MediaPipeUnity.unitypackage" : $"MediaPipeUnity.{version}.unitypackage"; | ||
var exportPath = "./" + fileName; | ||
|
||
var pluginAssets = EnumerateAssets(Path.Combine("Packages", "com.github.homuler.mediapipe")); // export all the files | ||
var sampleAssets = EnumerateAssets(Path.Combine("Assets", "MediaPipeUnity", "Samples"), new string[] { ".cs", ".unity" }) | ||
.Where(x => Path.GetFileName(x) != "Start Scene.unity"); // exclude the 'Start Scene' | ||
var assets = pluginAssets.Concat(sampleAssets).ToArray(); | ||
|
||
Debug.Log("Export below files" + Environment.NewLine + string.Join(Environment.NewLine, assets)); | ||
|
||
AssetDatabase.ExportPackage( | ||
assets, | ||
exportPath, | ||
ExportPackageOptions.IncludeDependencies); | ||
|
||
Debug.Log("Export complete: " + Path.GetFullPath(exportPath)); | ||
} | ||
|
||
private static IEnumerable<string> EnumerateAssets(string path) | ||
{ | ||
var projectRoot = Path.Combine(Application.dataPath, ".."); | ||
var assetRoot = Path.Combine(projectRoot, path); | ||
|
||
return Directory.EnumerateFiles(assetRoot, "*", SearchOption.AllDirectories) | ||
.Select(x => path + x.Replace(assetRoot, "").Replace(@"\", "/")); | ||
} | ||
|
||
private static IEnumerable<string> EnumerateAssets(string path, string[] extensions) | ||
{ | ||
return EnumerateAssets(path).Where(x => Array.IndexOf(extensions, Path.GetExtension(x)) >= 0); | ||
} | ||
|
||
private static string GetVersion(string packagePath) | ||
{ | ||
var version = Environment.GetEnvironmentVariable("UNITY_PACKAGE_VERSION"); | ||
var packageJsonPath = Path.Combine(packagePath, "package.json"); | ||
|
||
if (File.Exists(packageJsonPath)) | ||
{ | ||
var packageJson = JsonUtility.FromJson<PackageJson>(File.ReadAllText(packageJsonPath)); | ||
|
||
if (!string.IsNullOrEmpty(version)) | ||
{ | ||
if (packageJson.version != version) | ||
{ | ||
var msg = $"package.json and env version are mismatched. UNITY_PACKAGE_VERSION:{version}, package.json:{packageJson.version}"; | ||
|
||
if (Application.isBatchMode) | ||
{ | ||
Console.WriteLine(msg); | ||
Application.Quit(1); | ||
} | ||
|
||
throw new Exception("package.json and env version are mismatched."); | ||
} | ||
} | ||
|
||
version = packageJson.version; | ||
} | ||
|
||
return version; | ||
} | ||
|
||
public class PackageJson | ||
{ | ||
public string name; | ||
public string version; | ||
public string displayName; | ||
public string description; | ||
public string unity; | ||
public Author author; | ||
public string changelogUrl; | ||
// public Dictionary<string, string> dependencies; | ||
public string documentationUrl; | ||
public bool hideInEditor; | ||
public List<string> keywords; | ||
public string license; | ||
public string licenseUrl; | ||
public List<Sample> samples; | ||
public string type; | ||
public string unityRelease; | ||
|
||
[Serializable] | ||
public class Author | ||
{ | ||
public string name; | ||
public string email; | ||
public string url; | ||
} | ||
|
||
[Serializable] | ||
public class Sample | ||
{ | ||
public string displayName; | ||
public string description; | ||
public string path; | ||
} | ||
} | ||
} | ||
|
||
#endif |
2 changes: 1 addition & 1 deletion
2
...cenes/Hello World/HelloWorldGraph.cs.meta → ...aPipeUnity/Editor/PackageExporter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
Assets/MediaPipeUnity/Samples/Common/Scripts/ImageSource/ImageSourceType.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,13 @@ | ||
// Copyright (c) 2021 homuler | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
public enum ImageSourceType | ||
{ | ||
WebCamera = 0, | ||
Image = 1, | ||
Video = 2, | ||
Unknown = 3, | ||
} |
2 changes: 1 addition & 1 deletion
2
...es/Hello World/HelloWorldSolution.cs.meta → ...ripts/ImageSource/ImageSourceType.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.