Skip to content

Commit ae837ca

Browse files
committed
FrameRecorder detects FrameCapturer presence and auto-imports FC integration package.
1 parent 36a482a commit ae837ca

File tree

8 files changed

+111
-66
lines changed

8 files changed

+111
-66
lines changed

source/FrameRecorder/Integrations/FrameCapturer/Editor/FrameCapturerPackager.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class FrameCapturerPackager : ScriptableObject {}
1313
class FrameCapturerPackagerInternal : ScriptableObject
1414
{
1515
const string k_PackageName = "FrameCapturerRecorders";
16-
const string k_WitnessClass = "Recorder";
17-
const string k_WitnessNamespace = "UnityEngine.FrameRecorder";
16+
const string k_WitnessClass = "fcAPI";
17+
const string k_WitnessNamespace = "UTJ.FrameCapturer";
1818

1919
static string m_PkgFile;
2020
static string m_ScriptFile;
@@ -25,26 +25,38 @@ public static string GeneratePackage()
2525
{
2626
Path.Combine(FRPackagerPaths.GetIntegrationPath(), "FrameCapturer/Recorders"),
2727
};
28-
var destFile = Path.Combine(FRPackagerPaths.GetIntegrationPackagePath(), k_PackageName + ".unitypackage");
28+
29+
var destDir = FRPackagerPaths.GetIntegrationPackagePath();
30+
if (!Directory.Exists(destDir))
31+
Directory.CreateDirectory(destDir);
32+
33+
var destFile = Path.Combine(destDir, k_PackageName + ".unitypackage");
2934
AssetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
3035
Debug.Log("Generated package: " + destFile);
3136

3237
return destFile;
3338
}
39+
40+
static bool AutoExtractAllowed
41+
{
42+
get { return !AppDomain.CurrentDomain.GetAssemblies().Any(x => x.GetTypes().Any(y => y.Name == "FRPackager" && y.Namespace == "UnityEditor.FrameRecorder")); }
43+
}
44+
45+
static bool FrameCapturerPresent
46+
{
47+
get { return AppDomain.CurrentDomain.GetAssemblies().Any(x => x.GetTypes().Any(y => y.Name == k_WitnessClass && y.Namespace == k_WitnessNamespace)); }
48+
}
3449

3550
static FrameCapturerPackagerInternal() // auto extracts
3651
{
37-
var havePostProcessing = AppDomain.CurrentDomain.GetAssemblies()
38-
.Any(x => x.GetTypes().Any(y => y.Name == k_WitnessClass && y.Namespace == k_WitnessNamespace));
39-
40-
if (havePostProcessing)
52+
if(AutoExtractAllowed && FrameCapturerPresent )
4153
{
42-
m_PkgFile = Path.Combine( FRPackagerPaths.GetIntegrationPackagePath(), "../" + k_PackageName + ".unityPackage" );
54+
m_PkgFile = Path.Combine( FRPackagerPaths.GetIntegrationPackagePath(), k_PackageName + ".unityPackage" );
4355
m_ScriptFile = Path.Combine(FRPackagerPaths.GetIntegrationPath(), "FrameCapturer/Recorders/BaseFCRecorderSettings.cs");
4456
if ( File.Exists(m_PkgFile) &&
4557
(!File.Exists(m_ScriptFile) || File.GetLastWriteTime(m_PkgFile) > File.GetLastWriteTime(m_ScriptFile)))
4658
{
47-
Debug.Log("PostProcessing asset detected - Importing FrameCapturer's Recorders");
59+
Debug.Log("Importing FrameCapturer's Recorders: Processing...");
4860
AssetDatabase.importPackageCompleted += AssetDatabase_importPackageCompleted;
4961
AssetDatabase.importPackageFailed += AssetDatabase_importPackageFailed;
5062
AssetDatabase.importPackageCancelled += RemovePackageImportCallbacks;
@@ -59,7 +71,7 @@ static void AssetDatabase_importPackageCompleted(string packageName)
5971
{
6072
File.SetLastWriteTime(m_ScriptFile, File.GetLastWriteTime(m_PkgFile));
6173
RemovePackageImportCallbacks(k_PackageName);
62-
Debug.LogError("FrameRecorder enabled/updated integration package" + k_PackageName );
74+
Debug.Log("Importing FrameCapturer's Recorders: Done.");
6375
}
6476
}
6577

source/FrameRecorder/Packager/Editor/FRPackager.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.IO;
2+
using UnityEngine;
3+
4+
namespace UnityEditor.FrameRecorder
5+
{
6+
class FRPackagerPaths : ScriptableObject
7+
{
8+
public static string GetFrameRecorderRootPath()
9+
{
10+
ScriptableObject dummy = ScriptableObject.CreateInstance<FRPackagerPaths>();
11+
string path = Application.dataPath + AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(dummy)).Substring("Assets".Length);
12+
13+
path = path.Substring(path.IndexOf("Assets"));
14+
path = path.Substring(0, path.LastIndexOf('/'));
15+
path = path.Substring(0, path.LastIndexOf('/'));
16+
path = path.Substring(0, path.LastIndexOf('/'));
17+
return path;
18+
}
19+
20+
public static string GetIntegrationPath()
21+
{
22+
return Path.Combine(GetFrameRecorderRootPath(), "Integrations");
23+
}
24+
25+
public static string GetIntegrationPackagePath()
26+
{
27+
return Path.Combine(GetIntegrationPath(), "SelfExtractPackages");
28+
}
29+
}
30+
}

source/FrameRecorder/Packager/Editor/FRPackagerPaths.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/FrameRecorder/Packager/Private.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/FrameRecorder/Packager/Private/Editor.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.IO;
2+
using UnityEngine;
3+
4+
5+
namespace UnityEditor.FrameRecorder
6+
{
7+
static class FRPackager
8+
{
9+
const string k_PackageName = "GenericFrameFrameRecorder";
10+
11+
[MenuItem("Assets/FrameRecorder - Generate Package")]
12+
static void GeneratePackage()
13+
{
14+
var rootPath = FRPackagerPaths.GetFrameRecorderRootPath();
15+
16+
string[] files = new string[]
17+
{
18+
Path.Combine(rootPath, "Core" ),
19+
Path.Combine(rootPath, "Inputs" ),
20+
Path.Combine(rootPath, "Recorders" ),
21+
Path.Combine(rootPath, "Packager/Editor" ),
22+
Path.Combine(rootPath, "Integrations/FrameCapturer/Editor" ), FRPackagerPaths.GetIntegrationPackagePath(),
23+
};
24+
var destFile = k_PackageName + ".unitypackage";
25+
AssetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
26+
Debug.Log("Generated package: " + destFile);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)