Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
lanreolokoba committed Dec 4, 2022
0 parents commit 926ff13
Show file tree
Hide file tree
Showing 114 changed files with 4,115 additions and 0 deletions.
Binary file added .media/key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
305 changes: 305 additions & 0 deletions Changelog.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Changelog.md.meta

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

8 changes: 8 additions & 0 deletions Editor.meta

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

27 changes: 27 additions & 0 deletions Editor/NatCorderMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* NatCorder
* Copyright (c) 2022 NatML Inc. All rights reserved.
*/

namespace NatML.Recorders.Editor {

using UnityEditor;
using Internal;

internal static class NatCorderMenu {

private const int BasePriority = 0;

[MenuItem(@"NatML/NatCorder " + NatCorderSettings.Version, false, BasePriority)]
private static void Version () { }

[MenuItem(@"NatML/NatCorder " + NatCorderSettings.Version, true, BasePriority)]
private static bool DisableVersion () => false;

[MenuItem(@"NatML/View NatCorder Docs", false, BasePriority + 1)]
private static void OpenDocs () => Help.BrowseURL(@"https://docs.natml.ai/natcorder");

[MenuItem(@"NatML/Open a NatCorder Issue", false, BasePriority + 2)]
private static void OpenIssue () => Help.BrowseURL(@"https://github.com/natmlx/NatCorder");
}
}
11 changes: 11 additions & 0 deletions Editor/NatCorderMenu.cs.meta

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

74 changes: 74 additions & 0 deletions Editor/NatCorderProjectSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* NatCorder
* Copyright (c) 2022 NatML Inc. All rights reserved.
*/

namespace NatML.Recorders.Editor {

using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEditor;
using Hub;
using Hub.Internal;
using Hub.Requests;
using Internal;

[FilePath(@"ProjectSettings/NatCorder.asset", FilePathAttribute.Location.ProjectFolder)]
internal sealed class NatCorderProjectSettings : ScriptableSingleton<NatCorderProjectSettings> {

#region --Client API--
/// <summary>
/// NatCorder settings from the current project settings.
/// </summary>
internal static NatCorderSettings CurrentSettings {
get {
var settings = ScriptableObject.CreateInstance<NatCorderSettings>();
settings.token = SessionState.GetString(tokenKey, string.Empty);
return settings;
}
}

/// <summary>
/// Create NatCorder settings.
/// </summary>
/// <param name="platform">NatML platform identifier.</param>
/// <param name="bundle">NatML app bundle.</param>
/// <param name="accessKey">NatML access key.</param>
internal static NatCorderSettings CreateSettings (string platform, string bundle, string accessKey) {
var input = new CreateMediaSessionRequest.Input {
api = NatCorderSettings.API,
version = NatCorderSettings.Version,
platform = platform,
bundle = bundle,
};
var session = Task.Run(() => NatMLHub.CreateMediaSession(input, accessKey)).Result;
var settings = ScriptableObject.CreateInstance<NatCorderSettings>();
settings.token = session.token;
return settings;
}
#endregion


#region --Operations--
private static string tokenKey => $"{NatCorderSettings.API}.token";

[InitializeOnLoadMethod]
private static void OnLoad () {
NatCorderSettings.Instance = CurrentSettings;
HubSettings.OnUpdateSettings += OnUpdateHubSettings;
}

private static void OnUpdateHubSettings (HubSettings hubSettings) {
try {
var settings = CreateSettings(NatMLHub.CurrentPlatform, NatMLHub.GetEditorBundle(), hubSettings.AccessKey);
SessionState.SetString(tokenKey, settings.token);
} catch (Exception ex) {
SessionState.EraseString(tokenKey);
Debug.LogWarning($"NatCorder Error: {ex.InnerException.Message}");
}
NatCorderSettings.Instance = CurrentSettings;
}
#endregion
}
}
11 changes: 11 additions & 0 deletions Editor/NatCorderProjectSettings.cs.meta

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

50 changes: 50 additions & 0 deletions Editor/NatCorderSettingsEmbed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* NatCorder
* Copyright (c) 2022 NatML Inc. All rights reserved.
*/

namespace NatML.Recorders.Editor {

using System;
using System.IO;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using Hub;
using Hub.Editor;
using Hub.Internal;
using Internal;

internal sealed class NatCorderSettingsEmbed : BuildEmbedHelper<NatCorderSettings> {

protected override BuildTarget[] SupportedTargets => new [] {
BuildTarget.Android,
BuildTarget.iOS,
BuildTarget.StandaloneOSX,
BuildTarget.StandaloneWindows,
BuildTarget.StandaloneWindows64,
BuildTarget.WebGL,
};
private const string CachePath = @"Assets/NMLBuildCache";

protected override NatCorderSettings[] CreateEmbeds (BuildReport report) {
var platform = ToPlatform(report.summary.platform);
var bundle = BundleOverride?.identifier ?? NatMLHub.GetAppBundle(platform);
var accessKey = HubSettings.Instance.AccessKey;
var settings = NatCorderProjectSettings.CurrentSettings;
try {
settings = NatCorderProjectSettings.CreateSettings(platform, bundle, accessKey);
} catch(Exception ex) {
Debug.LogWarning($"NatCorder Error: {ex.InnerException.Message}");
}
Directory.CreateDirectory(CachePath);
AssetDatabase.CreateAsset(settings, $"{CachePath}/NatCorder.asset");
return new [] { settings };
}

protected override void ClearEmbeds (BuildReport report) {
base.ClearEmbeds(report);
AssetDatabase.DeleteAsset(CachePath);
}
}
}
11 changes: 11 additions & 0 deletions Editor/NatCorderSettingsEmbed.cs.meta

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

19 changes: 19 additions & 0 deletions Editor/NatML.Recorders.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "NatML.Recorders.Editor",
"references": [
"NatML.Hub",
"NatML.Hub.Editor",
"NatML.Recorders"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Editor/NatML.Recorders.Editor.asmdef.meta

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

Loading

0 comments on commit 926ff13

Please sign in to comment.