Skip to content

Commit

Permalink
Updating package and increasing name checks for playback.
Browse files Browse the repository at this point in the history
  • Loading branch information
rorygames committed Jul 20, 2023
1 parent 1726704 commit a1cb18c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rotation statistic recording
- Option to flatten multipart statistics (e.g. XYZ) into a single line during CSV export

### Changed
- Playback file checks are more aggressive to ensure file changes are accounted for

## [1.1.2] - 11/07/23

### Added
Expand Down
57 changes: 32 additions & 25 deletions Core/Editor/Scripts/PlaybackManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class PlaybackManagerEditor : Editor
private SerializedProperty _timeCounter;
private SerializedProperty _ignoreFile;

private bool _awaitingRefreshVal = false;

private string _componentFilter = "";

private GUIContent _recordFoldoutGUI = new GUIContent("", "You can drag files onto this header to add them to the files list.");
Expand All @@ -53,6 +55,14 @@ private void Awake()
}
}

private void OnDestroy()
{
if (_awaitingRefreshVal)
{
Debug.LogWarning("Playback Manager needs to Update Files before you can enter play mode.", serializedObject.targetObject);
}
}

public override bool RequiresConstantRepaint()
{
return false;
Expand All @@ -65,6 +75,7 @@ private void SetProperties()
_binders = serializedObject.FindProperty("_binders");
_currentFile = serializedObject.FindProperty("_currentFile");
_awaitingRefresh = serializedObject.FindProperty("_awaitingFileRefresh");
_awaitingRefreshVal = _awaitingRefresh.boolValue;
_oldFileIndex = serializedObject.FindProperty("_oldFileIndex");
_playing = serializedObject.FindProperty("_playing");
_changingFiles = serializedObject.FindProperty("_changingFiles");
Expand Down Expand Up @@ -248,19 +259,15 @@ private void RecordedFilesList()
if (_recordedFiles.isExpanded)
{
_fileScrollPos = EditorGUILayout.BeginScrollView(_fileScrollPos, GUILayout.Height(Sizes.Playback.heightFileScroll));
EditorGUI.BeginChangeCheck();
for (int i = 0; i < _recordedFiles.arraySize; i++)
{
if (!(_fileScrollPos.y - ((Sizes.heightLine + Sizes.padding)*2) <= ((Sizes.heightLine+Sizes.padding) * (i - 1)) && _fileScrollPos.y + Sizes.Playback.heightFileScroll > ((Sizes.heightLine + Sizes.padding) * i)))
if (!(_fileScrollPos.y - ((Sizes.heightLine + Sizes.padding) * 2) <= ((Sizes.heightLine + Sizes.padding) * (i - 1)) && _fileScrollPos.y + Sizes.Playback.heightFileScroll > ((Sizes.heightLine + Sizes.padding) * i)))
{
EditorGUILayout.LabelField("");
continue;
}

if (_recordedFiles.GetArrayElementAtIndex(i).objectReferenceValue == null)
{
_awaitingRefresh.boolValue = true;
}

EditorGUILayout.BeginHorizontal();

EditorGUI.BeginDisabledGroup(_awaitingRefresh.boolValue);
Expand All @@ -283,7 +290,6 @@ private void RecordedFilesList()
{
_recordedFiles.GetArrayElementAtIndex(i).objectReferenceValue = null;
_recordedFiles.DeleteArrayElementAtIndex(i);
_awaitingRefresh.boolValue = true;
if (_currentFile.intValue >= _recordedFiles.arraySize)
{
_currentFile.intValue = _recordedFiles.arraySize - 1;
Expand All @@ -294,6 +300,10 @@ private void RecordedFilesList()

EditorGUILayout.EndHorizontal();
}
if (EditorGUI.EndChangeCheck())
{
_awaitingRefresh.boolValue = true;
}
EditorGUILayout.EndScrollView();
}
}
Expand Down Expand Up @@ -324,13 +334,13 @@ private void Playlists()
for (int i = 0; i < _recordedFiles.arraySize; i++)
{
TextAsset t = (TextAsset)_recordedFiles.GetArrayElementAtIndex(i).objectReferenceValue;
if(t == null)
if (t == null)
{
continue;
}
string guid = "";
long local = 0;
if(AssetDatabase.TryGetGUIDAndLocalFileIdentifier(t, out guid, out local))
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(t, out guid, out local))
{
playlist.Add(new PlaylistItem(t.name, AssetDatabase.GUIDToAssetPath(guid), guid));
}
Expand All @@ -343,10 +353,10 @@ private void Playlists()

EditorGUI.EndDisabledGroup();

if (GUILayout.Button(new GUIContent("Load Playlist","Loading a playlist will overwrite your current set of loaded files. Playlist order is determined on how files are found, not the order they are present within the file.")))
if (GUILayout.Button(new GUIContent("Load Playlist", "Loading a playlist will overwrite your current set of loaded files. Playlist order is determined on how files are found, not the order they are present within the file.")))
{
var path = EditorUtility.OpenFilePanel("Load Playlist", "", "json");
if(path.Length != 0)
if (path.Length != 0)
{
try
{
Expand All @@ -357,7 +367,7 @@ private void Playlists()
for (int i = 0; i < playlist.Count; i++)
{
temp = AssetDatabase.GUIDToAssetPath(playlist[i].guid.ToString());
if(temp.Contains(playlist[i].name + ".bytes"))
if (temp.Contains(playlist[i].name + ".bytes"))
{
textAssets.Add(AssetDatabase.LoadAssetAtPath<TextAsset>(temp));
playlist.RemoveAt(i);
Expand All @@ -370,19 +380,19 @@ private void Playlists()
for (int i = 0; i < assets.Length; i++)
{
temp = AssetDatabase.GUIDToAssetPath(assets[i]);
if(temp.EndsWith("bytes"))
if (temp.EndsWith("bytes"))
{
for (int j = 0; j < playlist.Count; j++)
{
if(temp.Contains(playlist[j].name))
if (temp.Contains(playlist[j].name))
{
textAssets.Add(AssetDatabase.LoadAssetAtPath<TextAsset>(temp));
playlist.RemoveAt(j);
break;
}
}
}
if(playlist.Count == 0)
if (playlist.Count == 0)
{
break;
}
Expand Down Expand Up @@ -433,7 +443,7 @@ private void RecordComponents()
}
}

GUIContent recordComponents = new GUIContent("Recorded Items (" + _binders.arraySize+")", EditorMessages.playbackRecordItemInfo);
GUIContent recordComponents = new GUIContent("Recorded Items (" + _binders.arraySize + ")", EditorMessages.playbackRecordItemInfo);

EditorGUILayout.BeginHorizontal();

Expand All @@ -444,19 +454,19 @@ private void RecordComponents()
GUIContent redLabel = new GUIContent(EditorGUIUtility.IconContent("redLight"));
redLabel.tooltip = EditorMessages.playbackRecordItemInfo;

_binders.isExpanded = EditorGUI.Foldout(foldoutRect,_binders.isExpanded, recordComponents, true, Styles.foldoutBold);
_binders.isExpanded = EditorGUI.Foldout(foldoutRect, _binders.isExpanded, recordComponents, true, Styles.foldoutBold);

EditorGUILayout.LabelField(greenLabel,Styles.textIconBold,GUILayout.Width(Sizes.widthIcon));
EditorGUILayout.LabelField(greenLabel, Styles.textIconBold, GUILayout.Width(Sizes.widthIcon));

GUIContent gcLabel = new GUIContent(assignedCount.ToString(), EditorMessages.playbackRecordItemInfo);

EditorGUILayout.LabelField(gcLabel,Styles.textBold, GUILayout.Width(Styles.textBold.CalcSize(gcLabel).x));
EditorGUILayout.LabelField(gcLabel, Styles.textBold, GUILayout.Width(Styles.textBold.CalcSize(gcLabel).x));

EditorGUILayout.LabelField(redLabel,Styles.textIconBold, GUILayout.Width(Sizes.widthIcon));
EditorGUILayout.LabelField(redLabel, Styles.textIconBold, GUILayout.Width(Sizes.widthIcon));

GUIContent rcLabel = new GUIContent(unassignedCount.ToString(), EditorMessages.playbackRecordItemInfo);

EditorGUILayout.LabelField(rcLabel, Styles.textBold,GUILayout.Width(Styles.textBold.CalcSize(rcLabel).x));
EditorGUILayout.LabelField(rcLabel, Styles.textBold, GUILayout.Width(Styles.textBold.CalcSize(rcLabel).x));

EditorGUILayout.EndHorizontal();

Expand Down Expand Up @@ -507,7 +517,7 @@ private void PlaybackIgnoreItems()
EditorGUILayout.LabelField(new GUIContent("Playback Ignore File", "This file controls which components on a RecordComponent's object are NOT disabled when playback begins. If no file is assigned then the default values for each RecordComponent will be used."), Styles.textBold);
_ignoreFile.objectReferenceValue = EditorGUILayout.ObjectField(_ignoreFile.objectReferenceValue, typeof(PlaybackIgnoreComponentsObject), false);
EditorGUILayout.EndHorizontal();
if(_ignoreFile.objectReferenceValue == null)
if (_ignoreFile.objectReferenceValue == null)
{
EditorGUILayout.HelpBox("To create an Ignore File, go to your project assets, right click -> Create -> PlayRecorder -> Playback Ignore Asset. If no file is selected, default values are used.", MessageType.Info);
}
Expand Down Expand Up @@ -569,8 +579,5 @@ private void PlaybackControls()

EditorGUI.EndDisabledGroup();
}


}

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.ultraleap.playrecorder",
"version": "1.1.2",
"version": "1.1.3",
"description": "Unity scene logic recorder tool for editor and builds.",
"displayName": "Ultraleap PlayRecorder",
"unity": "2020.3",
Expand Down

0 comments on commit a1cb18c

Please sign in to comment.