123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848 |
- #if UNITY_EDITOR
- #if UNITY_5_4_OR_NEWER || (UNITY_5 && !UNITY_5_0)
- #define AVPRO_MOVIECAPTURE_WINDOWTITLE_51
- #define AVPRO_MOVIECAPTURE_GRAPHICSDEVICETYPE_51
- #endif
- #if UNITY_5_4_OR_NEWER || (UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2)
- #define AVPRO_MOVIECAPTURE_SCENEMANAGER_53
- #endif
- #if UNITY_5_4_OR_NEWER || UNITY_5
- #define AVPRO_MOVIECAPTURE_DEFERREDSHADING
- #endif
- using UnityEngine;
- using UnityEditor;
- //-----------------------------------------------------------------------------
- // Copyright 2012-2017 RenderHeads Ltd. All rights reserved.
- //-----------------------------------------------------------------------------
- namespace RenderHeads.Media.AVProMovieCapture.Editor
- {
- /// <summary>
- /// Creates a dockable window in Unity that can be used for handy in-editor capturing
- /// </summary>
- public class CaptureEditorWindow : EditorWindow
- {
- private const string TempGameObjectName = "Temp_MovieCapture";
- private const string SettingsPrefix = "AVProMovieCapture.EditorWindow.";
- private static bool _isTrialVersion = false;
- private CaptureBase _capture;
- private CaptureFromScreen _captureScreen;
- private CaptureFromCamera _captureCamera;
- private CaptureFromCamera360 _captureCamera360;
- private CaptureFromCamera360ODS _captureCamera360ODS;
- private static bool _isCreated = false;
- private static bool _isInit = false;
- private static bool _isFailedInit = false;
- private static bool _showAlpha = false;
- private static string[] _videoCodecNames = new string[0];
- private static string[] _audioCodecNames = new string[0];
- private static string[] _audioDeviceNames = new string[0];
- private static bool[] _videoCodecConfigurable = new bool[0];
- private static bool[] _audioCodecConfigurable = new bool[0];
- private readonly string[] _downScales = { "Original", "Half", "Quarter", "Eighth", "Sixteenth", "Custom" };
- private readonly string[] _captureModes = { "Realtime Capture", "Offline Render" };
- private readonly string[] _outputFolders = { "Project Folder", "Persistent Data Folder", "Absolute Folder" };
- private readonly string[] _sourceNames = { "Screen", "Camera", "Camera 360 (fast Stereo)", "Camera 360 (accurate ODS Stereo)" };
- private enum SourceType
- {
- Screen,
- Camera,
- Camera360,
- Camera360ODS,
- }
- [SerializeField]
- private SourceType _sourceType = SourceType.Screen;
- private bool _startPaused = false;
- private Camera _cameraNode;
- private string _cameraName;
- private int _captureModeIndex;
- private int _outputFolderIndex;
- [SerializeField]
- private CaptureBase.OutputType _outputType = CaptureBase.OutputType.VideoFile;
- private bool _autoFilenamePrefixFromSceneName = true;
- private string _autoFilenamePrefix = "capture";
- private string _autoFilenameExtension = "avi";
- private string _outputFolderRelative = string.Empty;
- private string _outputFolderAbsolute = string.Empty;
- private bool _appendTimestamp = true;
- [SerializeField]
- private string _namedPipePath = @"\\.\pipe\pipename";
- private int _downScaleIndex;
- private int _downscaleX;
- private int _downscaleY;
- private bool _captureMouseCursor = false;
- private Texture2D _mouseCursorTexture = null;
- [SerializeField]
- private CaptureBase.Resolution _renderResolution = CaptureBase.Resolution.Original;
- private Vector2 _renderSize;
- [SerializeField]
- private int _renderAntiAliasing;
- [SerializeField]
- private bool _useContributingCameras = true;
- [SerializeField]
- private CaptureBase.FrameRate _frameRate = CaptureBase.FrameRate.Thirty;
- private bool _supportAlpha = false;
- private bool _useMediaFoundationH264 = false;
- private int _videoCodecIndex;
- private bool _captureAudio;
- private int _audioCodecIndex;
- private int _audioDeviceIndex;
- private Vector2 _scroll = Vector2.zero;
- private bool _queueStart;
- private int _queueConfigureVideoCodec = -1;
- private int _queueConfigureAudioCodec = -1;
- private bool _useMotionBlur = false;
- private int _motionBlurSampleCount = 16;
- private int _cubemapResolution = 2048;
- private int _cubemapDepth = 24;
- private int _cubemapStereoPacking = 0;
- private float _cubemapStereoIPD = 0.064f;
- [SerializeField]
- private StopMode _stopMode = StopMode.None;
- private int _stopFrames = 300;
- private float _stopSeconds = 10f;
- private SerializedProperty _propSourceType;
- private SerializedProperty _propOutputType;
- private SerializedProperty _propNamedPipePath;
- private SerializedProperty _propFrameRate;
- private SerializedProperty _propStopMode;
- private SerializedProperty _propRenderResolution;
- private SerializedProperty _propUseContributingCameras;
- private SerializedProperty _propStereoIPD;
- private SerializedProperty _propRenderAntiAliasing;
- private SerializedProperty _propOdsCamera;
- private SerializedProperty _propOdsIPD;
- private SerializedProperty _propOdsPixelSliceSize;
- private SerializedProperty _propOdsPaddingSize;
- private SerializedProperty _propOdsCameraClearMode;
- private SerializedProperty _propOdsCameraClearColor;
- [SerializeField]
- private CaptureFromCamera360ODS.Settings _odsSettings = new CaptureFromCamera360ODS.Settings();
- // TODO: we should actually be saving these parameters per-scene...
- private long _lastFileSize;
- private uint _lastEncodedMinutes;
- private uint _lastEncodedSeconds;
- private uint _lastEncodedFrame;
- private int _selectedTool;
- private int _selectedConfigTool;
- private bool _expandSectionTrial = true;
- private static Texture2D _icon;
- private string _pluginVersionWarningText = string.Empty;
- private SerializedObject _so;
- private const string LinkPluginWebsite = "http://renderheads.com/product/av-pro-movie-capture/";
- private const string LinkForumPage = "http://forum.unity3d.com/threads/released-avpro-movie-capture.120717/";
- private const string LinkAssetStorePage = "https://www.assetstore.unity3d.com/#!/content/2670";
- private const string LinkFreeAssetStorePage = "https://www.assetstore.unity3d.com/#!/content/97562";
- private const string LinkEmailSupport = "mailto:unitysupport@renderheads.com";
- private const string LinkUserManual = "http://downloads.renderheads.com/docs/UnityAVProMovieCapture.pdf";
- private const string SupportMessage = "If you are reporting a bug, please include any relevant files and details so that we may remedy the problem as fast as possible.\n\n" +
- "Essential details:\n" +
- "+ Error message\n" +
- " + The exact error message\n" +
- " + The console/output log if possible\n" +
- "+ Development environment\n" +
- " + Unity version\n" +
- " + Development OS version\n" +
- " + AVPro Movie Capture plugin version\n";
- [MenuItem("Window/Open AVPro Movie Capture..")]
- public static void Init()
- {
- if (_isInit || _isCreated)
- {
- CaptureEditorWindow window = (CaptureEditorWindow)EditorWindow.GetWindow(typeof(CaptureEditorWindow));
- window.Close();
- return;
- }
- _isCreated = true;
- // Get existing open window or if none, make a new one:
- CaptureEditorWindow window2 = (CaptureEditorWindow)EditorWindow.GetWindow(typeof(CaptureEditorWindow));
- if (window2 != null)
- {
- window2.SetupWindow();
- }
- }
- public void SetupWindow()
- {
- _isCreated = true;
- if (Application.platform == RuntimePlatform.WindowsEditor)
- {
- this.minSize = new Vector2(200f, 48f);
- this.maxSize = new Vector2(340f, 620f);
- #if AVPRO_MOVIECAPTURE_WINDOWTITLE_51
- if (_icon != null)
- {
- this.titleContent = new GUIContent("Movie Capture", _icon, "AVPro Movie Capture");
- }
- else
- {
- this.titleContent = new GUIContent("Movie Capture", "AVPro Movie Capture");
- }
- #else
- this.title = "Movie Capture";
- #endif
- this.CreateGUI();
- this.LoadSettings();
- _so = new SerializedObject(this);
- if (_so == null)
- {
- Debug.LogError("[AVProMovieCapture] SO is null");
- }
- _propSourceType = _so.FindProperty("_sourceType");
- _propOutputType = _so.FindProperty("_outputType");
- _propNamedPipePath = _so.FindProperty("_namedPipePath");
- _propRenderResolution = _so.FindProperty("_renderResolution");
- _propUseContributingCameras = _so.FindProperty("_useContributingCameras");
- _propFrameRate = _so.FindProperty("_frameRate");
- _propStopMode = _so.FindProperty("_stopMode");
- _propRenderAntiAliasing = _so.FindProperty("_renderAntiAliasing");
- _propOdsIPD = _so.FindProperty("_odsSettings.ipd");
- _propOdsPixelSliceSize = _so.FindProperty("_odsSettings.pixelSliceSize");
- _propOdsPaddingSize = _so.FindProperty("_odsSettings.paddingSize");
- _propOdsCameraClearMode = _so.FindProperty("_odsSettings.cameraClearMode");
- _propOdsCameraClearColor = _so.FindProperty("_odsSettings.cameraClearColor");
- this.Repaint();
- }
- }
- private void LoadSettings()
- {
- _sourceType = (SourceType)EditorPrefs.GetInt(SettingsPrefix + "SourceType", (int)_sourceType);
- _cameraName = EditorPrefs.GetString(SettingsPrefix + "CameraName", string.Empty);
- _captureModeIndex = EditorPrefs.GetInt(SettingsPrefix + "CaptureModeIndex", 0);
- _startPaused = EditorPrefs.GetBool(SettingsPrefix + "StartPaused", false);
- _captureMouseCursor = EditorPrefs.GetBool(SettingsPrefix + "CaptureMouseCursor", false);
- string mouseCursorGuid = EditorPrefs.GetString(SettingsPrefix + "CaptureMouseTexture", string.Empty);
- if (!string.IsNullOrEmpty(mouseCursorGuid))
- {
- string mouseCursorPath = AssetDatabase.GUIDToAssetPath(mouseCursorGuid);
- if (!string.IsNullOrEmpty(mouseCursorPath))
- {
- _mouseCursorTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(mouseCursorPath, typeof(Texture2D));
- }
- }
- _outputType = (CaptureBase.OutputType)EditorPrefs.GetInt(SettingsPrefix + "OutputType", (int)_outputType);
- _namedPipePath = EditorPrefs.GetString(SettingsPrefix + "NamedPipePath", _namedPipePath);
- _autoFilenamePrefixFromSceneName = EditorPrefs.GetBool(SettingsPrefix + "AutoFilenamePrefixFromScenename", _autoFilenamePrefixFromSceneName);
- _autoFilenamePrefix = EditorPrefs.GetString(SettingsPrefix + "AutoFilenamePrefix", "capture");
- _autoFilenameExtension = EditorPrefs.GetString(SettingsPrefix + "AutoFilenameExtension", "avi");
- _appendTimestamp = EditorPrefs.GetBool(SettingsPrefix + "AppendTimestamp", true);
- _outputFolderIndex = EditorPrefs.GetInt(SettingsPrefix + "OutputFolderIndex", 0);
- _outputFolderRelative = EditorPrefs.GetString(SettingsPrefix + "OutputFolderRelative", string.Empty);
- _outputFolderAbsolute = EditorPrefs.GetString(SettingsPrefix + "OutputFolderAbsolute", string.Empty);
- _downScaleIndex = EditorPrefs.GetInt(SettingsPrefix + "DownScaleIndex", 0);
- _downscaleX = EditorPrefs.GetInt(SettingsPrefix + "DownScaleX", 1);
- _downscaleY = EditorPrefs.GetInt(SettingsPrefix + "DownScaleY", 1);
- _frameRate = (CaptureBase.FrameRate)System.Enum.Parse(typeof(CaptureBase.FrameRate), EditorPrefs.GetString(SettingsPrefix + "FrameRate", "Thirty"));
- _supportAlpha = EditorPrefs.GetBool(SettingsPrefix + "SupportAlpha", false);
- _useMediaFoundationH264 = EditorPrefs.GetBool(SettingsPrefix + "UseMediaFoundationH264", false);
- _videoCodecIndex = EditorPrefs.GetInt(SettingsPrefix + "VideoCodecIndex", 0);
- _renderResolution = (CaptureBase.Resolution)EditorPrefs.GetInt(SettingsPrefix + "RenderResolution", (int)_renderResolution);
- _renderSize.x = EditorPrefs.GetInt(SettingsPrefix + "RenderWidth", 0);
- _renderSize.y = EditorPrefs.GetInt(SettingsPrefix + "RenderHeight", 0);
- _renderAntiAliasing = EditorPrefs.GetInt(SettingsPrefix + "RenderAntiAliasing", 0);
- _useContributingCameras = EditorPrefs.GetBool(SettingsPrefix + "UseContributingCameras", true);
- _captureAudio = EditorPrefs.GetBool(SettingsPrefix + "CaptureAudio", false);
- _audioCodecIndex = EditorPrefs.GetInt(SettingsPrefix + "AudioCodecIndex", 0);
- _audioDeviceIndex = EditorPrefs.GetInt(SettingsPrefix + "AudioDeviceIndex", 0);
- _useMotionBlur = EditorPrefs.GetBool(SettingsPrefix + "UseMotionBlur", false);
- _motionBlurSampleCount = EditorPrefs.GetInt(SettingsPrefix + "MotionBlurSampleCount", 16);
- _cubemapResolution = EditorPrefs.GetInt(SettingsPrefix + "CubemapResolution", 2048);
- _cubemapDepth = EditorPrefs.GetInt(SettingsPrefix + "CubemapDepth", 24);
- _cubemapStereoPacking = EditorPrefs.GetInt(SettingsPrefix + "CubemapStereoPacking", 0);
- _cubemapStereoIPD = EditorPrefs.GetFloat(SettingsPrefix + "CubemapStereoIPD", 0.064f);
- _stopMode = (StopMode)EditorPrefs.GetInt(SettingsPrefix + "StopMode", (int)_stopMode);
- _stopFrames = EditorPrefs.GetInt(SettingsPrefix + "StopFrames", _stopFrames);
- _stopSeconds = EditorPrefs.GetFloat(SettingsPrefix + "StopSeconds", _stopSeconds);
- if (!string.IsNullOrEmpty(_cameraName))
- {
- Camera[] cameras = (Camera[])GameObject.FindObjectsOfType(typeof(Camera));
- foreach (Camera cam in cameras)
- {
- if (cam.name == _cameraName)
- {
- _cameraNode = cam;
- break;
- }
- }
- }
- // Check ranges
- if (_videoCodecIndex >= _videoCodecNames.Length)
- {
- _videoCodecIndex = 0;
- }
- if (_audioDeviceIndex >= _audioDeviceNames.Length)
- {
- _audioDeviceIndex = 0;
- _captureAudio = false;
- }
- if (_audioCodecIndex >= _audioCodecNames.Length)
- {
- _audioCodecIndex = 0;
- _captureAudio = false;
- }
- _showAlpha = EditorPrefs.GetBool(SettingsPrefix + "ShowAlphaChannel", false);
- }
- private void SaveSettings()
- {
- EditorPrefs.SetInt(SettingsPrefix + "SourceType", (int)_sourceType);
- EditorPrefs.SetString(SettingsPrefix + "CameraName", _cameraName);
- EditorPrefs.SetInt(SettingsPrefix + "CaptureModeIndex", _captureModeIndex);
- EditorPrefs.SetBool(SettingsPrefix + "CaptureMouseCursor", _captureMouseCursor);
- EditorPrefs.SetBool(SettingsPrefix + "StartPaused", _startPaused);
- string mouseCursorGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(_mouseCursorTexture));
- EditorPrefs.SetString(SettingsPrefix + "CaptureMouseTexture", mouseCursorGuid);
- EditorPrefs.SetInt(SettingsPrefix + "OutputType", (int)_outputType);
- EditorPrefs.SetString(SettingsPrefix + "NamedPipePath", _namedPipePath);
- EditorPrefs.SetBool(SettingsPrefix + "AutoFilenamePrefixFromScenename", _autoFilenamePrefixFromSceneName);
- EditorPrefs.SetString(SettingsPrefix + "AutoFilenamePrefix", _autoFilenamePrefix);
- EditorPrefs.SetString(SettingsPrefix + "AutoFilenameExtension", _autoFilenameExtension);
- EditorPrefs.SetBool(SettingsPrefix + "AppendTimestamp", _appendTimestamp);
- EditorPrefs.SetInt(SettingsPrefix + "OutputFolderIndex", _outputFolderIndex);
- EditorPrefs.SetString(SettingsPrefix + "OutputFolderRelative", _outputFolderRelative);
- EditorPrefs.SetString(SettingsPrefix + "OutputFolderAbsolute", _outputFolderAbsolute);
- EditorPrefs.SetInt(SettingsPrefix + "DownScaleIndex", _downScaleIndex);
- EditorPrefs.SetInt(SettingsPrefix + "DownScaleX", _downscaleX);
- EditorPrefs.SetInt(SettingsPrefix + "DownScaleY", _downscaleY);
- EditorPrefs.SetBool(SettingsPrefix + "SupportAlpha", _supportAlpha);
- EditorPrefs.SetBool(SettingsPrefix + "UseMediaFoundationH264", _useMediaFoundationH264);
- EditorPrefs.SetString(SettingsPrefix + "FrameRate", _frameRate.ToString());
- EditorPrefs.SetInt(SettingsPrefix + "VideoCodecIndex", _videoCodecIndex);
- EditorPrefs.SetInt(SettingsPrefix + "RenderResolution", (int)_renderResolution);
- EditorPrefs.SetInt(SettingsPrefix + "RenderWidth", (int)_renderSize.x);
- EditorPrefs.SetInt(SettingsPrefix + "RenderHeight", (int)_renderSize.y);
- EditorPrefs.SetInt(SettingsPrefix + "RenderAntiAliasing", _renderAntiAliasing);
- EditorPrefs.SetBool(SettingsPrefix + "UseContributingCameras", _useContributingCameras);
- EditorPrefs.SetBool(SettingsPrefix + "CaptureAudio", _captureAudio);
- EditorPrefs.SetInt(SettingsPrefix + "AudioCodecIndex", _audioCodecIndex);
- EditorPrefs.SetInt(SettingsPrefix + "AudioDeviceIndex", _audioDeviceIndex);
- EditorPrefs.SetBool(SettingsPrefix + "UseMotionBlur", _useMotionBlur);
- EditorPrefs.SetInt(SettingsPrefix + "MotionBlurSampleCount", _motionBlurSampleCount);
- EditorPrefs.SetInt(SettingsPrefix + "CubemapResolution", _cubemapResolution);
- EditorPrefs.SetInt(SettingsPrefix + "CubemapDepth", _cubemapDepth);
- EditorPrefs.SetInt(SettingsPrefix + "CubemapStereoPacking", _cubemapStereoPacking);
- EditorPrefs.SetFloat(SettingsPrefix + "CubemapStereoIPD", _cubemapStereoIPD);
- EditorPrefs.SetInt(SettingsPrefix + "StopMode", (int)_stopMode);
- EditorPrefs.SetInt(SettingsPrefix + "StopFrames", _stopFrames);
- EditorPrefs.SetFloat(SettingsPrefix + "StopSeconds", _stopSeconds);
- EditorPrefs.SetBool(SettingsPrefix + "ShowAlphaChannel", _showAlpha);
- }
- private void ResetSettings()
- {
- _sourceType = SourceType.Screen;
- _cameraNode = null;
- _cameraName = string.Empty;
- _captureModeIndex = 0;
- _startPaused = false;
- _captureMouseCursor = false;
- _mouseCursorTexture = null;
- _outputType = CaptureBase.OutputType.VideoFile;
- _namedPipePath = @"\\.\pipe\pipename";
- _autoFilenamePrefixFromSceneName = true;
- _autoFilenamePrefix = "capture";
- _autoFilenameExtension = "avi";
- _outputFolderIndex = 0;
- _outputFolderRelative = string.Empty;
- _outputFolderAbsolute = string.Empty;
- _appendTimestamp = true;
- _downScaleIndex = 0;
- _downscaleX = 1;
- _downscaleY = 1;
- _frameRate = CaptureBase.FrameRate.Thirty;
- _supportAlpha = false;
- _useMediaFoundationH264 = false;
- _videoCodecIndex = 0;
- _renderResolution = CaptureBase.Resolution.Original;
- _renderSize = Vector2.one;
- _renderAntiAliasing = 0;
- _useContributingCameras = true;
- _captureAudio = false;
- _audioCodecIndex = 0;
- _audioDeviceIndex = 0;
- _useMotionBlur = false;
- _motionBlurSampleCount = 16;
- _cubemapResolution = 2048;
- _cubemapDepth = 24;
- _cubemapStereoPacking = 0;
- _stopMode = StopMode.None;
- _cubemapStereoIPD = 0.064f;
- _stopFrames = 300;
- _stopSeconds = 10f;
- }
- private static CaptureBase.DownScale GetDownScaleFromIndex(int index)
- {
- CaptureBase.DownScale result = CaptureBase.DownScale.Original;
- switch (index)
- {
- case 0:
- result = CaptureBase.DownScale.Original;
- break;
- case 1:
- result = CaptureBase.DownScale.Half;
- break;
- case 2:
- result = CaptureBase.DownScale.Quarter;
- break;
- case 3:
- result = CaptureBase.DownScale.Eighth;
- break;
- case 4:
- result = CaptureBase.DownScale.Sixteenth;
- break;
- case 5:
- result = CaptureBase.DownScale.Custom;
- break;
- }
- return result;
- }
- private void Configure(CaptureBase capture)
- {
- capture._videoCodecPriority = null;
- capture._audioCodecPriority = null;
- capture._captureOnStart = false;
- capture._listVideoCodecsOnStart = false;
- capture._frameRate = _frameRate;
- capture._supportAlpha = _supportAlpha;
- capture._downScale = GetDownScaleFromIndex(_downScaleIndex);
- if (capture._downScale == CaptureBase.DownScale.Custom)
- {
- capture._maxVideoSize.x = _downscaleX;
- capture._maxVideoSize.y = _downscaleY;
- }
- capture._stopMode = _stopMode;
- capture._stopFrames = _stopFrames;
- capture._stopSeconds = _stopSeconds;
- capture._isRealTime = (_captureModeIndex == 0);
- capture._startPaused = _startPaused;
- capture._outputType = _outputType;
- if (_outputType == CaptureBase.OutputType.VideoFile)
- {
- capture._autoGenerateFilename = _appendTimestamp;
- capture._autoFilenamePrefix = _autoFilenamePrefix;
- capture._autoFilenameExtension = _autoFilenameExtension;
- if (!capture._autoGenerateFilename)
- {
- capture._forceFilename = _autoFilenamePrefix + "." + _autoFilenameExtension;
- }
- }
- else
- {
- capture._forceFilename = _namedPipePath;
- }
- capture._outputFolderType = CaptureBase.OutputPath.RelativeToProject;
- capture._outputFolderPath = _outputFolderRelative;
- if (_outputFolderIndex == 1)
- {
- capture._outputFolderType = CaptureBase.OutputPath.RelativeToPeristentData;
- capture._outputFolderPath = _outputFolderAbsolute;
- }
- if (_outputFolderIndex == 2)
- {
- capture._outputFolderType = CaptureBase.OutputPath.Absolute;
- capture._outputFolderPath = _outputFolderAbsolute;
- }
- capture._forceVideoCodecIndex = capture._codecIndex = Mathf.Max(-1, (_videoCodecIndex - 4));
- capture._useMediaFoundationH264 = (_videoCodecIndex == 2);
- capture._noAudio = !_captureAudio;
- capture._forceAudioCodecIndex = capture._audioCodecIndex = Mathf.Max(-1, (_audioCodecIndex - 2));
- capture._forceAudioDeviceIndex = capture._audioDeviceIndex = Mathf.Max(-1, (_audioDeviceIndex - 2));
- if (_useMotionBlur && !capture._isRealTime && Camera.main != null)
- {
- capture._useMotionBlur = _useMotionBlur;
- capture._motionBlurSamples = _motionBlurSampleCount;
- capture._motionBlurCameras = new Camera[1];
- capture._motionBlurCameras[0] = Camera.main;
- }
- else
- {
- capture._useMotionBlur = false;
- }
- if (_captureMouseCursor)
- {
- capture._captureMouseCursor = true;
- if (capture._mouseCursor == null)
- {
- capture._mouseCursor = capture.gameObject.AddComponent<MouseCursor>();
- }
- if (capture._mouseCursor != null)
- {
- capture._mouseCursor.SetTexture(_mouseCursorTexture);
- }
- }
- else
- {
- capture._captureMouseCursor = false;
- if (capture._mouseCursor != null)
- {
- capture._mouseCursor.enabled = false;
- }
- }
- }
- private void CreateComponents()
- {
- switch (_sourceType)
- {
- case SourceType.Screen:
- _captureScreen = (CaptureFromScreen)GameObject.FindObjectOfType(typeof(CaptureFromScreen));
- if (_captureScreen == null)
- {
- GameObject go = new GameObject(TempGameObjectName);
- _captureScreen = go.AddComponent<CaptureFromScreen>();
- }
- _capture = _captureScreen;
- break;
- case SourceType.Camera:
- _captureCamera = _cameraNode.gameObject.GetComponent<CaptureFromCamera>();
- if (_captureCamera == null)
- {
- _captureCamera = _cameraNode.gameObject.AddComponent<CaptureFromCamera>();
- }
- _captureCamera.SetCamera(_cameraNode, _useContributingCameras);
- _capture = _captureCamera;
- _capture._renderResolution = _renderResolution;
- _capture._renderSize = _renderSize;
- _capture._renderAntiAliasing = _renderAntiAliasing;
- break;
- case SourceType.Camera360:
- _captureCamera360 = _cameraNode.gameObject.GetComponent<CaptureFromCamera360>();
- if (_captureCamera360 == null)
- {
- _captureCamera360 = _cameraNode.gameObject.AddComponent<CaptureFromCamera360>();
- }
- _capture = _captureCamera360;
- _capture._renderResolution = _renderResolution;
- _capture._renderSize = _renderSize;
- _capture._renderAntiAliasing = _renderAntiAliasing;
- _captureCamera360._cubemapResolution = _cubemapResolution;
- _captureCamera360._cubemapDepth = _cubemapDepth;
- _captureCamera360._stereoRendering = (StereoPacking)_cubemapStereoPacking;
- _captureCamera360._ipd = _cubemapStereoIPD;
- break;
- case SourceType.Camera360ODS:
- _captureCamera360ODS = _cameraNode.gameObject.GetComponent<CaptureFromCamera360ODS>();
- if (_captureCamera360ODS == null)
- {
- _captureCamera360ODS = _cameraNode.gameObject.AddComponent<CaptureFromCamera360ODS>();
- }
- _capture = _captureCamera360ODS;
- _capture._renderResolution = _renderResolution;
- _capture._renderSize = _renderSize;
- _capture._renderAntiAliasing = _renderAntiAliasing;
- _captureCamera360ODS.Setup.camera = _cameraNode;
- _captureCamera360ODS.Setup.ipd = _odsSettings.ipd;
- _captureCamera360ODS.Setup.pixelSliceSize = _odsSettings.pixelSliceSize;
- _captureCamera360ODS.Setup.paddingSize = _odsSettings.paddingSize;
- _captureCamera360ODS.Setup.cameraClearMode = _odsSettings.cameraClearMode;
- _captureCamera360ODS.Setup.cameraClearColor= _odsSettings.cameraClearColor;
- break;
- }
- // TODO: Remove old components from previous captures if the mode or gameObject has changed
- }
- private void CreateGUI()
- {
- try
- {
- if (!NativePlugin.Init())
- {
- Debug.LogError("[AVProMovieCapture] Failed to initialise");
- return;
- }
- }
- catch (System.DllNotFoundException e)
- {
- _isFailedInit = true;
- string missingDllMessage = string.Empty;
- #if (UNITY_5 || UNITY_5_4_OR_NEWER)
- missingDllMessage = "Unity couldn't find the plugin DLL. Please select the native plugin files in 'Plugins/RenderHeads/AVProMovieCapture/Plugins' folder and select the correct platform in the Inspector.";
- #else
- missingDllMessage = "Unity couldn't find the plugin DLL, Unity 4.x requires the 'Plugins' folder to be at the root of your project. Please move the contents of the 'Plugins' folder (in Plugins/RenderHeads/AVProMovieCapture/Plugins) to the 'Plugins' folder in the root of your project.";
- #endif
- Debug.LogError("[AVProMovieCapture] " + missingDllMessage);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.DisplayDialog("Plugin files not found", missingDllMessage, "Ok");
- #endif
- throw e;
- }
- // Video codec enumeration
- {
- int numVideoCodecs = Mathf.Max(0, NativePlugin.GetNumAVIVideoCodecs());
- _videoCodecNames = new string[numVideoCodecs + 4];
- _videoCodecNames[0] = "Uncompressed";
- _videoCodecNames[1] = string.Empty;
- _videoCodecNames[2] = "Media Foundation H.264 (MP4)";
- _videoCodecNames[3] = string.Empty;
- _videoCodecConfigurable = new bool[numVideoCodecs + 4];
- _videoCodecConfigurable[0] = false;
- _videoCodecConfigurable[1] = false;
- _videoCodecConfigurable[2] = false;
- _videoCodecConfigurable[3] = false;
- for (int i = 0; i < numVideoCodecs; i++)
- {
- _videoCodecNames[i + 4] = i.ToString("D2") + ") " + NativePlugin.GetAVIVideoCodecName(i).Replace("/", "_");
- _videoCodecConfigurable[i + 4] = NativePlugin.IsConfigureVideoCodecSupported(i);
- }
- }
- // Audio device enumeration
- {
- int numAudioDevices = Mathf.Max(0, NativePlugin.GetNumAVIAudioInputDevices());
- _audioDeviceNames = new string[numAudioDevices + 2];
- _audioDeviceNames[0] = "Unity";
- _audioDeviceNames[1] = string.Empty;
- for (int i = 0; i < numAudioDevices; i++)
- {
- _audioDeviceNames[i + 2] = i.ToString("D2") + ") " + NativePlugin.GetAVIAudioInputDeviceName(i).Replace("/", "_");
- }
- }
- // Audio codec enumeration
- {
- int numAudioCodecs = Mathf.Max(0, NativePlugin.GetNumAVIAudioCodecs());
- _audioCodecNames = new string[numAudioCodecs + 2];
- _audioCodecNames[0] = "Uncompressed";
- _audioCodecNames[1] = string.Empty;
- _audioCodecConfigurable = new bool[numAudioCodecs + 2];
- _audioCodecConfigurable[0] = false;
- _audioCodecConfigurable[1] = false;
- for (int i = 0; i < numAudioCodecs; i++)
- {
- _audioCodecNames[i + 2] = i.ToString("D2") + ") " + NativePlugin.GetAVIAudioCodecName(i).Replace("/", "_");
- _audioCodecConfigurable[i + 2] = NativePlugin.IsConfigureAudioCodecSupported(i);
- }
- }
- _isInit = true;
- }
- private void OnEnable()
- {
- if (_icon == null)
- {
- _icon = Resources.Load<Texture2D>("AVProMovieCaptureIcon");
- }
- if (!_isCreated)
- {
- SetupWindow();
- }
- _isTrialVersion = IsTrialVersion();
- // Check that the plugin version number is not too old
- {
- float pluginVersion = NativePlugin.GetPluginVersion();
- string pluginVersionString = pluginVersion.ToString("F2");
- if (_isTrialVersion)
- {
- pluginVersionString += "t";
- }
- _pluginVersionWarningText = string.Empty;
- if (pluginVersion.ToString("F2") != NativePlugin.ExpectedPluginVersion)
- {
- _pluginVersionWarningText = "Warning: Plugin version number " + pluginVersionString + " doesn't match the expected version number " + NativePlugin.ExpectedPluginVersion + ". It looks like the plugin didn't upgrade correctly. To resolve this please restart Unity and try to upgrade the package again.";
- }
- }
- }
- private void OnDisable()
- {
- SaveSettings();
- StopCapture();
- _isInit = false;
- _isCreated = false;
- Repaint();
- }
- private void StartCapture()
- {
- _lastFileSize = 0;
- _lastEncodedSeconds = 0;
- _lastEncodedMinutes = 0;
- _lastEncodedFrame = 0;
- CreateComponents();
- if (_capture != null)
- {
- Configure(_capture);
- _capture.SelectCodec(false);
- if (!_capture._noAudio)
- {
- _capture.SelectAudioCodec(false);
- _capture.SelectAudioDevice(false);
- }
- _capture.QueueStartCapture();
- }
- }
- private void StopCapture(bool cancelCapture = false)
- {
- if (_capture != null)
- {
- if (_capture.IsCapturing())
- {
- if (!cancelCapture)
- {
- _capture.StopCapture();
- }
- else
- {
- _capture.CancelCapture();
- }
- }
- _capture = null;
- _captureScreen = null;
- _captureCamera = null;
- }
- }
- // Updates 10 times/second
- void OnInspectorUpdate()
- {
- if (_capture != null)
- {
- if (Application.isPlaying)
- {
- _lastFileSize = _capture.GetCaptureFileSize();
- if (!_capture._isRealTime)
- {
- _lastEncodedSeconds = (uint)Mathf.FloorToInt((float)_capture.NumEncodedFrames / (float)_capture._frameRate);
- }
- else
- {
- _lastEncodedSeconds = _capture.TotalEncodedSeconds;
- }
- _lastEncodedMinutes = _lastEncodedSeconds / 60;
- _lastEncodedSeconds = _lastEncodedSeconds % 60;
- _lastEncodedFrame = _capture.NumEncodedFrames % (uint)_capture._frameRate;
- // If the capture has stopped automatically, we need to update the UI
- if (_capture._stopMode != StopMode.None && _capture.NumEncodedFrames > 0 && !_capture.IsCapturing())
- {
- StopCapture();
- }
- }
- else
- {
- StopCapture();
- }
- }
- else
- {
- if (_queueConfigureVideoCodec >= 0)
- {
- int configureVideoCodec = _queueConfigureVideoCodec;
- _queueConfigureVideoCodec = -1;
- NativePlugin.Init();
- NativePlugin.ConfigureVideoCodec(configureVideoCodec);
- }
- if (_queueConfigureAudioCodec >= 0)
- {
- int configureAudioCodec = _queueConfigureAudioCodec;
- _queueConfigureAudioCodec = -1;
- NativePlugin.Init();
- NativePlugin.ConfigureAudioCodec(configureAudioCodec);
- }
- if (_queueStart && Application.isPlaying)
- {
- _queueStart = false;
- StartCapture();
- }
- }
- Repaint();
- }
- private static bool ShowConfigList(string title, string[] items, bool[] isConfigurable, ref int itemIndex, bool showConfig = true, bool listEnabled = true)
- {
- bool result = false;
- if (itemIndex < 0 || items == null)
- return result;
- if (!string.IsNullOrEmpty(title))
- {
- EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
- }
- EditorGUI.BeginDisabledGroup(!listEnabled);
- EditorGUILayout.BeginHorizontal();
- itemIndex = EditorGUILayout.Popup(itemIndex, items);
- if (showConfig && isConfigurable != null && itemIndex < isConfigurable.Length)
- {
- EditorGUI.BeginDisabledGroup(itemIndex == 0 || !isConfigurable[itemIndex]);
- if (GUILayout.Button("Configure"))
- {
- result = true;
- }
- EditorGUI.EndDisabledGroup();
- }
- EditorGUILayout.EndHorizontal();
- EditorGUI.EndDisabledGroup();
- return result;
- }
- void OnGUI()
- {
- if (Application.platform != RuntimePlatform.WindowsEditor)
- {
- EditorGUILayout.LabelField("AVPro Movie Capture only works on the Windows platform.");
- return;
- }
- if (!_isInit)
- {
- if (_isFailedInit)
- {
- GUILayout.Label("Error", EditorStyles.boldLabel);
- GUI.enabled = false;
- string missingDllMessage = string.Empty;
- #if (UNITY_5 || UNITY_5_4_OR_NEWER)
- missingDllMessage = "Unity couldn't find the plugin DLL. Please select the native plugin files in 'Plugins/RenderHeads/AVProMovieCapture/Plugins' folder and select the correct platform in the Inspector.";
- #else
- missingDllMessage = "Unity couldn't find the plugin DLL, Unity 4.x requires the 'Plugins' folder to be at the root of your project. Please move the contents of the 'Plugins' folder (in Plugins/RenderHeads/AVProMovieCapture/Plugins) to the 'Plugins' folder in the root of your project.";
- #endif
- GUILayout.TextArea(missingDllMessage);
- GUI.enabled = true;
- return;
- }
- else
- {
- EditorGUILayout.LabelField("Initialising...");
- return;
- }
- }
- if (!string.IsNullOrEmpty(_pluginVersionWarningText))
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea(_pluginVersionWarningText);
- GUI.color = Color.white;
- }
- if (_so == null)
- {
- return;
- }
- _so.Update();
- #if AVPRO_MOVIECAPTURE_GRAPHICSDEVICETYPE_51
- if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Consider switching to Direct3D11 for best capture results. You may need to change your Build platform to Windows.");
- GUI.color = Color.white;
- }
- #endif
- if (_isTrialVersion)
- {
- EditorUtils.DrawSectionColored("- AVPRO MOVIE CAPTURE - FREE TRIAL VERSION", ref _expandSectionTrial, DrawTrialMessage, Color.yellow, Color.yellow, Color.yellow);
- //EditorGUILayout.Space();
- }
- DrawControlButtonsGUI();
- EditorGUILayout.Space();
- // Live Capture Stats
- if (Application.isPlaying && _capture != null && _capture.IsCapturing())
- {
- if (_propStopMode.enumValueIndex != (int)StopMode.None)
- {
- Rect r = GUILayoutUtility.GetRect(128f, EditorStyles.label.CalcHeight(GUIContent.none, 32f), GUILayout.ExpandWidth(true));
- float progress = _capture.GetProgress();
- EditorGUI.ProgressBar(r, progress, (progress * 100f).ToString("F1") + "%");
- }
- _scroll = EditorGUILayout.BeginScrollView(_scroll);
- DrawBaseCapturingGUI(_capture);
- DrawMoreCapturingGUI();
- EditorGUILayout.EndScrollView();
- }
- // Configuration
- else if (_capture == null)
- {
- string[] _toolNames = { "Settings", "About" };
- _selectedTool = GUILayout.Toolbar(_selectedTool, _toolNames);
- switch (_selectedTool)
- {
- case 0:
- DrawConfigGUI_Toolbar();
- _scroll = EditorGUILayout.BeginScrollView(_scroll);
- DrawConfigGUI();
- EditorGUILayout.EndScrollView();
- break;
- case 1:
- _scroll = EditorGUILayout.BeginScrollView(_scroll);
- DrawConfigGUI_About();
- EditorGUILayout.EndScrollView();
- break;
- }
- }
- if (_so.ApplyModifiedProperties())
- {
- EditorUtility.SetDirty(this);
- }
- }
- private void DrawTrialMessage()
- {
- string message = "The free trial version is limited to 10 seconds of capture time. UPGRADE to the full package for unlimited use.";
- //GUI.backgroundColor = Color.yellow;
- //EditorGUILayout.BeginVertical(GUI.skin.box);
- //GUI.color = Color.yellow;
- //GUILayout.Label("AVPRO MOVIE CAPTURE - FREE TRIAL VERSION", EditorStyles.boldLabel);
- GUI.color = Color.white;
- GUILayout.Label(message, EditorStyles.wordWrappedLabel);
- if (GUILayout.Button("Upgrade Now"))
- {
- Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/content/2670");
- }
- //EditorGUILayout.EndVertical();
- GUI.backgroundColor = Color.white;
- GUI.color = Color.white;
- }
- private void DrawControlButtonsGUI()
- {
- EditorGUILayout.BeginHorizontal();
- if (_capture == null)
- {
- GUI.backgroundColor = Color.green;
- string startString = "Start Capture";
- if (_captureModeIndex == 1)
- {
- startString = "Start Render";
- }
- if (GUILayout.Button(startString, GUILayout.Height(32f)))
- {
- bool isReady = true;
- if (_sourceType == SourceType.Camera && _cameraNode == null)
- {
- Debug.LogError("[AVProMovieCapture] Please select a Camera to capture from, or select to capture from Screen.");
- isReady = false;
- }
- if (isReady)
- {
- if (!Application.isPlaying)
- {
- EditorApplication.isPlaying = true;
- _queueStart = true;
- }
- else
- {
- StartCapture();
- Repaint();
- }
- }
- }
- }
- else
- {
- GUI.backgroundColor = Color.cyan;
- if (GUILayout.Button("Cancel", GUILayout.Height(32f)))
- {
- StopCapture(true);
- Repaint();
- }
- GUI.backgroundColor = Color.red;
- if (GUILayout.Button("Stop", GUILayout.Height(32f)))
- {
- StopCapture(false);
- Repaint();
- }
- if (_capture != null)
- {
- if (_capture.IsPaused())
- {
- GUI.backgroundColor = Color.green;
- if (GUILayout.Button("Resume", GUILayout.Height(32f)))
- {
- _capture.ResumeCapture();
- Repaint();
- }
- }
- else
- {
- GUI.backgroundColor = Color.yellow;
- if (GUILayout.Button("Pause", GUILayout.Height(32f)))
- {
- _capture.PauseCapture();
- Repaint();
- }
- }
- }
- }
- EditorGUILayout.EndHorizontal();
- GUI.backgroundColor = Color.white;
- GUILayout.BeginHorizontal();
- if (GUILayout.Button("Browse"))
- {
- if (!string.IsNullOrEmpty(CaptureBase.LastFileSaved))
- {
- Utils.ShowInExplorer(CaptureBase.LastFileSaved);
- }
- }
- if (GUILayout.Button("View Last Capture"))
- {
- if (!string.IsNullOrEmpty(CaptureBase.LastFileSaved))
- {
- Utils.OpenInDefaultApp(CaptureBase.LastFileSaved);
- }
- }
- GUILayout.EndHorizontal();
- }
- public static void DrawBaseCapturingGUI(CaptureBase capture)
- {
- GUILayout.Space(8.0f);
- Texture texture = capture.GetPreviewTexture();
- if (texture != null)
- {
- float width = Screen.width - (Screen.width / 8f);
- width = (Screen.width / 2f) - (Screen.width / 16f);
- float aspect = (float)texture.width / (float)texture.height;
- GUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
-
- if (_showAlpha)
- {
- width = (Screen.width / 2f) - (Screen.width / 16f);
- Rect textureRect = GUILayoutUtility.GetRect(width, width / aspect, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));
- EditorGUI.DrawPreviewTexture(textureRect, texture, null, ScaleMode.ScaleToFit);
- //textureRect = GUILayoutUtility.GetRect(width, width / aspect);
- textureRect = GUILayoutUtility.GetRect(width, width / aspect, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)); ;
- EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);
- }
- else
- {
- Rect textureRect = GUILayoutUtility.GetRect(width, width / aspect, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));
- EditorGUI.DrawPreviewTexture(textureRect, texture, null, ScaleMode.ScaleToFit);
- }
- GUILayout.FlexibleSpace();
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- _showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha", GUILayout.ExpandWidth(false));
- GUILayout.FlexibleSpace();
- GUILayout.EndHorizontal();
- GUILayout.Space(8.0f);
- }
- GUILayout.Label("Output", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- EditorGUI.indentLevel++;
- GUILayout.Label("Recording to: " + System.IO.Path.GetFileName(capture.LastFilePath), EditorStyles.wordWrappedLabel);
- GUILayout.Space(8.0f);
- GUILayout.Label("Video");
- EditorGUILayout.LabelField("Dimensions", capture.GetRecordingWidth() + "x" + capture.GetRecordingHeight() + " @ " + ((int)capture._frameRate).ToString() + "hz");
- if (!capture._useMediaFoundationH264)
- {
- EditorGUILayout.LabelField("Codec", capture._codecName);
- }
- else
- {
- EditorGUILayout.LabelField("Codec", "Media Foundation H.264");
- }
- if (!capture._noAudio && capture._isRealTime)
- {
- GUILayout.Label("Audio");
- EditorGUILayout.LabelField("Source", capture._audioDeviceName);
- EditorGUILayout.LabelField("Codec", capture._audioCodecName);
- if (capture._audioDeviceName == "Unity")
- {
- EditorGUILayout.LabelField("Sample Rate", capture._unityAudioSampleRate.ToString() + "hz");
- EditorGUILayout.LabelField("Channels", capture._unityAudioChannelCount.ToString());
- }
- }
- EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- GUILayout.Space(8.0f);
- GUILayout.Label("Stats", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- EditorGUI.indentLevel++;
- if (capture.FPS > 0f)
- {
- Color originalColor = GUI.color;
- if (capture._isRealTime)
- {
- float fpsDelta = (capture.FPS - (int)capture._frameRate);
- GUI.color = Color.red;
- if (fpsDelta > -10)
- {
- GUI.color = Color.yellow;
- }
- if (fpsDelta > -2)
- {
- GUI.color = Color.green;
- }
- }
- EditorGUILayout.LabelField("Capture Rate", string.Format("{0:0.##} / {1} FPS", capture.FPS, (int)capture._frameRate));
- GUI.color = originalColor;
- }
- else
- {
- EditorGUILayout.LabelField("Capture Rate", string.Format(".. / {0} FPS", (int)capture._frameRate));
- }
- EditorGUILayout.LabelField("Encoded Frames", capture.NumEncodedFrames.ToString());
- EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- }
- public void DrawMoreCapturingGUI()
- {
- GUILayout.Label("More Stats", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- EditorGUI.indentLevel++;
- EditorGUILayout.LabelField("File Size", ((float)_lastFileSize / (1024f * 1024f)).ToString("F1") + "MB");
- EditorGUILayout.LabelField("Video Length", _lastEncodedMinutes.ToString("00") + ":" + _lastEncodedSeconds.ToString("00") + "." + _lastEncodedFrame.ToString("000"));
- GUILayout.Label("Dropped Frames");
- EditorGUILayout.LabelField("In Unity", _capture.NumDroppedFrames.ToString());
- EditorGUILayout.LabelField("In Encoder", _capture.NumDroppedEncoderFrames.ToString());
- if (!_capture._noAudio && _capture._isRealTime)
- {
- if (_capture._audioCapture && _capture._audioDeviceName == "Unity")
- {
- EditorGUILayout.LabelField("Audio Overflows", _capture._audioCapture.OverflowCount.ToString());
- }
- }
- EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- }
- private void DrawConfigGUI_Toolbar()
- {
- string[] _toolNames = { "General", "Visual", "Audio", "Output" };
- _selectedConfigTool = GUILayout.Toolbar(_selectedConfigTool, _toolNames);
- }
- private void DrawConfigGUI()
- {
- switch (_selectedConfigTool)
- {
- case 0:
- DrawConfigGUI_General();
- break;
- case 1:
- DrawConfigGUI_Visual();
- break;
- case 2:
- DrawConfigGUI_Audio();
- break;
- case 3:
- DrawConfigGUI_Output();
- break;
- }
- GUILayout.FlexibleSpace();
- }
- public static void DrawConfigGUI_About()
- {
- string version = NativePlugin.GetPluginVersion().ToString("F2");
-
- EditorGUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- if (_icon == null)
- {
- _icon = Resources.Load<Texture2D>("AVProMovieCaptureIcon");
- }
- if (_icon != null)
- {
- GUILayout.Label(new GUIContent(_icon));
- }
- GUILayout.FlexibleSpace();
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- GUI.color = Color.yellow;
- GUILayout.Label("AVPro Movie Capture by RenderHeads Ltd", EditorStyles.boldLabel);
- GUI.color = Color.white;
- GUILayout.FlexibleSpace();
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- GUI.color = Color.yellow;
- GUILayout.Label("version " + version + " (scripts v" + NativePlugin.ScriptVersion + ")");
- GUI.color = Color.white;
- GUILayout.FlexibleSpace();
- EditorGUILayout.EndHorizontal();
- // Links
- {
- GUILayout.Space(32f);
- GUI.backgroundColor = Color.white;
- EditorGUILayout.LabelField("AVPro Movie Capture Links", EditorStyles.boldLabel);
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("Documentation");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("User Manual", GUILayout.ExpandWidth(false)))
- {
- Application.OpenURL(LinkUserManual);
- }
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(16f);
- GUILayout.Label("Rate and Review (★★★★☆)", GUILayout.ExpandWidth(false));
- if (GUILayout.Button("Unity Asset Store Page", GUILayout.ExpandWidth(false)))
- {
- if (!_isTrialVersion)
- {
- Application.OpenURL(LinkAssetStorePage);
- }
- else
- {
- Application.OpenURL(LinkFreeAssetStorePage);
- }
- }
- GUILayout.Space(16f);
- GUILayout.Label("Community");
- if (GUILayout.Button("Unity Forum Page", GUILayout.ExpandWidth(false)))
- {
- Application.OpenURL(LinkForumPage);
- }
- GUILayout.Space(16f);
- GUILayout.Label("Homepage", GUILayout.ExpandWidth(false));
- if (GUILayout.Button("AVPro Movie Capture Website", GUILayout.ExpandWidth(false)))
- {
- Application.OpenURL(LinkPluginWebsite);
- }
- GUILayout.Space(16f);
- GUILayout.Label("Bugs and Support");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("Email unitysupport@renderheads.com", GUILayout.ExpandWidth(false)))
- {
- Application.OpenURL(LinkEmailSupport);
- }
- EditorGUILayout.EndHorizontal();
- }
- // Credits
- {
- GUILayout.Space(32f);
- EditorGUILayout.LabelField("Credits", EditorStyles.boldLabel);
- GUILayout.Space(8f);
- EditorUtils.CentreLabel("Programming", EditorStyles.boldLabel);
- EditorUtils.CentreLabel("Andrew Griffiths");
- EditorUtils.CentreLabel("Sunrise Wang");
- GUILayout.Space(8f);
- EditorUtils.CentreLabel("Graphics", EditorStyles.boldLabel);
- EditorUtils.CentreLabel("Jeff Rusch");
- EditorUtils.CentreLabel("Luke Godward");
- }
- // Bug reporting
- {
- GUILayout.Space(32f);
- EditorGUILayout.LabelField("Bug Reporting Notes", EditorStyles.boldLabel);
- EditorGUILayout.SelectableLabel(SupportMessage, EditorStyles.wordWrappedLabel, GUILayout.Height(180f));
- }
- }
- private void DrawConfigGUI_General()
- {
- //GUILayout.Label("General", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- //EditorGUI.indentLevel++;
- // Time
- {
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("Time", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- _captureModeIndex = EditorGUILayout.Popup("Capture Mode", _captureModeIndex, _captureModes);
- EditorUtils.EnumAsDropdown("Frame Rate", _propFrameRate, new string[] { "1", "10", "15", "24", "25", "30", "50", "60", "75", "90", "120" });
- //_frameRate = (CaptureBase.FrameRate)EditorGUILayout.EnumPopup("Frame Rate", _frameRate);
- EditorGUI.indentLevel--;
- }
- // Source
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("Source", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- EditorUtils.EnumAsDropdown("Source", _propSourceType, _sourceNames);
- if (_sourceType == SourceType.Camera360ODS && _captureModeIndex == 0)
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: This source type is very slow and not suitable for 'Realtime Capture'. Consider changing the capture mode to 'Offline Render'.");
- GUI.color = Color.white;
- }
- //_sourceType = (SourceType)EditorGUILayout.EnumPopup("Type", _sourceType);
- if (_sourceType == SourceType.Camera || _sourceType == SourceType.Camera360 || _sourceType == SourceType.Camera360ODS)
- {
- if (_cameraNode == null)
- {
- _cameraNode = Utils.GetUltimateRenderCamera();
- }
- _cameraNode = (Camera)EditorGUILayout.ObjectField("Camera", _cameraNode, typeof(Camera), true);
- if (_sourceType == SourceType.Camera && _cameraNode != null)
- {
- EditorGUILayout.PropertyField(_propUseContributingCameras, new GUIContent("Contributing Cameras"));
- }
- }
- EditorGUI.indentLevel--;
- // Screen options
- if (_sourceType == SourceType.Screen)
- {
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("Cursor", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- _captureMouseCursor = EditorGUILayout.Toggle("Capture Mouse Cursor", _captureMouseCursor);
- _mouseCursorTexture = (Texture2D)EditorGUILayout.ObjectField("Mouse Cursor Texture", _mouseCursorTexture, typeof(Texture2D), false);
- EditorGUI.indentLevel--;
- }
- // Camera overrides
- if (_sourceType == SourceType.Camera || _sourceType == SourceType.Camera360 || _sourceType == SourceType.Camera360ODS)
- {
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("Camera Overrides", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- {
- EditorUtils.EnumAsDropdown("Resolution", _propRenderResolution, CaptureBaseEditor.ResolutionStrings);
- }
- if (_renderResolution == CaptureBase.Resolution.Custom)
- {
- _renderSize = EditorGUILayout.Vector2Field("Size", _renderSize);
- _renderSize = new Vector2(Mathf.Clamp((int)_renderSize.x, 1, NativePlugin.MaxRenderWidth), Mathf.Clamp((int)_renderSize.y, 1, NativePlugin.MaxRenderHeight));
- }
- {
- string currentAA = "None";
- if (QualitySettings.antiAliasing > 1)
- {
- currentAA = QualitySettings.antiAliasing.ToString() + "x";
- }
- EditorUtils.IntAsDropdown("Anti-aliasing", _propRenderAntiAliasing, new string[] { "Current (" + currentAA + ")", "None", "2x", "4x", "8x" }, new int[] { -1, 1, 2, 4, 8 });
- }
- if (_cameraNode != null)
- {
- if (_cameraNode.actualRenderingPath == RenderingPath.DeferredLighting
- #if AVPRO_MOVIECAPTURE_DEFERREDSHADING
- || _cameraNode.actualRenderingPath == RenderingPath.DeferredShading
- #endif
- )
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: Antialiasing by MSAA is not supported as camera is using deferred rendering path");
- GUI.color = Color.white;
- _renderAntiAliasing = -1;
- }
- if (_cameraNode.clearFlags == CameraClearFlags.Nothing || _cameraNode.clearFlags == CameraClearFlags.Depth)
- {
- if (_renderResolution != CaptureBase.Resolution.Original || _renderAntiAliasing != -1)
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: Overriding camera resolution or anti-aliasing when clear flag is set to " + _cameraNode.clearFlags + " may result in incorrect captures");
- GUI.color = Color.white;
- }
- }
- }
- EditorGUI.indentLevel--;
- }
- // 360 Cubemap
- if (_sourceType == SourceType.Camera360)
- {
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("360 Camera", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- {
- CaptureBase.CubemapResolution cubemapEnum = (CaptureBase.CubemapResolution)_cubemapResolution;
- _cubemapResolution = (int)((CaptureBase.CubemapResolution)EditorGUILayout.EnumPopup("Resolution", cubemapEnum));
- }
- {
- CaptureBase.CubemapDepth depthEnum = (CaptureBase.CubemapDepth)_cubemapDepth;
- _cubemapDepth = (int)((CaptureBase.CubemapDepth)EditorGUILayout.EnumPopup("Depth", depthEnum));
- }
- {
- StereoPacking stereoEnum = (StereoPacking)_cubemapStereoPacking;
- _cubemapStereoPacking = (int)((StereoPacking)EditorGUILayout.EnumPopup("Stereo Mode", stereoEnum));
- }
- if (_cubemapStereoPacking != (int)StereoPacking.None)
- {
- _cubemapStereoIPD = EditorGUILayout.FloatField("Interpupillary distance", _cubemapStereoIPD);
- }
- EditorGUI.indentLevel--;
- }
- // 360 Cubemap ODS
- if (_sourceType == SourceType.Camera360ODS)
- {
- GUILayout.Space(8f);
- EditorGUI.indentLevel++;
- EditorGUILayout.LabelField("Source Options", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- {
- EditorGUILayout.PropertyField(_propOdsIPD, new GUIContent("Interpupillary distance"));
- EditorGUILayout.PropertyField(_propOdsPixelSliceSize);
- EditorGUILayout.PropertyField(_propOdsPaddingSize);
- EditorGUILayout.PropertyField(_propOdsCameraClearMode);
- EditorGUILayout.PropertyField(_propOdsCameraClearColor);
- }
- EditorGUI.indentLevel--;
- EditorGUI.indentLevel--;
- }
- // Start / Stop
- {
- GUILayout.Space(8f);
- EditorGUILayout.LabelField("Start / Stop", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- _startPaused = EditorGUILayout.Toggle("Start Paused", _startPaused);
- _stopMode = (StopMode)EditorGUILayout.EnumPopup("Stop Mode", _stopMode);
- if (_stopMode == StopMode.FramesEncoded)
- {
- _stopFrames = EditorGUILayout.IntField("Frames", _stopFrames);
- }
- else if (_stopMode == StopMode.SecondsElapsed || _stopMode == StopMode.SecondsEncoded)
- {
- _stopSeconds = EditorGUILayout.FloatField("Seconds", _stopSeconds);
- }
- EditorGUI.indentLevel--;
- }
- GUILayout.Space(8f);
- if (GUILayout.Button("Reset All Settings"))
- {
- ResetSettings();
- }
- GUILayout.Space(4f);
- //EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- }
- private void DrawConfigGUI_Output()
- {
- //GUILayout.Label("Target", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- //EditorGUI.indentLevel++;
- EditorUtils.EnumAsDropdown("Output Type", _propOutputType, new string[] { "Video File", "Named Pipe" });
- GUILayout.Space(8f);
- if (_propOutputType.enumValueIndex == (int)CaptureBase.OutputType.VideoFile)
- {
- // File path
- EditorGUILayout.LabelField("File Path", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- _outputFolderIndex = EditorGUILayout.Popup("Relative to", _outputFolderIndex, _outputFolders);
- if (_outputFolderIndex == 0 || _outputFolderIndex == 1)
- {
- _outputFolderRelative = EditorGUILayout.TextField("SubFolder(s)", _outputFolderRelative);
- }
- else
- {
- EditorGUILayout.BeginHorizontal();
- _outputFolderAbsolute = EditorGUILayout.TextField("Path", _outputFolderAbsolute);
- if (GUILayout.Button(">", GUILayout.Width(22)))
- {
- _outputFolderAbsolute = EditorUtility.SaveFolderPanel("Select Folder To Store Video Captures", System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, "../")), "");
- EditorUtility.SetDirty(this);
- }
- EditorGUILayout.EndHorizontal();
- }
- EditorGUI.indentLevel--;
- GUILayout.Space(8f);
- // File name
- EditorGUILayout.LabelField("File Name", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- _autoFilenamePrefixFromSceneName = EditorGUILayout.Toggle("From Scene Name", _autoFilenamePrefixFromSceneName);
- if (_autoFilenamePrefixFromSceneName)
- {
- #if AVPRO_MOVIECAPTURE_SCENEMANAGER_53
- string currentScenePath = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().path;
- #else
- string currentScenePath = EditorApplication.currentScene;
- #endif
- _autoFilenamePrefix = System.IO.Path.GetFileNameWithoutExtension(currentScenePath);
- if (string.IsNullOrEmpty(_autoFilenamePrefix))
- {
- _autoFilenamePrefix = "capture";
- }
- }
- EditorGUI.BeginDisabledGroup(_autoFilenamePrefixFromSceneName);
- _autoFilenamePrefix = EditorGUILayout.TextField("Prefix", _autoFilenamePrefix);
- EditorGUI.EndDisabledGroup();
- _autoFilenameExtension = EditorGUILayout.TextField("Extension", _autoFilenameExtension);
- _appendTimestamp = EditorGUILayout.Toggle("Append Timestamp", _appendTimestamp);
- EditorGUI.indentLevel--;
- }
- else if (_propOutputType.enumValueIndex == (int)CaptureBase.OutputType.NamedPipe)
- {
- EditorGUILayout.PropertyField(_propNamedPipePath);
- }
- //EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- }
- private void DrawConfigGUI_Visual()
- {
- //GUILayout.Label("Video", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- //EditorGUI.indentLevel++;
- {
- Vector2 outSize = Vector2.zero;
- if (_sourceType == SourceType.Screen)
- {
- // We can't just use Screen.width and Screen.height because Unity returns the size of this window
- // So instead we look for a camera with no texture target and a valid viewport
- int inWidth = 1;
- int inHeight = 1;
- foreach (Camera cam in Camera.allCameras)
- {
- if (cam.targetTexture == null)
- {
- float rectWidth = Mathf.Clamp01(cam.rect.width + cam.rect.x) - Mathf.Clamp01(cam.rect.x);
- float rectHeight = Mathf.Clamp01(cam.rect.height + cam.rect.y) - Mathf.Clamp01(cam.rect.y);
- if (rectWidth > 0.0f && rectHeight > 0.0f)
- {
- inWidth = Mathf.FloorToInt(cam.pixelWidth / rectWidth);
- inHeight = Mathf.FloorToInt(cam.pixelHeight / rectHeight);
- //Debug.Log (rectWidth + " " + (cam.rect.height - cam.rect.y) + " " + cam.pixelHeight + " = " + inWidth + "x" + inHeight);
- break;
- }
- }
- }
- outSize = CaptureBase.GetRecordingResolution(inWidth, inHeight, GetDownScaleFromIndex(_downScaleIndex), new Vector2(_downscaleX, _downscaleY));
- }
- else
- {
- if (_cameraNode != null)
- {
- int inWidth = Mathf.FloorToInt(_cameraNode.pixelRect.width);
- int inHeight = Mathf.FloorToInt(_cameraNode.pixelRect.height);
- if (_renderResolution != CaptureBase.Resolution.Original)
- {
- float rectWidth = Mathf.Clamp01(_cameraNode.rect.width + _cameraNode.rect.x) - Mathf.Clamp01(_cameraNode.rect.x);
- float rectHeight = Mathf.Clamp01(_cameraNode.rect.height + _cameraNode.rect.y) - Mathf.Clamp01(_cameraNode.rect.y);
- if (_renderResolution == CaptureBase.Resolution.Custom)
- {
- inWidth = (int)_renderSize.x;
- inHeight = (int)_renderSize.y;
- }
- else
- {
- CaptureBase.GetResolution(_renderResolution, ref inWidth, ref inHeight);
- inWidth = Mathf.FloorToInt(inWidth * rectWidth);
- inHeight = Mathf.FloorToInt(inHeight * rectHeight);
- }
- }
- outSize = CaptureBase.GetRecordingResolution(inWidth, inHeight, GetDownScaleFromIndex(_downScaleIndex), new Vector2(_downscaleX, _downscaleY));
- }
- }
- GUILayout.Space(8f);
- GUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- GUI.color = Color.cyan;
- GUILayout.TextArea("Output: " + (int)outSize.x + " x " + (int)outSize.y + " @ " + (int)_frameRate);
- GUILayout.FlexibleSpace();
- GUILayout.EndHorizontal();
- GUILayout.Space(8f);
- GUI.color = Color.white;
- }
- _downScaleIndex = EditorGUILayout.Popup("Down Scale", _downScaleIndex, _downScales);
- if (_downScaleIndex == 5)
- {
- Vector2 maxVideoSize = new Vector2(_downscaleX, _downscaleY);
- maxVideoSize = EditorGUILayout.Vector2Field("Size", maxVideoSize);
- _downscaleX = Mathf.Clamp((int)maxVideoSize.x, 1, NativePlugin.MaxRenderWidth);
- _downscaleY = Mathf.Clamp((int)maxVideoSize.y, 1, NativePlugin.MaxRenderHeight);
- }
- _supportAlpha = EditorGUILayout.Toggle("Support Alpha", _supportAlpha);
- GUILayout.Space(8f);
- //EditorGUILayout.LabelField("Codec", EditorStyles.boldLabel);
- if (_outputType == CaptureBase.OutputType.VideoFile)
- {
- if (ShowConfigList("Codec", _videoCodecNames, _videoCodecConfigurable, ref _videoCodecIndex, true, true))
- {
- _queueConfigureVideoCodec = Mathf.Max(-1, _videoCodecIndex - 4);
- }
- _useMediaFoundationH264 = (_videoCodecIndex == 2);
- if (_useMediaFoundationH264)
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: Make sure to set the file extension to .mp4");
- GUI.color = Color.white;
- }
- else
- {
- if (_videoCodecIndex > 0 && (
- _videoCodecNames[_videoCodecIndex].EndsWith("Cinepak Codec by Radius")
- || _videoCodecNames[_videoCodecIndex].EndsWith("DV Video Encoder")
- || _videoCodecNames[_videoCodecIndex].EndsWith("Microsoft Video 1")
- || _videoCodecNames[_videoCodecIndex].EndsWith("Microsoft RLE")
- || _videoCodecNames[_videoCodecIndex].EndsWith("Logitech Video (I420)")
- || _videoCodecNames[_videoCodecIndex].EndsWith("Intel IYUV codec")
- ))
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: Legacy codec, not recommended");
- GUI.color = Color.white;
- }
- if (_videoCodecIndex >= 0 &&
- (_videoCodecNames[_videoCodecIndex].Contains("Decoder") || _videoCodecNames[_videoCodecIndex].Contains("Decompressor")))
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: Codec may contain decompressor only");
- GUI.color = Color.white;
- }
- if (_videoCodecIndex >= 0 && _videoCodecNames[_videoCodecIndex].EndsWith("Uncompressed"))
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: Uncompressed may result in very large files");
- GUI.color = Color.white;
- }
- if (_videoCodecNames.Length < 8)
- {
- GUI.color = Color.cyan;
- EditorGUILayout.TextArea("Low number of codecs, consider installing more");
- GUI.color = Color.white;
- }
- }
- }
- else
- {
- GUI.color = Color.yellow;
- EditorGUILayout.TextArea("Codec selection not available when using named pipe output");
- GUI.color = Color.white;
- }
- DrawConfigGUI_MotionBlur();
- //EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- }
- private void DrawConfigGUI_MotionBlur()
- {
- EditorGUI.BeginDisabledGroup(_captureModeIndex == 0);
- //EditorGUILayout.BeginVertical("box");
- //EditorGUI.indentLevel++;
- GUILayout.Space(8f);
- GUILayout.Label("Motion Blur (beta)", EditorStyles.boldLabel);
- //EditorGUILayout.BeginVertical("box");
- //EditorGUI.indentLevel++;
- if (_captureModeIndex == 0)
- {
- GUI.color = Color.yellow;
- EditorGUILayout.TextArea("Motion Blur only available in Offline Render mode");
- GUI.color = Color.white;
- }
- _useMotionBlur = EditorGUILayout.Toggle("Use Motion Blur", _useMotionBlur);
- EditorGUI.BeginDisabledGroup(!_useMotionBlur);
- EditorGUILayout.PrefixLabel("Samples");
- EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
- //EditorGUILayout.LabelField("moo", GUILayout.ExpandWidth(false));
- _motionBlurSampleCount = EditorGUILayout.IntSlider(_motionBlurSampleCount, 0, 64);
- EditorGUILayout.EndHorizontal();
- EditorGUI.EndDisabledGroup();
- //EditorGUI.indentLevel--;
- //EditorGUILayout.EndVertical();
- EditorGUI.EndDisabledGroup();
- }
- private void DrawConfigGUI_Audio()
- {
- EditorGUI.BeginDisabledGroup(_captureModeIndex != 0 || _outputType != CaptureBase.OutputType.VideoFile);
- //GUILayout.Label("Audio", EditorStyles.boldLabel);
- EditorGUILayout.BeginVertical("box");
- //EditorGUI.indentLevel++;
- if (_captureModeIndex != 0)
- {
- GUI.color = Color.yellow;
- EditorGUILayout.TextArea("Audio capture not available in Offline Render mode");
- GUI.color = Color.white;
- }
- if (_outputType == CaptureBase.OutputType.NamedPipe)
- {
- GUI.color = Color.yellow;
- EditorGUILayout.TextArea("Audio capture not available when using named pipe output");
- GUI.color = Color.white;
- }
- _captureAudio = EditorGUILayout.Toggle("Capture Audio", _captureAudio);
- GUILayout.Space(8f);
- EditorGUI.BeginDisabledGroup(!_captureAudio);
- if (ShowConfigList("Source", _audioDeviceNames, null, ref _audioDeviceIndex, false))
- {
- }
- GUILayout.Space(8f);
- if (ShowConfigList("Codec", _audioCodecNames, _audioCodecConfigurable, ref _audioCodecIndex))
- {
- _queueConfigureAudioCodec = Mathf.Max(-1, _audioCodecIndex - 2);
- }
- if (_audioCodecIndex > 0 && (_audioCodecNames[_audioCodecIndex].EndsWith("MPEG Layer-3")))
- {
- GUI.color = Color.yellow;
- GUILayout.TextArea("Warning: We have had reports that this codec doesn't work. Consider using a different codec");
- GUI.color = Color.white;
- }
- EditorGUI.EndDisabledGroup();
- //EditorGUI.indentLevel--;
- EditorGUILayout.EndVertical();
- EditorGUI.EndDisabledGroup();
- }
- private static bool IsTrialVersion()
- {
- return NativePlugin.IsTrialVersion();
- }
- }
- }
- #endif
|