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,81 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using ABI.CCK.Scripts;
using UnityEditor;
// TODO: Rename parent folder to CCK_CVRAdvancedAvatarSettingsTriggerEditor
// I fucked up and forgot the Editor postfix, its driving me mad.
// We cannot fix it without requiring clean reimport of the CCK, so it should wait for huge refactor?
namespace ABI.CCK.Components
{
[CanEditMultipleObjects]
[CustomEditor(typeof(CVRAdvancedAvatarSettingsTrigger))]
public partial class CCK_CVRAdvancedAvatarSettingsTriggerEditor : Editor
{
#region EditorGUI Foldouts
private static bool _guiAreaConfigurationFoldout = true;
private static bool _guiInteractionFilterFoldout = true;
private static bool _guiAllowedFilterFoldout;
private static bool _guiTriggerSettingsFoldout;
#endregion
private CVRAdvancedAvatarSettingsTrigger _trigger;
private List<string> _avatarParameterNames;
#region Unity Events
private void OnEnable()
{
if (target == null) return;
_trigger = (CVRAdvancedAvatarSettingsTrigger)target;
CVRAvatar avatar = _trigger.GetComponentInParent<CVRAvatar>();
if (avatar != null && avatar.overrides != null)
_avatarParameterNames = CVRCommon.GetParametersFromControllerAsString(avatar.overrides, CVRCommon.NonCoreFilter);
else
_avatarParameterNames = new List<string>();
}
public override void OnInspectorGUI()
{
if (_trigger == null)
return;
serializedObject.Update();
Draw_TriggerMode();
Draw_AreaSettings();
Draw_FilterSettings();
if (!_trigger.useAdvancedTrigger)
{
Draw_SimpleTasks();
}
else
{
Draw_AllowedFilterSettings();
Draw_AdvancedTasks();
}
serializedObject.ApplyModifiedProperties();
}
#endregion
#region Drawing Methods
private void Draw_TriggerMode()
{
int newSelectedIndex = EditorGUILayout.Popup("Trigger Mode", _trigger.useAdvancedTrigger ? 1 : 0,
new[] { "Simple", "Advanced" });
_trigger.useAdvancedTrigger = (newSelectedIndex == 1);
}
#endregion
}
}
#endif

View file

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

View file

@ -0,0 +1,386 @@
#if UNITY_EDITOR
using System.Linq;
using ABI.CCK.Scripts;
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_CVRAdvancedAvatarSettingsTriggerEditor
{
// Allow
private ReorderableList _allowedTypesList;
private ReorderableList _allowedPointersList;
// Tasks
private ReorderableList _onEnterList;
private ReorderableList _onExitList;
private ReorderableList _onStayList;
private void Draw_AllowedFilterSettings()
{
using (new FoldoutScope(ref _guiAllowedFilterFoldout, "Allowed Filter"))
{
if (!_guiAllowedFilterFoldout) return;
DrawAllowedFilterSettings();
}
}
private void Draw_AdvancedTasks()
{
using (new FoldoutScope(ref _guiTriggerSettingsFoldout, "Trigger Tasks"))
{
if (!_guiTriggerSettingsFoldout) return;
DrawAdvancedTasks();
}
}
#region Drawing Methods
private void DrawAllowedFilterSettings()
{
if (_allowedPointersList == null)
{
_allowedPointersList = new ReorderableList(serializedObject,
serializedObject.FindProperty("allowedPointer"), false, true, true, false)
{
drawHeaderCallback = OnDrawHeaderAllowedPointers,
drawElementCallback = OnDrawElementAllowedPointers,
elementHeightCallback = OnElementHeight,
onChangedCallback = OnChanged
};
}
if (_allowedTypesList == null)
{
_allowedTypesList = new ReorderableList(serializedObject,
serializedObject.FindProperty("allowedTypes"), false, true, true, false)
{
drawHeaderCallback = OnDrawHeaderAllowedTypes,
drawElementCallback = OnDrawElementAllowedTypes,
elementHeightCallback = OnElementHeight,
onChangedCallback = OnChanged
};
}
int newSelectedIndex;
int currentMode = (_allowedPointersList.count > 0) ? 1 : 0;
using (new EditorGUI.IndentLevelScope())
newSelectedIndex = EditorGUILayout.Popup("Allow Filter Mode", currentMode, new[] { "Type", "Reference" });
// This is so jank... Why are they one or the other???
if (newSelectedIndex != currentMode) {
if (newSelectedIndex == 0) {
_allowedPointersList.serializedProperty.arraySize = 0;
} else {
_allowedPointersList.serializedProperty.arraySize = 1;
_allowedPointersList.serializedProperty.GetArrayElementAtIndex(0).objectReferenceValue = null;
}
}
Separator();
if (newSelectedIndex == 0) {
EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ADVAVTR_TRIGGER_ALLOWED_TYPES_HELPBOX"), MessageType.Info);
_allowedTypesList.DoLayoutList();
} else {
EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ADVAVTR_TRIGGER_ALLOWED_POINTERS_HELPBOX"), MessageType.Info);
_allowedPointersList.DoLayoutList();
}
}
private void DrawAdvancedTasks()
{
if (_onEnterList == null)
{
_onEnterList = new ReorderableList(_trigger.enterTasks,
typeof(CVRAdvancedAvatarSettingsTriggerTask),
false, true, true, true)
{
drawHeaderCallback = OnDrawHeaderEnter,
drawElementCallback = OnDrawElementEnter,
elementHeightCallback = OnHeightElementEnter,
onChangedCallback = OnChangedEnter
};
}
if (_onExitList == null)
{
_onExitList = new ReorderableList(_trigger.exitTasks, typeof(CVRAdvancedAvatarSettingsTriggerTask),
false, true, true, true)
{
drawHeaderCallback = OnDrawHeaderExit,
drawElementCallback = OnDrawElementExit,
elementHeightCallback = OnHeightElementExit,
onChangedCallback = OnChangedExit
};
}
if (_onStayList == null)
{
_onStayList = new ReorderableList(_trigger.stayTasks,
typeof(CVRAdvancedAvatarSettingsTriggerTaskStay),
false, true, true, true)
{
drawHeaderCallback = OnDrawHeaderStay,
drawElementCallback = OnDrawElementStay,
elementHeightCallback = OnHeightElementStay,
onChangedCallback = OnChangedStay
};
}
_onEnterList.DoLayoutList();
EditorGUILayout.Space();
_onExitList.DoLayoutList();
EditorGUILayout.Space();
_onStayList.DoLayoutList();
EditorGUILayout.Space();
if (_trigger.stayTasks.Count > 0)
{
_trigger.sampleDirection = (CVRAdvancedAvatarSettingsTrigger.SampleDirection)
EditorGUILayout.EnumPopup("Sample Direction", _trigger.sampleDirection);
}
}
#endregion
#region ReorderableList AllowLists
private void OnDrawHeaderAllowedTypes(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "Allowed Types");
}
private void OnDrawHeaderAllowedPointers(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "Allowed Pointers");
}
private float OnElementHeight(int index)
{
return 4 + EditorGUIUtility.singleLineHeight;
}
private void OnChanged(ReorderableList list)
{
EditorUtility.SetDirty(_trigger);
}
private void OnDrawElementAllowedTypes(Rect rect, int index, bool isActive, bool isFocused)
{
if (index >= _allowedTypesList.serializedProperty.arraySize) return;
SerializedProperty element = _allowedTypesList.serializedProperty.GetArrayElementAtIndex(index);
GUIContent buttonContent = CVRCommon.DefaultPointerTypes.Contains(element.stringValue)
? EditorGUIExtensions.GetCachedIconContent("Favorite")
: EditorGUIExtensions.GetCachedIconContent("d_editicon.sml");
var newValue = EditorGUIExtensions.AdvancedDropdownInput(
new Rect(rect.x, rect.y + 2, rect.width - 20, EditorGUIUtility.singleLineHeight), element.stringValue,
CVRCommon.DefaultPointerTypes, "Default Pointer Types", buttonContent);
if (newValue != element.stringValue)
{
element.stringValue = newValue;
_allowedTypesList.serializedProperty.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
if (GUI.Button(new Rect(rect.x + rect.width - 18, rect.y + 2, 18, EditorGUIUtility.singleLineHeight), "X"))
{
_allowedTypesList.serializedProperty.DeleteArrayElementAtIndex(index);
_allowedTypesList.serializedProperty.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(_trigger);
}
}
private void OnDrawElementAllowedPointers(Rect rect, int index, bool isActive, bool isFocused)
{
if (index >= _allowedPointersList.serializedProperty.arraySize) return;
SerializedProperty element = _allowedPointersList.serializedProperty.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(new Rect(rect.x, rect.y + 2, rect.width - 20, EditorGUIUtility.singleLineHeight),
element, typeof(CVRPointer), GUIContent.none);
if (GUI.Button(new Rect(rect.x + rect.width - 18, rect.y + 2, 18, EditorGUIUtility.singleLineHeight), "X"))
{
_allowedPointersList.serializedProperty.DeleteArrayElementAtIndex(index);
_allowedPointersList.serializedProperty.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(_trigger);
}
}
#endregion
#region ReorderableList OnEnterTasks
private void OnDrawHeaderEnter(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "On Enter Trigger");
EditorGUIExtensions.UtilityMenu(_rect, _onEnterList);
}
private void OnDrawElementEnter(Rect rect, int index, bool isactive, bool isfocused)
{
if (index >= _trigger.enterTasks.Count) return;
CVRAdvancedAvatarSettingsTriggerTask enterTask = _trigger.enterTasks[index];
Rect _rect = new Rect(rect.x, rect.y + 2, rect.width, EditorGUIUtility.singleLineHeight);
float spacing = EditorGUIUtility.singleLineHeight * 1.25f;
float originalLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 100;
enterTask.settingName = EditorGUIExtensions.AdvancedDropdownInput(_rect, enterTask.settingName, _avatarParameterNames,
"Setting Name", "No Parameters");
_rect.y += spacing;
enterTask.settingValue = EditorGUI.FloatField(_rect, "Setting Value", enterTask.settingValue);
_rect.y += spacing;
enterTask.delay = EditorGUI.FloatField(_rect, "Delay", enterTask.delay);
_rect.y += spacing;
enterTask.holdTime = EditorGUI.FloatField(_rect,"Hold Time", enterTask.holdTime);
_rect.y += spacing;
enterTask.updateMethod =
(CVRAdvancedAvatarSettingsTriggerTask.UpdateMethod)EditorGUI.EnumPopup(_rect, "Update Method", enterTask.updateMethod);
EditorGUIUtility.labelWidth = originalLabelWidth;
}
private float OnHeightElementEnter(int index)
{
return EditorGUIUtility.singleLineHeight * 6.25f;
}
private void OnChangedEnter(ReorderableList list)
{
EditorUtility.SetDirty(_trigger);
}
#endregion
#region ReorderableList OnExitTasks
private void OnDrawHeaderExit(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "On Exit Trigger");
EditorGUIExtensions.UtilityMenu(_rect, _onExitList);
}
private void OnDrawElementExit(Rect rect, int index, bool isactive, bool isfocused)
{
if (index >= _trigger.exitTasks.Count) return;
CVRAdvancedAvatarSettingsTriggerTask exitTask = _trigger.exitTasks[index];
Rect _rect = new Rect(rect.x, rect.y + 2, rect.width, EditorGUIUtility.singleLineHeight);
float spacing = EditorGUIUtility.singleLineHeight * 1.25f;
float originalLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 100;
exitTask.settingName = EditorGUIExtensions.AdvancedDropdownInput(_rect, exitTask.settingName, _avatarParameterNames,
"Setting Name", "No Parameters");
_rect.y += spacing;
exitTask.settingValue = EditorGUI.FloatField(_rect, "Setting Value", exitTask.settingValue);
_rect.y += spacing;
exitTask.delay = EditorGUI.FloatField(_rect, "Delay", exitTask.delay);
_rect.y += spacing;
exitTask.updateMethod =
(CVRAdvancedAvatarSettingsTriggerTask.UpdateMethod)EditorGUI.EnumPopup(_rect, "Update Method", exitTask.updateMethod);
EditorGUIUtility.labelWidth = originalLabelWidth;
}
private float OnHeightElementExit(int index)
{
return EditorGUIUtility.singleLineHeight * 5f;
}
private void OnChangedExit(ReorderableList list)
{
EditorUtility.SetDirty(_trigger);
}
#endregion
#region ReorderableList OnStayTasks
private void OnDrawHeaderStay(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "On Stay Trigger");
EditorGUIExtensions.UtilityMenu(_rect, _onStayList);
}
private void OnDrawElementStay(Rect rect, int index, bool isactive, bool isfocused)
{
if (index >= _trigger.stayTasks.Count) return;
CVRAdvancedAvatarSettingsTriggerTaskStay stayTask = _trigger.stayTasks[index];
Rect _rect = new Rect(rect.x, rect.y + 2, rect.width, EditorGUIUtility.singleLineHeight);
float spacing = EditorGUIUtility.singleLineHeight * 1.25f;
float originalLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 100;
stayTask.settingName = EditorGUIExtensions.AdvancedDropdownInput(_rect, stayTask.settingName, _avatarParameterNames,
"Setting Name", "No Parameters");
_rect.y += spacing;
stayTask.updateMethod =
(CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod)EditorGUI.EnumPopup(_rect,
"Update Method", stayTask.updateMethod);
_rect.y += spacing;
if (stayTask.updateMethod == CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod.SetFromPosition ||
stayTask.updateMethod == CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod.SetFromDistance)
{
stayTask.minValue = EditorGUI.FloatField(_rect, "Min Value", stayTask.minValue);
_rect.y += spacing;
stayTask.maxValue = EditorGUI.FloatField(_rect, "Max Value", stayTask.maxValue);
_rect.y += spacing;
}
else
{
stayTask.minValue = EditorGUI.FloatField(_rect, "Change per sec", stayTask.minValue);
_rect.y += spacing;
}
EditorGUIUtility.labelWidth = originalLabelWidth;
}
private float OnHeightElementStay(int index)
{
if (index >= _trigger.stayTasks.Count) return EditorGUIUtility.singleLineHeight * 3.75f;
CVRAdvancedAvatarSettingsTriggerTaskStay stayTask = _trigger.stayTasks[index];
if (stayTask.updateMethod == CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod.SetFromPosition ||
stayTask.updateMethod == CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod.SetFromDistance)
return EditorGUIUtility.singleLineHeight * 5f;
return EditorGUIUtility.singleLineHeight * 3.75f;
}
private void OnChangedStay(ReorderableList list)
{
EditorUtility.SetDirty(_trigger);
}
#endregion
}
}
#endif

View file

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

View file

@ -0,0 +1,29 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRAdvancedAvatarSettingsTriggerEditor
{
private void Draw_AreaSettings()
{
using (new FoldoutScope(ref _guiAreaConfigurationFoldout, "Area Configuration"))
{
if (!_guiAreaConfigurationFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawAreaSettings();
}
}
private void DrawAreaSettings()
{
GUILayout.BeginVertical();
EditorGUILayout.PropertyField(serializedObject.FindProperty("areaSize"), new GUIContent("Area Size"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("areaOffset"), new GUIContent("Area Offset"));
GUILayout.EndVertical();
}
}
}
#endif

View file

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

View file

@ -0,0 +1,31 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRAdvancedAvatarSettingsTriggerEditor
{
private void Draw_FilterSettings()
{
using (new FoldoutScope(ref _guiInteractionFilterFoldout, "Interaction Filter"))
{
if (!_guiInteractionFilterFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawFilterSettings();
}
}
private void DrawFilterSettings()
{
GUILayout.BeginVertical();
EditorGUILayout.PropertyField(serializedObject.FindProperty("isLocalInteractable"), new GUIContent("Local Interaction"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("isNetworkInteractable"), new GUIContent("Network Interaction"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("allowParticleInteraction"), new GUIContent("Particle Interaction"));
//EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ADVAVTR_TRIGGER_PARTICLE_HELPBOX"), MessageType.Info);
GUILayout.EndVertical();
}
}
}
#endif

View file

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

View file

@ -0,0 +1,37 @@
#if UNITY_EDITOR
using ABI.CCK.Scripts.Editor;
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_CVRAdvancedAvatarSettingsTriggerEditor
{
private void Draw_SimpleTasks()
{
using (new FoldoutScope(ref _guiTriggerSettingsFoldout, "Trigger Settings"))
{
if (!_guiTriggerSettingsFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawSimpleTasks();
}
}
private void DrawSimpleTasks()
{
GUILayout.BeginVertical();
string newName = EditorGUIExtensions.AdvancedDropdownInput(EditorGUILayout.GetControlRect(),
_trigger.settingName, _avatarParameterNames,
"Setting Name", "No Parameters");
if (newName != _trigger.settingName)
serializedObject.FindProperty("settingName").stringValue = newName;
EditorGUILayout.PropertyField(serializedObject.FindProperty("settingValue"), new GUIContent("Setting Value"));
GUILayout.EndVertical();
}
}
}
#endif

View file

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