update CCK to 3.10, fixing unity 2021 crash :)

This commit is contained in:
Crispy 2024-08-03 22:24:42 +02:00
parent 48a978fa2a
commit d11e0fb3a9
492 changed files with 2165204 additions and 437687 deletions

View file

@ -0,0 +1,91 @@
#if UNITY_EDITOR
using UnityEditor;
namespace ABI.CCK.Components
{
[CanEditMultipleObjects]
[CustomEditor(typeof(CVRVideoPlayer))]
public partial class CCK_CVRVideoPlayerEditor : Editor
{
#region Editor GUI Foldouts
private static bool _guiGeneralSettingsFoldout = true;
private static bool _guiAudioSettingsFoldout = false;
private static bool _guiAudioSettingsPlaybackFoldout = false;
private static bool _guiAudioSettingsAudioSourceFoldout = false;
private static bool _guiPlaylistsFoldout = false;
private static bool _guiEventsFoldout = false;
#endregion
#region Private Variables
private CVRVideoPlayer _player;
#endregion
#region Serialized Properties
private SerializedProperty m_SyncEnabledProp;
private SerializedProperty m_InteractiveUIProp;
private SerializedProperty m_VideoPlayerUIPositionProp;
private SerializedProperty m_ProjectionTextureProp;
private SerializedProperty m_AutoplayProp;
private SerializedProperty m_LocalPlaybackSpeedProp;
private SerializedProperty m_PlaybackVolumeProp;
private SerializedProperty m_AudioPlaybackModeProp;
private SerializedProperty m_CustomAudioSourceProp;
private SerializedProperty m_RoomScaleAudioSourcesProp;
private SerializedProperty m_StartedPlaybackProp;
private SerializedProperty m_FinishedPlaybackProp;
private SerializedProperty m_PausedPlaybackProp;
private SerializedProperty m_SetUrlProp;
#endregion
#region Unity Events
private void OnEnable()
{
if (target == null) return;
_player = (CVRVideoPlayer)target;
m_SyncEnabledProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.syncEnabled));
m_InteractiveUIProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.interactiveUI));
m_VideoPlayerUIPositionProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.videoPlayerUIPosition));
m_ProjectionTextureProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.ProjectionTexture));
m_AutoplayProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.autoplay));
m_LocalPlaybackSpeedProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.localPlaybackSpeed));
m_PlaybackVolumeProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.playbackVolume));
m_AudioPlaybackModeProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.audioPlaybackMode));
m_CustomAudioSourceProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.customAudioSource));
m_RoomScaleAudioSourcesProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.roomScaleAudioSources));
m_StartedPlaybackProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.startedPlayback));
m_FinishedPlaybackProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.finishedPlayback));
m_PausedPlaybackProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.pausedPlayback));
m_SetUrlProp = serializedObject.FindProperty(nameof(CVRVideoPlayer.setUrl));
}
public override void OnInspectorGUI()
{
if (_player == null)
return;
serializedObject.Update();
Draw_GeneralSettings();
Draw_AudioSettings();
Draw_Playlists();
Draw_Events();
serializedObject.ApplyModifiedProperties();
}
#endregion
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d389338725868141ae73753b40a30f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,108 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRVideoPlayerEditor
{
private ReorderableList _roomScaleAudioSourcesList;
private void Draw_AudioSettings()
{
using (new FoldoutScope(ref _guiAudioSettingsFoldout, "Audio Settings"))
{
if (!_guiAudioSettingsFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawAudioSettings();
}
}
private void DrawAudioSettings()
{
GUILayout.BeginVertical();
DrawPlaybackSettings();
EditorGUILayout.Space();
DrawAudioSources();
GUILayout.EndVertical();
}
#region Drawing Methods
private void DrawPlaybackSettings()
{
if (!InnerFoldout(ref _guiAudioSettingsPlaybackFoldout, "Playback"))
return;
EditorGUILayout.PropertyField(m_AutoplayProp, new GUIContent("Play On Awake"));
EditorGUILayout.Slider(m_LocalPlaybackSpeedProp, 0.0f, 1.0f, new GUIContent("Playback Speed"));
EditorGUILayout.PropertyField(m_PlaybackVolumeProp, new GUIContent("Playback Volume"), true);
EditorGUILayout.PropertyField(m_AudioPlaybackModeProp, new GUIContent("Audio Playback Mode"), true);
switch (_player.audioPlaybackMode)
{
default:
case CVRVideoPlayer.AudioMode.Direct:
EditorGUILayout.HelpBox("This will output the audio in a direct way using 2D Audio Sources. No special setup required, works out of the box.", MessageType.Info);
break;
case CVRVideoPlayer.AudioMode.AudioSource:
EditorGUILayout.HelpBox("This will use the provided Custom Audio Source to determine its settings such as fall of range (min, max) and more.", MessageType.Info);
break;
case CVRVideoPlayer.AudioMode.RoomScale:
EditorGUILayout.HelpBox("The Room Scale Audio Playback Mode should only be used when playing 5.1 or 7.1 audio. As well as a specific setup of such speakers, audio sources, is required for it to output good results. Stereo Audio will render degraded when using the room scale output mode. ", MessageType.Info);
break;
}
}
private void DrawAudioSources()
{
if (!InnerFoldout(ref _guiAudioSettingsAudioSourceFoldout, "Audio Sources"))
return;
EditorGUILayout.PropertyField(m_CustomAudioSourceProp, new GUIContent("Custom Audio Source"), true);
if (_roomScaleAudioSourcesList == null)
{
_roomScaleAudioSourcesList = new ReorderableList(
serializedObject,
m_RoomScaleAudioSourcesProp,
true, true, true, true);
_roomScaleAudioSourcesList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
{
Rect _rect = new Rect(rect.x, rect.y + 2, rect.width, EditorGUIUtility.singleLineHeight);
SerializedProperty element = _roomScaleAudioSourcesList.serializedProperty.GetArrayElementAtIndex(index);
float halfWidth = _rect.width * 0.5f;
EditorGUI.PropertyField(
new Rect(_rect.x, _rect.y, halfWidth, EditorGUIUtility.singleLineHeight),
element.FindPropertyRelative("type"), GUIContent.none);
EditorGUI.PropertyField(
new Rect(_rect.x + halfWidth, _rect.y, halfWidth, EditorGUIUtility.singleLineHeight),
element.FindPropertyRelative("audioSource"), GUIContent.none);
};
_roomScaleAudioSourcesList.elementHeight = EditorGUIUtility.singleLineHeight + 4f;
_roomScaleAudioSourcesList.drawHeaderCallback = (Rect rect) =>
{
EditorGUI.LabelField(rect, "Room Scale Audio Sources");
//EditorGUIExtensions.UtilityMenu(rect, _roomScaleAudioSourcesList); // TODO: Make utility menu work with serialized properties
};
}
using (new SetIndentLevelScope(0))
{
using (new EditorGUILayout.VerticalScope(new GUIStyle() { padding = new RectOffset(15, 0, 5, 5) }))
_roomScaleAudioSourcesList.DoLayoutList();
}
}
#endregion
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 93df7125d8625674d9a208e8e7b61c87
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRVideoPlayerEditor
{
private void Draw_Events()
{
using (new FoldoutScope(ref _guiEventsFoldout, "Events"))
{
if (!_guiEventsFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawEvents();
}
}
private void DrawEvents()
{
GUILayout.BeginVertical();
EditorGUILayout.PropertyField(m_StartedPlaybackProp, true);
EditorGUILayout.PropertyField(m_FinishedPlaybackProp, true);
EditorGUILayout.PropertyField(m_PausedPlaybackProp, true);
EditorGUILayout.PropertyField(m_SetUrlProp, true);
GUILayout.EndVertical();
}
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f56c30524fd7f684eb12c9426ddd4e2a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,57 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRVideoPlayerEditor
{
private void Draw_GeneralSettings()
{
using (new FoldoutScope(ref _guiGeneralSettingsFoldout, "General Settings"))
{
if (!_guiGeneralSettingsFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawGeneralSettings();
}
}
private void DrawGeneralSettings()
{
GUILayout.BeginVertical();
EditorGUILayout.PropertyField(m_SyncEnabledProp, new GUIContent("Network Sync"));
EditorGUILayout.PropertyField(m_InteractiveUIProp, new GUIContent("Use Interactive Library UI"));
EditorGUILayout.PropertyField(m_VideoPlayerUIPositionProp, new GUIContent("UI Position/Parent"));
//EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_ProjectionTextureProp, new GUIContent("Projection Texture"));
if (m_ProjectionTextureProp.objectReferenceValue == null)
{
Separator();
using (new SetIndentLevelScope(0))
{
EditorGUILayout.HelpBox("The video player output texture is empty, please fill it or no video will be drawn.", MessageType.Warning);
if (GUILayout.Button("Auto Create Render Texture"))
{
RenderTexture tex = new RenderTexture(1920, 1080, 24);
if (!AssetDatabase.IsValidFolder("Assets/ABI.Generated"))
AssetDatabase.CreateFolder("Assets", "ABI.Generated");
if (!AssetDatabase.IsValidFolder("Assets/ABI.Generated/VideoPlayer"))
AssetDatabase.CreateFolder("Assets/ABI.Generated", "VideoPlayer");
if (!AssetDatabase.IsValidFolder("Assets/ABI.Generated/VideoPlayer/RenderTextures"))
AssetDatabase.CreateFolder("Assets/ABI.Generated/VideoPlayer", "RenderTextures");
AssetDatabase.CreateAsset(tex,
"Assets/ABI.Generated/VideoPlayer/RenderTextures/" + ((MonoBehaviour)serializedObject.targetObject).gameObject.GetInstanceID() + ".renderTexture");
m_ProjectionTextureProp.objectReferenceValue = tex;
}
}
}
GUILayout.EndVertical();
}
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1a77b7a862e1b14a8b2dcd83d8436b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,165 @@
#if UNITY_EDITOR
using ABI.CCK.Scripts.Editor;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRVideoPlayerEditor
{
private const string TypeLabel = "Playlists";
private ReorderableList _playlistList;
private void Draw_Playlists()
{
using (new FoldoutScope(ref _guiPlaylistsFoldout, "Playlists"))
{
if (!_guiPlaylistsFoldout) return;
DrawPlaylists();
}
}
#region Drawing Methods
private void DrawPlaylists()
{
if (_playlistList == null)
{
_playlistList = new ReorderableList(_player.entities, typeof(CVRVideoPlayerPlaylist), true, true, true, true)
{
drawHeaderCallback = OnDrawHeader,
drawElementCallback = OnDrawElement,
elementHeightCallback = OnHeightElement,
onAddCallback = OnAdd,
onChangedCallback = OnChanged
};
}
GUILayout.BeginVertical();
DrawDefaultVideoSelection();
EditorGUILayout.Space();
_playlistList.DoLayoutList();
EditorGUILayout.Space();
GUILayout.EndVertical();
}
private void DrawDefaultVideoSelection()
{
EditorGUILayout.LabelField(new GUIContent("Play On Awake Object", "Default video to play on start/awake"), new GUIContent(_player.playOnAwakeObject?.videoTitle));
if (GUILayout.Button("Remove Play on Awake Object")) _player.playOnAwakeObject = null;
}
#endregion
#region Playlist ReorderableList
private float OnHeightElement(int index)
{
var height = 0f;
if (!_player.entities[index].isCollapsed) return EditorGUIUtility.singleLineHeight * 1.25f;
height += EditorGUIUtility.singleLineHeight * (3f + 2.5f);
if (_player.entities[index].playlistVideos.Count == 0) height += 1.25f * EditorGUIUtility.singleLineHeight;
foreach (var entry in _player.entities[index].playlistVideos)
{
if (entry == null)
{
height += 1.25f * EditorGUIUtility.singleLineHeight;
}
else
{
height += (entry.isCollapsed ? 7.5f : 1.25f) * EditorGUIUtility.singleLineHeight;
}
}
return height;
}
private void OnDrawHeader(Rect rect)
{
Rect rectA = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(rectA, TypeLabel);
EditorGUIExtensions.UtilityMenu(rectA, _playlistList);
}
private void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
if (index > _player.entities.Count) return;
rect.y += 2;
rect.x += 12;
rect.width -= 12;
Rect rectA = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
EditorGUI.BeginChangeCheck();
bool collapse = EditorGUI.Foldout(rectA, _player.entities[index].isCollapsed, "Playlist Title", true);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target, "Playlist Expand");
_player.entities[index].isCollapsed = collapse;
}
rectA.x += 80;
rectA.width = rect.width - 80;
EditorGUI.BeginChangeCheck();
string playlistTitle = EditorGUI.TextField(rectA, _player.entities[index].playlistTitle);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target, "Playlist Title");
_player.entities[index].playlistTitle = playlistTitle;
}
if (!_player.entities[index].isCollapsed) return;
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
rectA = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(rectA, "Thumbnail Url");
rectA.x += 80;
rectA.width = rect.width - 80;
EditorGUI.BeginChangeCheck();
string playlistThumbnailUrl = EditorGUI.TextField(rectA, _player.entities[index].playlistThumbnailUrl);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target, "Playlist Thumbnail Url");
_player.entities[index].playlistThumbnailUrl = playlistThumbnailUrl;
}
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
//_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
var videoList = _player.entities[index].GetReorderableList(_player);
videoList.DoList(new Rect(rect.x, rect.y, rect.width, 20f));
}
private void OnAdd(ReorderableList list)
{
Undo.RecordObject(target, "Add Playlist Entry");
_player.entities.Add(null);
}
private void OnChanged(ReorderableList list)
{
Undo.RecordObject(target, "Playlist List changed");
}
#endregion
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8071bc6b13952e34fa40bf5d4f3860c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: