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,121 @@
using System;
using UnityEditor;
using UnityEngine;
namespace ABI.CCK.Components
{
[CanEditMultipleObjects]
[CustomEditor(typeof(GravityZone))]
public partial class CCK_GravityZoneEditor : Editor
{
#region EditorGUI Foldouts
private static bool _guiAreaConfigurationFoldout = true;
private static bool _guiGeneralSettingsFoldout = true;
private static bool _guiGizmoSettingsFoldout;
#endregion
#region Private Variables
private GravityZone _gravityZone;
#endregion
#region Serialized Properties
private SerializedProperty m_ZoneShape;
private SerializedProperty m_CustomZoneShapeMesh;
private SerializedProperty m_Center;
private SerializedProperty m_Size;
private SerializedProperty m_GravityDirection;
private SerializedProperty m_GravityMix;
private SerializedProperty m_Priority;
private SerializedProperty m_GravityType;
private SerializedProperty m_Strength;
private SerializedProperty m_GravityEffect;
private SerializedProperty m_GravityFalloff;
private SerializedProperty m_PlayerGravityAlignmentMode;
private SerializedProperty m_PlayerGravityCustomAlignmentValue;
#endregion
#region Unity Events
private void OnEnable()
{
if (target == null) return;
_gravityZone = (GravityZone) target;
m_ZoneShape = serializedObject.FindProperty(nameof(GravityZone.zoneShape));
m_CustomZoneShapeMesh = serializedObject.FindProperty(nameof(GravityZone.customZoneShapeMesh));
m_Center = serializedObject.FindProperty(nameof(GravityZone.center));
m_Size = serializedObject.FindProperty(nameof(GravityZone.size));
m_GravityDirection = serializedObject.FindProperty(nameof(GravityZone.gravityDirection));
m_GravityMix = serializedObject.FindProperty(nameof(GravityZone.gravityMix));
m_Priority = serializedObject.FindProperty(nameof(GravityZone.priority));
m_GravityType = serializedObject.FindProperty(nameof(GravityZone.gravityType));
m_Strength = serializedObject.FindProperty(nameof(GravityZone.strength));
m_GravityEffect = serializedObject.FindProperty(nameof(GravityZone.gravityEffect));
m_GravityFalloff = serializedObject.FindProperty(nameof(GravityZone.gravityFalloff));
m_PlayerGravityAlignmentMode = serializedObject.FindProperty(nameof(GravityZone.playerGravityAlignmentMode));
m_PlayerGravityCustomAlignmentValue = serializedObject.FindProperty(nameof(GravityZone.playerGravityCustomAlignmentValue));
}
public override void OnInspectorGUI()
{
if (_gravityZone == null)
return;
serializedObject.Update();
//Draw_CustomModeColliderWarning();
Draw_ZoneSettings();
Draw_GeneralSettings();
Draw_GizmoSettings();
serializedObject.ApplyModifiedProperties();
}
public void OnSceneGUI()
{
if (_gravityZone == null)
return;
// force scene gizmos to update when inspector is visible
SceneView.RepaintAll();
}
#endregion
#region Drawing Methods
private void Draw_CustomModeColliderWarning()
{
if ((GravityZone.ZoneShape)m_ZoneShape.intValue != GravityZone.ZoneShape.Custom)
return;
MeshCollider collider = _gravityZone.GetComponent<MeshCollider>();
if (collider == null || !collider.isTrigger || collider.sharedMesh == null)
{
EditorGUILayout.HelpBox("When in custom Mode, a MeshCollider setup as Trigger is needed on this GameObject!", MessageType.Error);
}
}
#endregion
#region Gizmos Drawing
[DrawGizmo(GizmoType.Selected)]
private static void OnGizmosSelected(GravityZone zone, GizmoType _) => DrawGizmos(zone, true);
[DrawGizmo(GizmoType.NotInSelectionHierarchy)]
private static void OnGizmoNotSelected(GravityZone zone, GizmoType _) => DrawGizmos(zone, false);
private static void DrawGizmos(GravityZone zone, bool isSelected)
=> CCK_GravityZoneGizmos.DrawGizmo(zone, isSelected);
#endregion
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ea9ee38c88a349d58598a50ea59d8869
timeCreated: 1698178255

View file

@ -0,0 +1,98 @@
#if UNITY_EDITOR
using System.Linq;
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_GravityZoneEditor
{
private void Draw_ZoneSettings()
{
using (new FoldoutScope(ref _guiAreaConfigurationFoldout, "Zone Configuration"))
{
if (!_guiAreaConfigurationFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawZoneSettings();
}
}
private void DrawZoneSettings()
{
EditorGUILayout.PropertyField(m_ZoneShape, new GUIContent("Zone Shape"));
if (serializedObject.isEditingMultipleObjects)
{
GravityZone.ZoneShape mainShape = (GravityZone.ZoneShape) m_ZoneShape.intValue;
if (serializedObject.targetObjects.Cast<GravityZone>().Any(zone => zone.zoneShape != mainShape))
{
EditorGUILayout.HelpBox("Cannot multi-edit Shape options of conflicting Shape types!", MessageType.Info);
return;
}
}
GravityZone.ZoneShape shape = (GravityZone.ZoneShape) m_ZoneShape.intValue;
if (shape != GravityZone.ZoneShape.Custom) EditorGUILayout.PropertyField(m_Center, new GUIContent("Center"));
float radius;
float height;
switch (shape)
{
case GravityZone.ZoneShape.Box:
EditorGUILayout.PropertyField(m_Size, new GUIContent("Size"));
EditorGUILayout.PropertyField(m_GravityDirection, new GUIContent("GravityDirection"));
break;
case GravityZone.ZoneShape.Sphere:
case GravityZone.ZoneShape.HalfSphere:
case GravityZone.ZoneShape.QuarterSphere:
radius = EditorGUILayout.FloatField("Radius", m_Size.vector3Value.x);
//m_Size.vector3Value = Vector3.right * radius;
Vector3 sphereValue = m_Size.vector3Value;
sphereValue.x = radius;
m_Size.vector3Value = sphereValue;
m_GravityDirection.intValue = (int) GravityZone.GravityDirection.TowardsCenter;
break;
case GravityZone.ZoneShape.Capsule:
case GravityZone.ZoneShape.HalfCapsule:
case GravityZone.ZoneShape.QuarterCapsule:
radius = EditorGUILayout.FloatField("Radius", m_Size.vector3Value.x);
height = EditorGUILayout.FloatField("Height", m_Size.vector3Value.y);
height = Mathf.Max(height, radius * 2f);
//m_Size.vector3Value = Vector3.right * radius + Vector3.up * height;
Vector3 capsuleValue = m_Size.vector3Value;
capsuleValue.x = radius;
capsuleValue.y = height;
m_Size.vector3Value = capsuleValue;
m_GravityDirection.intValue = (int) GravityZone.GravityDirection.TowardsCenter;
break;
case GravityZone.ZoneShape.Cylinder:
case GravityZone.ZoneShape.HalfCylinder:
case GravityZone.ZoneShape.QuarterCylinder:
radius = EditorGUILayout.FloatField("Radius", m_Size.vector3Value.x);
height = EditorGUILayout.FloatField("Height", m_Size.vector3Value.y);
//m_Size.vector3Value = Vector3.right * radius + Vector3.up * height;
Vector3 cylinderValue = m_Size.vector3Value;
cylinderValue.x = radius;
cylinderValue.y = height;
m_Size.vector3Value = cylinderValue;
m_GravityDirection.intValue = (int) GravityZone.GravityDirection.TowardsCenter;
break;
case GravityZone.ZoneShape.Custom:
EditorGUILayout.PropertyField(m_CustomZoneShapeMesh, new GUIContent("Custom Mesh"));
m_GravityDirection.intValue = (int) GravityZone.GravityDirection.TowardsCenter;
if (m_CustomZoneShapeMesh.objectReferenceValue == null)
{
Rect rect = EditorGUILayout.GetControlRect();
rect.x += EditorGUI.indentLevel * 15f;
rect.width -= EditorGUI.indentLevel * 15f;
EditorGUI.HelpBox(rect, "Custom Mesh cannot be null!", MessageType.Error);
}
break;
}
}
}
}
#endif

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 513af8917872469b8f6e14d0c5b7fa53
timeCreated: 1706314962

View file

@ -0,0 +1,48 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_GravityZoneEditor
{
private void Draw_GeneralSettings()
{
using (new FoldoutScope(ref _guiGeneralSettingsFoldout, "General Configuration"))
{
if (!_guiGeneralSettingsFoldout) return;
using (new EditorGUI.IndentLevelScope()) {
DrawGeneralSettings();
if (_gravityZone.gravityEffect.HasFlag(GravityZone.GravityEffect.Players))
DrawPlayerGravityAlignmentSettings();
}
}
}
private void DrawGeneralSettings()
{
EditorGUILayout.PropertyField(m_GravityMix, new GUIContent("Mix"));
EditorGUILayout.PropertyField(m_Priority, new GUIContent("Priority"));
EditorGUILayout.PropertyField(m_GravityType, new GUIContent("Type"));
EditorGUILayout.HelpBox("When relative Type is selected, Strength is handled as a multiplier of the world gravity", MessageType.Info);
EditorGUILayout.PropertyField(m_Strength, new GUIContent("Strength"));
EditorGUILayout.PropertyField(m_GravityEffect, new GUIContent("Effected Objects"));
//EditorGUILayout.PropertyField(m_GravityFalloff, new GUIContent("Falloff")); // not implemented yet
}
private void DrawPlayerGravityAlignmentSettings() {
EditorGUILayout.PropertyField(m_PlayerGravityAlignmentMode, new GUIContent("Player Gravity Alignment Mode"));
if (_gravityZone.playerGravityAlignmentMode == GravityZone.PlayerAlignmentMode.Custom)
EditorGUILayout.PropertyField(m_PlayerGravityCustomAlignmentValue, new GUIContent("Rotation Speed (Degrees/second)"));
if (_gravityZone.playerGravityAlignmentMode != GravityZone.PlayerAlignmentMode.Auto)
EditorGUILayout.HelpBox("Only the gravity alignment mode Auto can be overriden by player settings. " +
"The other options might cause motion sickness to the users since if ignores their settings.", MessageType.Warning);
}
}
}
#endif

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f7082da914a64c608a6187a9818b8a6b
timeCreated: 1699818570

View file

@ -0,0 +1,28 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using static ABI.CCK.Scripts.Editor.SharedComponentGUI;
namespace ABI.CCK.Components
{
public partial class CCK_GravityZoneEditor
{
private void Draw_GizmoSettings()
{
using (new FoldoutScope(ref _guiGizmoSettingsFoldout, "Editor Gizmos"))
{
if (!_guiGizmoSettingsFoldout) return;
using (new EditorGUI.IndentLevelScope())
DrawGizmoSettings();
}
}
private void DrawGizmoSettings()
{
CCK_GravityZoneGizmos.DrawGizmos = EditorGUILayout.Toggle("Draw Gizmos", CCK_GravityZoneGizmos.DrawGizmos);
CCK_GravityZoneGizmos.GravityVisualAnimation = EditorGUILayout.Toggle("Gravity Visual Animation", CCK_GravityZoneGizmos.GravityVisualAnimation);
CCK_GravityZoneGizmos.OpacityMultiplier = EditorGUILayout.Slider("Opacity", CCK_GravityZoneGizmos.OpacityMultiplier, 0f, 1f);
}
}
}
#endif

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 401b78203ba44a87b58e3e085891c6a7
timeCreated: 1706315773