#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using SLZ.Marrow.Utilities; using SLZ.Marrow.Warehouse; using SLZ.MarrowEditor; using UnityEditor; using UnityEditor.SceneManagement; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.UIElements; namespace SLZ.Marrow { [CanEditMultipleObjects] [CustomEditor(typeof(ImpactProperties))] public class ImpactPropertiesEditor : Editor { ImpactProperties script; private static GUIContent previewMeshGizmoIcon = null; private static GUIContent materialIconOn = null; private static GUIContent materialIconOff = null; public ToolbarToggle showPreviewMeshToolbarToggle; private static List allGameObjects = new List(); private static List unattachedColsMissingImpactProperties = new List(); private static List rbAttachedColsMissingImpactProperties = new List(); VisualElement applyPhysMatsContainer; private static GameObject m_LastHoveredObject; private void OnEnable() { script = (ImpactProperties)target; if (previewMeshGizmoIcon == null) { previewMeshGizmoIcon = new GUIContent(EditorGUIUtility.IconContent("d_GizmosToggle On@2x")); previewMeshGizmoIcon.tooltip = "Toggle Preview Mesh Gizmo"; } if (allGameObjects == null) { allGameObjects = new List(); } if (allGameObjects?.Count == 0) { allGameObjects = FindObjectsOfType().ToList(); foreach (GameObject gameObj in allGameObjects) { if (gameObj.TryGetComponent(out var gameObjHasCol) && !gameObjHasCol.isTrigger) { if (!gameObj.GetComponent()) { if (gameObjHasCol.attachedRigidbody == null) { if (!unattachedColsMissingImpactProperties.Contains(gameObj)) { unattachedColsMissingImpactProperties.Add(gameObj); } } else { if (gameObjHasCol.attachedRigidbody.gameObject.GetComponent() == null) { if (!rbAttachedColsMissingImpactProperties.Contains(gameObjHasCol.attachedRigidbody.gameObject)) { rbAttachedColsMissingImpactProperties.Add(gameObjHasCol.attachedRigidbody.gameObject); } } } } } } } } public override VisualElement CreateInspectorGUI() { string VISUALTREE_PATH = AssetDatabase.GUIDToAssetPath("2956736148bce0e4eb269d7c6a26fb1f"); VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath(VISUALTREE_PATH); VisualElement tree = visualTree.Instantiate(); VisualElement validationFeedback = tree.Q("validationFeedback"); PropertyField surfaceDataCardField = tree.Q("_surfaceDataCard"); EnumField decalTypeField = tree.Q("DecalType"); PropertyField surfaceDataField = tree.Q("surfaceData"); if (serializedObject.FindProperty("surfaceData") == null) { surfaceDataField.style.display = DisplayStyle.None; } applyPhysMatsContainer = tree.Q("applyPhysMatsContainer"); PhysicMaterial suggestedPhysMat = null; Label suggsetedPhysMatLabel = tree.Q