using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using DM; using Landfall.TABS; using Landfall.TABS.UnitEditor; using Landfall.TABS.Workshop; using Newtonsoft.Json; using PropEditor; using PropEditor.服饰编辑器配置文件1; using PropEditor.模型解析类; using PropEditor.模组配置项; using PropEditor.物品添加类; using PropEditor.翻译器; using PropEditor.配置文件生成类; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Mod name")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("made in SFT by FhpSlime")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class ui推拽脚本 : MonoBehaviour, IDragHandler, IEventSystemHandler, IBeginDragHandler, IEndDragHandler { [Header("拖拽设置")] [SerializeField] private bool enableDrag = true; [SerializeField] private bool dragOnAnyArea = true; [SerializeField] private RectTransform dragHandle; [Header("边界限制")] [SerializeField] private bool restrictWithinParent = true; [SerializeField] private bool restrictWithinCanvas = true; [SerializeField] private Vector2 padding = Vector2.zero; [Header("动画效果")] [SerializeField] private bool smoothDrag = false; [SerializeField] private float smoothSpeed = 10f; [Header("重置位置设置")] [SerializeField] private bool enableResetAnimation = true; [SerializeField] private float resetAnimationDuration = 0.3f; [SerializeField] private AnimationCurve resetCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); [SerializeField] private bool snapToNearestEdge = false; [SerializeField] private Vector2[] presetPositions; private RectTransform rectTransform; private Canvas parentCanvas; private Vector2 originalPosition; private Vector2 dragStartPosition; private Vector2 targetPosition; private bool isDragging = false; private Coroutine resetCoroutine; private int currentPresetIndex = -1; private void Start() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) rectTransform = ((Component)this).GetComponent(); parentCanvas = ((Component)this).GetComponentInParent(); if ((Object)(object)dragHandle == (Object)null && !dragOnAnyArea) { dragHandle = rectTransform; } originalPosition = rectTransform.anchoredPosition; targetPosition = originalPosition; } private void Update() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (smoothDrag && isDragging) { rectTransform.anchoredPosition = Vector2.Lerp(rectTransform.anchoredPosition, targetPosition, smoothSpeed * Time.deltaTime); } } public void OnBeginDrag(PointerEventData eventData) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (enableDrag && CanDrag(eventData)) { if (resetCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resetCoroutine); resetCoroutine = null; } isDragging = true; Transform parent = ((Transform)rectTransform).parent; RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), eventData.position, eventData.pressEventCamera, ref dragStartPosition); OnDragStart(); } } public void OnDrag(PointerEventData eventData) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (enableDrag && isDragging) { Transform parent = ((Transform)rectTransform).parent; Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), eventData.position, eventData.pressEventCamera, ref val); Vector2 val2 = val - dragStartPosition; Vector2 position = rectTransform.anchoredPosition + val2; position = ApplyConstraints(position); if (smoothDrag) { targetPosition = position; } else { rectTransform.anchoredPosition = position; } dragStartPosition = val; OnDragging(); } } public void OnEndDrag(PointerEventData eventData) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (enableDrag) { isDragging = false; if (!smoothDrag) { rectTransform.anchoredPosition = ApplyConstraints(rectTransform.anchoredPosition); } OnDragEnd(); } } private bool CanDrag(PointerEventData eventData) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (dragOnAnyArea) { return true; } if ((Object)(object)dragHandle == (Object)null) { return false; } Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(dragHandle, eventData.position, eventData.pressEventCamera, ref val); Rect rect = dragHandle.rect; return ((Rect)(ref rect)).Contains(val); } private Vector2 ApplyConstraints(Vector2 position) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (!restrictWithinParent && !restrictWithinCanvas) { return position; } Vector2 val = position; Transform parent = ((Transform)rectTransform).parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val2 == (Object)null) { return position; } Rect rect = rectTransform.rect; Vector2 size = ((Rect)(ref rect)).size; Vector2 val3 = size * rectTransform.pivot; Vector2 val4; Vector2 val5; if (restrictWithinParent) { val4 = -val3 + padding; rect = val2.rect; val5 = ((Rect)(ref rect)).size - val3 - padding; } else { if (!restrictWithinCanvas || !((Object)(object)parentCanvas != (Object)null)) { return position; } Rect rect2 = ((Component)parentCanvas).GetComponent().rect; val4 = -val3 + padding; val5 = ((Rect)(ref rect2)).size - val3 - padding; } val.x = Mathf.Clamp(val.x, val4.x, val5.x); val.y = Mathf.Clamp(val.y, val4.y, val5.y); return val; } public void ResetPosition(bool useAnimation = true) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (((Component)this).gameObject.activeInHierarchy) { if (resetCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resetCoroutine); resetCoroutine = null; } isDragging = false; Vector2 nearestEdgePosition = originalPosition; if (snapToNearestEdge && !useAnimation) { nearestEdgePosition = GetNearestEdgePosition(); } nearestEdgePosition = ApplyConstraints(nearestEdgePosition); if (enableResetAnimation && useAnimation) { resetCoroutine = ((MonoBehaviour)this).StartCoroutine(AnimateReset(nearestEdgePosition)); return; } rectTransform.anchoredPosition = nearestEdgePosition; targetPosition = nearestEdgePosition; OnResetComplete(); } } public void ResetToPresetPosition(int presetIndex, bool useAnimation = true) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (presetPositions == null || presetIndex < 0 || presetIndex >= presetPositions.Length) { Debug.LogWarning((object)$"预设位置索引 {presetIndex} 无效!"); return; } if (resetCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resetCoroutine); resetCoroutine = null; } isDragging = false; currentPresetIndex = presetIndex; Vector2 val = ApplyConstraints(presetPositions[presetIndex]); if (enableResetAnimation && useAnimation) { resetCoroutine = ((MonoBehaviour)this).StartCoroutine(AnimateReset(val)); return; } rectTransform.anchoredPosition = val; targetPosition = val; OnResetComplete(); } public void ResetToCenter() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Transform)rectTransform).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val != (Object)null)) { return; } Rect rect = val.rect; Vector2 position = ((Rect)(ref rect)).size * 0.5f; position = ApplyConstraints(position); if (enableResetAnimation) { if (resetCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resetCoroutine); } resetCoroutine = ((MonoBehaviour)this).StartCoroutine(AnimateReset(position)); } else { rectTransform.anchoredPosition = position; targetPosition = position; } } public void SnapToNearestEdge() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Vector2 nearestEdgePosition = GetNearestEdgePosition(); nearestEdgePosition = ApplyConstraints(nearestEdgePosition); if (enableResetAnimation) { if (resetCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resetCoroutine); } resetCoroutine = ((MonoBehaviour)this).StartCoroutine(AnimateReset(nearestEdgePosition)); } else { rectTransform.anchoredPosition = nearestEdgePosition; targetPosition = nearestEdgePosition; } } private Vector2 GetNearestEdgePosition() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Transform)rectTransform).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val == (Object)null) { return originalPosition; } Vector2 anchoredPosition = rectTransform.anchoredPosition; Rect rect = val.rect; Vector2 size = ((Rect)(ref rect)).size; rect = rectTransform.rect; Vector2 size2 = ((Rect)(ref rect)).size; float num = Mathf.Abs(anchoredPosition.x + size2.x * rectTransform.pivot.x); float num2 = Mathf.Abs(size.x - (anchoredPosition.x + size2.x * rectTransform.pivot.x)); float num3 = Mathf.Abs(size.y - (anchoredPosition.y + size2.y * rectTransform.pivot.y)); float num4 = Mathf.Abs(anchoredPosition.y + size2.y * rectTransform.pivot.y); float num5 = Mathf.Min(new float[4] { num, num2, num3, num4 }); Vector2 result = anchoredPosition; if (Mathf.Approximately(num5, num)) { result.x = (0f - size2.x) * rectTransform.pivot.x + padding.x; } else if (Mathf.Approximately(num5, num2)) { result.x = size.x - size2.x * rectTransform.pivot.x - padding.x; } if (Mathf.Approximately(num5, num4)) { result.y = (0f - size2.y) * rectTransform.pivot.y + padding.y; } else if (Mathf.Approximately(num5, num3)) { result.y = size.y - size2.y * rectTransform.pivot.y - padding.y; } return result; } private IEnumerator AnimateReset(Vector2 targetPos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Vector2 startPos = rectTransform.anchoredPosition; float elapsedTime = 0f; while (elapsedTime < resetAnimationDuration) { elapsedTime += Time.deltaTime; float t = elapsedTime / resetAnimationDuration; float curveValue = resetCurve.Evaluate(t); rectTransform.anchoredPosition = Vector2.Lerp(startPos, targetPos, curveValue); targetPosition = rectTransform.anchoredPosition; yield return null; } rectTransform.anchoredPosition = targetPos; targetPosition = targetPos; resetCoroutine = null; OnResetComplete(); } private void OnResetComplete() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)$"UI面板已重置到位置:{rectTransform.anchoredPosition}"); } public void SetAsOriginalPosition() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) originalPosition = rectTransform.anchoredPosition; Debug.Log((object)$"已设置新的初始位置:{originalPosition}"); } public bool IsAtOriginalPosition() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return Vector2.Distance(rectTransform.anchoredPosition, originalPosition) < 0.1f; } public Vector2 GetOriginalPosition() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return originalPosition; } public void ResetPosition() { ResetPosition(useAnimation: true); } public void SetPosition(Vector2 newPosition) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (resetCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resetCoroutine); resetCoroutine = null; } newPosition = ApplyConstraints(newPosition); rectTransform.anchoredPosition = newPosition; targetPosition = newPosition; } public void SetDragEnabled(bool enabled) { enableDrag = enabled; } protected virtual void OnDragStart() { Debug.Log((object)"开始拖拽"); } protected virtual void OnDragging() { } protected virtual void OnDragEnd() { Debug.Log((object)"结束拖拽"); } } public class ui点击事件 : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerDownHandler, IPointerUpHandler { [Header("点击事件设置")] [SerializeField] private ClickMode clickMode = ClickMode.SingleClick; [Header("双击设置")] [SerializeField] private float doubleClickTime = 0.3f; [Header("长按设置")] [SerializeField] private float longPressTime = 0.8f; [SerializeField] private bool triggerLongPressOnUp = false; [SerializeField] private bool continuousLongPress = false; [SerializeField] private float continuousInterval = 0.1f; [Header("视觉反馈")] [SerializeField] private bool provideVisualFeedback = true; [SerializeField] private Color normalColor = Color.white; [SerializeField] private Color pressColor = new Color(0.8f, 0.8f, 0.8f, 1f); [SerializeField] private Color longPressColor = new Color(0.5f, 0.5f, 0.5f, 1f); [Header("音效反馈(可选)")] [SerializeField] private AudioClip clickSound; [SerializeField] private AudioClip doubleClickSound; [SerializeField] private AudioClip longPressSound; [SerializeField] private AudioSource audioSource; [Header("事件响应")] public UnityEvent OnSingleClick; public UnityEvent OnDoubleClick; public UnityEvent OnLongPress; public UnityEvent OnLongPressStart; public UnityEvent OnLongPressEnd; private Image cachedImage; private SpriteRenderer cachedSprite; private float clickTimer = 0f; private float pressTimer = 0f; private bool isPointerDown = false; private bool longPressTriggered = false; private Coroutine continuousLongPressCoroutine; private int clickCount = 0; private void Start() { if (provideVisualFeedback) { cachedImage = ((Component)this).GetComponent(); if ((Object)(object)cachedImage == (Object)null) { cachedSprite = ((Component)this).GetComponent(); } } if ((Object)(object)audioSource == (Object)null && ((Object)(object)clickSound != (Object)null || (Object)(object)doubleClickSound != (Object)null || (Object)(object)longPressSound != (Object)null)) { audioSource = ((Component)this).GetComponent(); if ((Object)(object)audioSource == (Object)null) { audioSource = ((Component)this).gameObject.AddComponent(); } } ResetColor(); } private void Update() { if (clickTimer > 0f) { clickTimer -= Time.deltaTime; if (clickTimer <= 0f) { clickCount = 0; } } if (isPointerDown && !longPressTriggered && clickMode == ClickMode.LongPress) { pressTimer += Time.deltaTime; if (pressTimer >= longPressTime) { TriggerLongPress(); } } } public void OnPointerDown(PointerEventData eventData) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (clickMode == ClickMode.LongPress) { isPointerDown = true; pressTimer = 0f; longPressTriggered = false; if (provideVisualFeedback) { SetColor(pressColor); } } } public void OnPointerUp(PointerEventData eventData) { if (clickMode != ClickMode.LongPress) { return; } isPointerDown = false; if (triggerLongPressOnUp && pressTimer >= longPressTime && !longPressTriggered) { TriggerLongPress(); } if (longPressTriggered) { UnityEvent onLongPressEnd = OnLongPressEnd; if (onLongPressEnd != null) { onLongPressEnd.Invoke(); } } longPressTriggered = false; pressTimer = 0f; if (provideVisualFeedback) { ResetColor(); } } public void OnPointerClick(PointerEventData eventData) { switch (clickMode) { case ClickMode.SingleClick: HandleSingleClick(); break; case ClickMode.DoubleClick: HandleDoubleClick(); break; case ClickMode.LongPress: if (!longPressTriggered && pressTimer < longPressTime) { HandleSingleClick(); } break; } } private void HandleSingleClick() { PlaySound(clickSound); ((MonoBehaviour)this).StartCoroutine(ClickFeedback()); UnityEvent onSingleClick = OnSingleClick; if (onSingleClick != null) { onSingleClick.Invoke(); } Debug.Log((object)("[ui点击事件] " + ((Object)((Component)this).gameObject).name + " 被单击")); } private void HandleDoubleClick() { clickCount++; if (clickCount == 1) { clickTimer = doubleClickTime; } else if (clickCount >= 2) { PlaySound(doubleClickSound); ((MonoBehaviour)this).StartCoroutine(DoubleClickFeedback()); UnityEvent onDoubleClick = OnDoubleClick; if (onDoubleClick != null) { onDoubleClick.Invoke(); } Debug.Log((object)("[ui点击事件] " + ((Object)((Component)this).gameObject).name + " 被双击")); clickCount = 0; clickTimer = 0f; } } private void TriggerLongPress() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (longPressTriggered) { return; } longPressTriggered = true; PlaySound(longPressSound); if (provideVisualFeedback) { SetColor(longPressColor); } UnityEvent onLongPress = OnLongPress; if (onLongPress != null) { onLongPress.Invoke(); } UnityEvent onLongPressStart = OnLongPressStart; if (onLongPressStart != null) { onLongPressStart.Invoke(); } Debug.Log((object)("[ui点击事件] " + ((Object)((Component)this).gameObject).name + " 被长按")); if (continuousLongPress) { if (continuousLongPressCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(continuousLongPressCoroutine); } continuousLongPressCoroutine = ((MonoBehaviour)this).StartCoroutine(ContinuousLongPress()); } } private IEnumerator ContinuousLongPress() { while (isPointerDown && longPressTriggered) { UnityEvent onLongPress = OnLongPress; if (onLongPress != null) { onLongPress.Invoke(); } yield return (object)new WaitForSeconds(continuousInterval); } continuousLongPressCoroutine = null; } private IEnumerator ClickFeedback() { if (provideVisualFeedback) { Color originalColor = GetCurrentColor(); SetColor(new Color(0.7f, 0.7f, 0.7f, 1f)); yield return (object)new WaitForSeconds(0.1f); SetColor(originalColor); } } private IEnumerator DoubleClickFeedback() { if (provideVisualFeedback) { Color originalColor = GetCurrentColor(); SetColor(new Color(0.5f, 0.8f, 0.5f, 1f)); yield return (object)new WaitForSeconds(0.15f); SetColor(originalColor); } } private void PlaySound(AudioClip clip) { if ((Object)(object)clip != (Object)null && (Object)(object)audioSource != (Object)null) { audioSource.PlayOneShot(clip); } } private void SetColor(Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cachedImage != (Object)null) { ((Graphic)cachedImage).color = color; } else if ((Object)(object)cachedSprite != (Object)null) { cachedSprite.color = color; } } private void ResetColor() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) SetColor(normalColor); } private Color GetCurrentColor() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cachedImage != (Object)null) { return ((Graphic)cachedImage).color; } if ((Object)(object)cachedSprite != (Object)null) { return cachedSprite.color; } return normalColor; } public void SetClickMode(ClickMode mode) { clickMode = mode; ResetState(); } private void ResetState() { isPointerDown = false; longPressTriggered = false; pressTimer = 0f; clickCount = 0; clickTimer = 0f; if (continuousLongPressCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(continuousLongPressCoroutine); continuousLongPressCoroutine = null; } ResetColor(); } public void SetLongPressTime(float time) { longPressTime = Mathf.Max(0.1f, time); } public void SetDoubleClickTime(float time) { doubleClickTime = Mathf.Max(0.1f, time); } } [Serializable] public enum ClickMode { SingleClick, DoubleClick, LongPress } public class 实例化子ui自动排序 : MonoBehaviour { [Header("UI引用")] public GameObject 实例化ui; public Transform 自动排列到最后; public Transform 父级; private void Start() { if ((Object)(object)自动排列到最后 != (Object)null && (Object)(object)父级 != (Object)null) { 自动排列到最后.SetAsLastSibling(); } } public void 实例化数据UI() { if ((Object)(object)实例化ui == (Object)null) { Debug.LogError((object)"实例化ui预制体未赋值!"); return; } if ((Object)(object)父级 == (Object)null) { Debug.LogError((object)"父级容器未赋值!"); return; } if ((Object)(object)自动排列到最后 == (Object)null) { Debug.LogError((object)"自动排列到最后(加号按钮)未赋值!"); return; } GameObject val = Object.Instantiate(实例化ui, 父级); val.SetActive(true); val.transform.SetParent(父级, false); 自动排列到最后.SetAsLastSibling(); Debug.Log((object)$"已实例化数据UI,当前子物体数量:{父级.childCount},加号已在最后"); } public void 清空所有数据UI() { if ((Object)(object)父级 == (Object)null) { return; } for (int num = 父级.childCount - 1; num >= 0; num--) { Transform child = 父级.GetChild(num); if (!((Object)(object)child == (Object)(object)自动排列到最后)) { Object.Destroy((Object)(object)((Component)child).gameObject); } } if ((Object)(object)自动排列到最后 != (Object)null) { 自动排列到最后.SetAsLastSibling(); } Debug.Log((object)"已清空所有数据UI"); } } public class 实例化服饰数据核心类 : MonoBehaviour { public Transform[] 所有显示ui; public TMP_Dropdown 指定下拉菜单; public TMP_InputField 缩放数据x; public TMP_InputField 缩放数据y; public TMP_InputField 缩放数据z; public TMP_InputField 位置数据x; public TMP_InputField 位置数据y; public TMP_InputField 位置数据z; public TMP_InputField 旋转数据x; public TMP_InputField 旋转数据y; public TMP_InputField 旋转数据z; public TMP_Dropdown 默认实例几何体下拉菜单; public TMP_InputField 模型名称输入类; public Transform 总体父级; private Transform 实例引用 = null; private bool isUpdatingFromCode = false; private int 当前模式 = -1; private void Start() { if (!模型资源加载类.是否已初始化) { Debug.LogWarning((object)"模型资源加载器尚未初始化,正在自动初始化..."); 模型资源加载类.初始化(); } OnDropdownValueChanged(0); if (Object.op_Implicit((Object)(object)指定下拉菜单)) { ((UnityEvent)(object)指定下拉菜单.onValueChanged).AddListener((UnityAction)OnDropdownValueChanged); } if (Object.op_Implicit((Object)(object)默认实例几何体下拉菜单)) { ((UnityEvent)(object)默认实例几何体下拉菜单.onValueChanged).AddListener((UnityAction)OnDefaultGeometryChanged); } BindInputEvents(); ui获取并生成对应配置 component = ((Component)((Component)this).transform.root).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.所有核心数据.Add(this); } } private void BindInputEvents() { if (Object.op_Implicit((Object)(object)缩放数据x)) { ((UnityEvent)(object)缩放数据x.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)缩放数据y)) { ((UnityEvent)(object)缩放数据y.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)缩放数据z)) { ((UnityEvent)(object)缩放数据z.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)位置数据x)) { ((UnityEvent)(object)位置数据x.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)位置数据y)) { ((UnityEvent)(object)位置数据y.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)位置数据z)) { ((UnityEvent)(object)位置数据z.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)旋转数据x)) { ((UnityEvent)(object)旋转数据x.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)旋转数据y)) { ((UnityEvent)(object)旋转数据y.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)旋转数据z)) { ((UnityEvent)(object)旋转数据z.onEndEdit).AddListener((UnityAction)OnInputChanged); } if (Object.op_Implicit((Object)(object)模型名称输入类)) { ((UnityEvent)(object)模型名称输入类.onEndEdit).AddListener((UnityAction)OnModelNameChanged); } } private void OnModelNameChanged(string modelName) { if (当前模式 == 2) { 重新生成实例(); } } private void OnDropdownValueChanged(int selectedIndex) { if (所有显示ui != null && 所有显示ui.Length == 指定下拉菜单.options.Count) { for (int i = 0; i < 所有显示ui.Length; i++) { ((Component)所有显示ui[i]).gameObject.SetActive(i == selectedIndex); } } 当前模式 = selectedIndex; 更新实例(selectedIndex); } private void OnDefaultGeometryChanged(int selectedIndex) { if (当前模式 == 1) { 重新生成实例(); } } private void 重新生成实例() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) if (当前模式 != 1 && 当前模式 != 2) { return; } Vector3? val = null; Vector3? val2 = null; Vector3? val3 = null; if ((Object)(object)实例引用 != (Object)null) { val = 实例引用.localPosition; val2 = 实例引用.localEulerAngles; val3 = 实例引用.localScale; Object.Destroy((Object)(object)((Component)实例引用).gameObject); 实例引用 = null; } GameObject val4 = null; if (当前模式 == 1) { int geometryType = (Object.op_Implicit((Object)(object)默认实例几何体下拉菜单) ? 默认实例几何体下拉菜单.value : 0); val4 = 创建基本几何体(geometryType); } else if (当前模式 == 2) { string text = (((Object)(object)模型名称输入类 != (Object)null) ? 模型名称输入类.text.Trim() : ""); if (string.IsNullOrEmpty(text)) { Debug.LogWarning((object)"请输入模型名称"); return; } val4 = 模型资源加载类.获取模型克隆(text); if ((Object)(object)val4 == (Object)null) { Debug.LogError((object)("加载模型失败: " + text)); Debug.Log((object)("可用模型列表: " + string.Join(", ", 模型资源加载类.所有模型名称))); return; } Debug.Log((object)("✅ 成功加载模型: " + text)); } if ((Object)(object)val4 != (Object)null) { if ((Object)(object)总体父级 != (Object)null) { val4.transform.SetParent(总体父级); } else { val4.transform.SetParent((Transform)null); } if (val.HasValue) { val4.transform.localPosition = val.Value; val4.transform.localEulerAngles = val2.Value; val4.transform.localScale = val3.Value; } else { val4.transform.localPosition = Vector3.zero; val4.transform.localEulerAngles = Vector3.zero; val4.transform.localScale = Vector3.one; } 实例引用 = val4.transform; 更新实例变换(); Debug.Log((object)$"重新生成实例: {((Object)val4).name},模式: {当前模式}"); } } private GameObject 创建基本几何体(int geometryType) { GameObject val = null; switch (geometryType) { case 0: return GameObject.CreatePrimitive((PrimitiveType)3); case 1: return GameObject.CreatePrimitive((PrimitiveType)0); case 2: return GameObject.CreatePrimitive((PrimitiveType)1); case 3: return GameObject.CreatePrimitive((PrimitiveType)2); default: Debug.LogWarning((object)$"未知的几何体类型: {geometryType},默认创建Cube"); return GameObject.CreatePrimitive((PrimitiveType)3); } } private void OnInputChanged(string submittedText) { if (!((Object)(object)实例引用 == (Object)null) && !isUpdatingFromCode) { 更新实例变换(); } } private void 更新实例变换() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)实例引用 == (Object)null) { return; } try { float num = ParseFloat(位置数据x.text, 0f); float num2 = ParseFloat(位置数据y.text, 0f); float num3 = ParseFloat(位置数据z.text, 0f); 实例引用.localPosition = new Vector3(num, num2, num3); float num4 = ParseFloat(旋转数据x.text, 0f); float num5 = ParseFloat(旋转数据y.text, 0f); float num6 = ParseFloat(旋转数据z.text, 0f); 实例引用.localEulerAngles = new Vector3(num4, num5, num6); float num7 = ParseFloat(缩放数据x.text, 1f); float num8 = ParseFloat(缩放数据y.text, 1f); float num9 = ParseFloat(缩放数据z.text, 1f); 实例引用.localScale = new Vector3(num7, num8, num9); } catch (Exception ex) { Debug.LogWarning((object)("更新实例变换时出错: " + ex.Message)); } } private float ParseFloat(string text, float defaultValue) { if (string.IsNullOrEmpty(text)) { return defaultValue; } if (float.TryParse(text, out var result)) { return result; } return defaultValue; } private void 更新实例(int 模式) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) switch (模式) { case 0: if ((Object)(object)实例引用 != (Object)null) { Object.Destroy((Object)(object)((Component)实例引用).gameObject); 实例引用 = null; } break; case 1: { if ((Object)(object)实例引用 != (Object)null) { Object.Destroy((Object)(object)((Component)实例引用).gameObject); 实例引用 = null; } int num = (Object.op_Implicit((Object)(object)默认实例几何体下拉菜单) ? 默认实例几何体下拉菜单.value : 0); GameObject val2 = 创建基本几何体(num); if ((Object)(object)val2 != (Object)null) { if ((Object)(object)总体父级 != (Object)null) { val2.transform.SetParent(总体父级); } else { val2.transform.SetParent((Transform)null); } val2.transform.localPosition = Vector3.zero; val2.transform.localEulerAngles = Vector3.zero; val2.transform.localScale = Vector3.one; 实例引用 = val2.transform; 更新实例变换(); Debug.Log((object)$"已创建 {((Object)val2).name},几何体类型: {num}"); } break; } case 2: { if ((Object)(object)实例引用 != (Object)null) { Object.Destroy((Object)(object)((Component)实例引用).gameObject); 实例引用 = null; } string text = (((Object)(object)模型名称输入类 != (Object)null) ? 模型名称输入类.text.Trim() : ""); if (string.IsNullOrEmpty(text)) { Debug.LogWarning((object)"请输入模型名称"); break; } if (!模型资源加载类.是否已初始化) { Debug.LogWarning((object)"模型资源加载器尚未初始化,正在自动初始化..."); 模型资源加载类.初始化(); } GameObject val = 模型资源加载类.获取模型克隆(text); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("加载模型失败: " + text)); Debug.Log((object)("可用模型列表: " + string.Join(", ", 模型资源加载类.所有模型名称))); break; } if ((Object)(object)总体父级 != (Object)null) { val.transform.SetParent(总体父级); } else { val.transform.SetParent((Transform)null); } val.transform.localPosition = Vector3.zero; val.transform.localEulerAngles = Vector3.zero; val.transform.localScale = Vector3.one; 实例引用 = val.transform; 更新实例变换(); Debug.Log((object)("✅ 已加载模型: " + text)); break; } } } public void 删除这个ui() { if ((Object)(object)实例引用 != (Object)null) { Object.Destroy((Object)(object)((Component)实例引用).gameObject); 实例引用 = null; } Object.Destroy((Object)(object)((Component)this).gameObject); } private void OnDestroy() { if ((Object)(object)实例引用 != (Object)null) { ui获取并生成对应配置 component = ((Component)((Component)this).transform.root).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.所有核心数据.Remove(this); } Object.Destroy((Object)(object)((Component)实例引用).gameObject); 实例引用 = null; } } } public class 物体切换状态w : MonoBehaviour { [Header("目标物体设置")] public Transform 指定物体; public bool 初始状态 = true; [Header("切换效果")] public bool 使用动画效果 = false; public float 动画时长 = 0.3f; public AnimationCurve 动画曲线 = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); [Header("其他设置")] public bool 切换按钮自身 = false; public bool 自动记录状态 = true; public string 状态存储键 = "UI状态"; [Header("可选:按钮图片变化")] public Image 按钮图片; public Sprite 展开状态图片; public Sprite 关闭状态图片; private RectTransform 目标RectTransform; private Vector2 原始大小; private bool 当前状态; private Coroutine 动画协程; private Vector3 原始位置; private void Start() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) GameObject val = (切换按钮自身 ? ((Component)this).gameObject : (((Object)(object)指定物体 != (Object)null) ? ((Component)指定物体).gameObject : null)); if ((Object)(object)val != (Object)null) { 目标RectTransform = val.GetComponent(); 原始大小 = (((Object)(object)目标RectTransform != (Object)null) ? 目标RectTransform.sizeDelta : Vector2.zero); 原始位置 = ((Transform)目标RectTransform).localPosition; } if (自动记录状态 && PlayerPrefs.HasKey(状态存储键)) { 当前状态 = PlayerPrefs.GetInt(状态存储键) == 1; } else { 当前状态 = 初始状态; } SetUIState(当前状态, useAnimation: false); UpdateButtonImage(); } public void 切换物体状态() { 当前状态 = !当前状态; SetUIState(当前状态, 使用动画效果); if (自动记录状态) { PlayerPrefs.SetInt(状态存储键, 当前状态 ? 1 : 0); PlayerPrefs.Save(); } UpdateButtonImage(); Debug.Log((object)("UI状态切换为:" + (当前状态 ? "展开" : "关闭"))); } private void SetUIState(bool isOpen, bool useAnimation) { GameObject val = (切换按钮自身 ? ((Component)this).gameObject : (((Object)(object)指定物体 != (Object)null) ? ((Component)指定物体).gameObject : null)); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"没有指定要切换的物体!"); return; } if (动画协程 != null) { ((MonoBehaviour)this).StopCoroutine(动画协程); 动画协程 = null; } if (useAnimation && (Object)(object)目标RectTransform != (Object)null) { 动画协程 = ((MonoBehaviour)this).StartCoroutine(动画切换(val, isOpen)); } else { val.SetActive(isOpen); } } private IEnumerator 动画切换(GameObject 目标物体, bool 最终状态) { if (最终状态 && !目标物体.activeSelf) { 目标物体.SetActive(true); if ((Object)(object)目标RectTransform != (Object)null) { ((Transform)目标RectTransform).localScale = new Vector3(1f, 0f, 1f); } } float 当前时间 = 0f; Vector3 起始缩放 = (((Object)(object)目标RectTransform != (Object)null) ? ((Transform)目标RectTransform).localScale : Vector3.one); Vector3 目标缩放 = (最终状态 ? new Vector3(1f, 1f, 1f) : new Vector3(1f, 0f, 1f)); if (!最终状态) { 起始缩放 = (((Object)(object)目标RectTransform != (Object)null) ? ((Transform)目标RectTransform).localScale : Vector3.one); } while (当前时间 < 动画时长) { 当前时间 += Time.deltaTime; float t = 当前时间 / 动画时长; float 曲线值 = 动画曲线.Evaluate(t); if ((Object)(object)目标RectTransform != (Object)null) { ((Transform)目标RectTransform).localScale = Vector3.Lerp(起始缩放, 目标缩放, 曲线值); } yield return null; } if ((Object)(object)目标RectTransform != (Object)null) { ((Transform)目标RectTransform).localScale = 目标缩放; } if (!最终状态) { 目标物体.SetActive(false); } 动画协程 = null; } private void UpdateButtonImage() { if ((Object)(object)按钮图片 != (Object)null) { if (当前状态 && (Object)(object)展开状态图片 != (Object)null) { 按钮图片.sprite = 展开状态图片; } else if (!当前状态 && (Object)(object)关闭状态图片 != (Object)null) { 按钮图片.sprite = 关闭状态图片; } } } public void 展开UI() { if (!当前状态) { 切换物体状态(); } } public void 关闭UI() { if (当前状态) { 切换物体状态(); } } public bool 获取当前状态() { return 当前状态; } public void 重置状态() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ((Transform)目标RectTransform).localPosition = 原始位置; 当前状态 = 初始状态; SetUIState(当前状态, useAnimation: false); UpdateButtonImage(); if (自动记录状态) { PlayerPrefs.SetInt(状态存储键, 当前状态 ? 1 : 0); PlayerPrefs.Save(); } } } public class 第三人称视角类 : MonoBehaviour { [Header("目标对象")] public Transform target; [Header("摄像机参数")] public float distance = 5f; public float minDistance = 1f; public float maxDistance = 15f; public float rotationSpeed = 2f; public float scrollSpeed = 2f; [Header("角度限制")] public float minVerticalAngle = -30f; public float maxVerticalAngle = 60f; [Header("平滑参数")] public float smoothTime = 0.1f; public bool useSmooth = true; [Header("鼠标灵敏度")] public float mouseSensitivity = 0.3f; private float currentX = 0f; private float currentY = 20f; private float currentDistance; private Vector3 velocity = Vector3.zero; private Vector2 lastMousePosition; private bool isDragging = false; private void Start() { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { GameObject val = GameObject.FindGameObjectWithTag("Player"); if ((Object)(object)val != (Object)null) { target = val.transform; } else { Debug.LogWarning((object)"未找到目标物体,请手动指定target!"); } } currentDistance = distance; if ((Object)(object)target != (Object)null) { Vector3 val2 = ((Component)this).transform.position - target.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; currentX = Mathf.Atan2(normalized.x, normalized.z) * 57.29578f; currentY = Mathf.Asin(normalized.y) * 57.29578f; currentDistance = Vector3.Distance(((Component)this).transform.position, target.position); currentDistance = Mathf.Clamp(currentDistance, minDistance, maxDistance); } lastMousePosition = Vector2.op_Implicit(Input.mousePosition); } private void LateUpdate() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return; } if (Input.GetMouseButtonDown(0)) { lastMousePosition = Vector2.op_Implicit(Input.mousePosition); isDragging = true; } else if (Input.GetMouseButton(0) && isDragging) { Vector2 val = Vector2.op_Implicit(Input.mousePosition); Vector2 val2 = val - lastMousePosition; if (((Vector2)(ref val2)).magnitude > 0.1f) { float num = Mathf.Min(Screen.width, Screen.height); float num2 = mouseSensitivity / num * 100f; float num3 = val2.x * num2; float num4 = val2.y * num2; currentX += num3 * rotationSpeed; currentY -= num4 * rotationSpeed; currentY = Mathf.Clamp(currentY, minVerticalAngle, maxVerticalAngle); } lastMousePosition = val; } else if (Input.GetMouseButtonUp(0)) { isDragging = false; } float axis = Input.GetAxis("Mouse ScrollWheel"); if (Mathf.Abs(axis) > 0.001f) { currentDistance -= axis * scrollSpeed * currentDistance * 0.1f; currentDistance = Mathf.Clamp(currentDistance, minDistance, maxDistance); } Vector3 targetPosition = GetTargetPosition(); if (useSmooth) { ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, targetPosition, ref velocity, smoothTime); } else { ((Component)this).transform.position = targetPosition; } ((Component)this).transform.LookAt(target); } private Vector3 GetTargetPosition() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) float num = currentX * ((float)Math.PI / 180f); float num2 = currentY * ((float)Math.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Sin(num2), Mathf.Cos(num) * Mathf.Cos(num2)); return target.position + val * currentDistance; } public void SetTarget(Transform newTarget) { target = newTarget; } public void ResetView() { currentX = 0f; currentY = 20f; currentDistance = distance; } private void OnDrawGizmosSelected() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { Gizmos.color = Color.green; Gizmos.DrawWireSphere(target.position, currentDistance); Gizmos.color = Color.yellow; Gizmos.DrawLine(target.position, ((Component)this).transform.position); } } } public class 菜单切换更改位置 : MonoBehaviour { public Transform 位置更改目标; public TMP_Dropdown myDropdown; public Transform 头部; public Transform 躯干; public Transform 臀部; public Transform 大臂; public Transform 小臂; public Transform 大腿; public Transform 小腿; private Coroutine 正在携程 = null; [SerializeField] private float 移动速度 = 5f; private void Start() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)myDropdown == (Object)null) { myDropdown = ((Component)this).GetComponent(); } ((UnityEvent)(object)myDropdown.onValueChanged).AddListener((UnityAction)OnDropdownValueChanged); if ((Object)(object)位置更改目标 != (Object)null && myDropdown.options.Count > 0) { string text = myDropdown.options[0].text; Transform val = 根据文本获取位置(text); if ((Object)(object)val != (Object)null) { 位置更改目标.position = val.position; } } } private void OnDropdownValueChanged(int selectedIndex) { string text = myDropdown.options[selectedIndex].text; Transform val = 根据文本获取位置(text); if ((Object)(object)val != (Object)null && (Object)(object)位置更改目标 != (Object)null) { if (正在携程 != null) { ((MonoBehaviour)this).StopCoroutine(正在携程); 正在携程 = null; } 正在携程 = ((MonoBehaviour)this).StartCoroutine(平滑移动到位置(val)); } } private Transform 根据文本获取位置(string text) { switch (text) { case "Neck": return 头部; case "Body": return 躯干; case "Hips": return 臀部; case "Arm": return 大臂; case "Forearm": return 小臂; case "Thigh": return 大腿; case "Leg": return 小腿; default: Debug.LogWarning((object)("未找到对应的部位: " + text)); return null; } } private IEnumerator 平滑移动到位置(Transform 目标位置) { if ((Object)(object)位置更改目标 == (Object)null || (Object)(object)目标位置 == (Object)null) { 正在携程 = null; yield break; } Vector3 起始位置 = 位置更改目标.position; Vector3 终点位置 = 目标位置.position; float 移动进度 = 0f; while (移动进度 < 1f) { 移动进度 += Time.deltaTime * 移动速度; 移动进度 = Mathf.Min(移动进度, 1f); float 平滑进度 = Mathf.SmoothStep(0f, 1f, 移动进度); 位置更改目标.position = Vector3.Lerp(起始位置, 终点位置, 平滑进度); yield return null; } 位置更改目标.position = 终点位置; 正在携程 = null; } } public class 限制写入浮点数 : MonoBehaviour { public TMP_InputField inputField; [Header("限制设置")] public int maxDecimalPlaces = 2; public float minValue = -9999f; public float maxValue = 9999f; private void Start() { if ((Object)(object)inputField == (Object)null) { inputField = ((Component)this).GetComponent(); } ((UnityEvent)(object)inputField.onEndEdit).AddListener((UnityAction)OnEndEdit); } private void OnEndEdit(string inputText) { if (!TryParseFloat(inputText, out var result)) { inputField.text = "0"; Debug.LogWarning((object)"输入无效,已重置为0"); return; } result = Mathf.Clamp(result, minValue, maxValue); string text = result.ToString(CultureInfo.InvariantCulture); if (maxDecimalPlaces >= 0) { text = result.ToString($"F{maxDecimalPlaces}", CultureInfo.InvariantCulture); } if (inputField.text != text) { inputField.SetTextWithoutNotify(text); } } private bool TryParseFloat(string s, out float result) { string s2 = s.Replace(',', '.'); return float.TryParse(s2, NumberStyles.Float, CultureInfo.InvariantCulture, out result); } public float GetFloatValue() { if (TryParseFloat(inputField.text, out var result)) { return Mathf.Clamp(result, minValue, maxValue); } return 0f; } } namespace PropEditor { [BepInPlugin("PropEditorMOD", "PropEditorMOD", "1.0.0")] internal class Loader : BaseUnityPlugin { private void Awake() { Debug.Log((object)"已加载PropEditorMOD"); 服饰编辑器配置文件 服饰编辑器配置文件 = 模组配置项配置文件生成工具.读取或生成配置文件(); if (服饰编辑器配置文件 != null) { ((MonoBehaviour)this).StartCoroutine(call(服饰编辑器配置文件.延迟加载)); } } private IEnumerator call(float time) { UManager.Init(); yield return (object)new WaitUntil((Func)(() => (Object)(object)Object.FindObjectOfType() != (Object)null)); yield return (object)new WaitUntil((Func)(() => ServiceLocator.GetService() != null)); 模型资源加载类.初始化(); GameObject 场景切换管理 = new GameObject("服饰编辑器模组场景切换管理"); 场景切换管理.AddComponent<场景添加器>(); Object.DontDestroyOnLoad((Object)(object)场景切换管理); 服饰编辑器ui翻译器.添加语言(); int d = 0; while (!模型资源加载类.是否已初始化) { yield return (object)new WaitForSecondsRealtime(1f); d++; if (d >= 30) { Debug.LogError((object)"模型文件初始化错误!!"); yield break; } } 服饰编辑器配置文件生成.初始化(); yield return (object)new WaitForSecondsRealtime(time); } } public static class UManager { public static string mod名字 = "PropEditorMOD"; public static AssetBundle ab包_场景; public static AssetBundle ab包_普通资源; public static void Init() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("PropEditor.scenesasset"); AssetBundle val = AssetBundle.LoadFromStream(manifestResourceStream); ab包_场景 = val; Assembly executingAssembly2 = Assembly.GetExecutingAssembly(); Stream manifestResourceStream2 = executingAssembly2.GetManifestResourceStream("PropEditor.iconassets"); AssetBundle val2 = AssetBundle.LoadFromStream(manifestResourceStream2); ab包_普通资源 = val2; } } public class 场景添加器 : MonoBehaviour { public 场景添加器() { SceneManager.sceneLoaded += SceneLoaded; } public void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { if (!(((Scene)(ref scene)).name == "CustomContentPage")) { return; } GameObject val = GameObject.Find("CustomContent"); if (!((Object)(object)val != (Object)null)) { return; } Transform val2 = val.transform.Find("Title Safe/CanvasUIComponents/ContentBropwser/TABS/TabsContainer/Levels"); Transform val3 = val.transform.Find("Title Safe/CanvasUIComponents/ContentBropwser/TABS/TabsContainer/Dot"); Transform val4 = val.transform.Find("Title Safe/CanvasUIComponents/ContentBropwser/TABS/TabsContainer"); Object.Instantiate(((Component)val3).gameObject, val4); GameObject val5 = Object.Instantiate(((Component)val2).gameObject, val4); Sprite sprite = UManager.ab包_普通资源.LoadAsset("ui图标we山地车fkjsdfip1"); Image component = ((Component)val5.transform.GetChild(0).GetChild(1)).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.sprite = sprite; } Image component2 = ((Component)val5.transform.GetChild(1).GetChild(1)).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { component2.sprite = sprite; } LocalizeText component3 = ((Component)val5.transform.GetChild(1).GetChild(0)).GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { component3.LocaleID = "服饰编辑器"; } Toggle componentInChildren = val5.GetComponentInChildren(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return; } ((UnityEventBase)componentInChildren.onValueChanged).RemoveAllListeners(); ((UnityEvent)(object)componentInChildren.onValueChanged).AddListener((UnityAction)delegate(bool isOn) { if (isOn) { SceneManager.LoadScene("FUshibianjiq"); } }); EventTrigger componentInChildren2 = val5.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { componentInChildren2.triggers.Clear(); } } } public static class 模型资源加载类 { private static bool _是否已初始化 = false; private static string _模型文件夹路径 = ""; private static GameObject _缓存容器 = null; private static List _支持的扩展名 = new List { ".obj", ".OBJ" }; public static Dictionary 模型资源字典 { get; private set; } = new Dictionary(); public static bool 是否已初始化 => _是否已初始化; public static int 模型总数 => 模型资源字典.Count; public static List 所有模型名称 => 模型资源字典.Keys.ToList(); public static int 初始化(bool 是否包含子文件夹 = true, string 自定义文件夹名称 = "Model") { try { 创建缓存容器(); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _模型文件夹路径 = Path.Combine(directoryName, 自定义文件夹名称); Debug.Log((object)("DLL所在路径: " + directoryName)); Debug.Log((object)("模型文件夹路径: " + _模型文件夹路径)); if (!Directory.Exists(_模型文件夹路径)) { Debug.Log((object)("模型文件夹不存在,正在自动创建: " + _模型文件夹路径)); try { Directory.CreateDirectory(_模型文件夹路径); Debug.Log((object)("✅ 模型文件夹已创建: " + _模型文件夹路径)); _是否已初始化 = true; Debug.Log((object)"模型文件夹已创建,请将OBJ模型文件放入该文件夹后重新加载"); return 0; } catch (Exception ex) { Debug.LogError((object)("❌ 创建模型文件夹失败: " + _模型文件夹路径 + "\n错误: " + ex.Message)); _是否已初始化 = false; return 0; } } 清空字典(); SearchOption searchOption = (是否包含子文件夹 ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); string[] array = Directory.GetFiles(_模型文件夹路径, "*.obj", searchOption).Concat(Directory.GetFiles(_模型文件夹路径, "*.OBJ", searchOption)).Distinct() .ToArray(); if (array.Length == 0) { Debug.LogWarning((object)("在 " + _模型文件夹路径 + " 中未找到任何OBJ文件")); _是否已初始化 = true; return 0; } Debug.Log((object)$"找到 {array.Length} 个OBJ文件,开始加载..."); int num = 0; int num2 = 0; OBJ模型解析类 oBJ模型解析类 = new OBJ模型解析类(); string[] array2 = array; foreach (string text in array2) { try { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); fileNameWithoutExtension = 获取唯一名称(fileNameWithoutExtension); OBJ解析结果 oBJ解析结果 = oBJ模型解析类.解析模型(text); if (oBJ解析结果 != null && (Object)(object)oBJ解析结果.游戏物体 != (Object)null) { ((Object)oBJ解析结果.游戏物体).name = fileNameWithoutExtension; oBJ解析结果.游戏物体.transform.SetParent(_缓存容器.transform, false); 模型资源字典[fileNameWithoutExtension] = oBJ解析结果.游戏物体; oBJ解析结果.游戏物体.SetActive(false); num++; Debug.Log((object)$"✅ 成功加载模型: {fileNameWithoutExtension} (顶点: {oBJ解析结果.顶点总数}, 三角面: {oBJ解析结果.三角面总数})"); } else { num2++; Debug.LogWarning((object)("⚠\ufe0f 加载模型失败: " + text + " - 解析结果为空")); } } catch (Exception ex2) { num2++; Debug.LogError((object)("❌ 加载模型异常: " + text + "\n错误: " + ex2.Message)); } } _是否已初始化 = true; Debug.Log((object)$"\ud83c\udfaf 模型加载完成!成功: {num}, 失败: {num2}, 总计: {模型资源字典.Count}"); return num; } catch (Exception ex3) { Debug.LogError((object)("❌ 初始化模型资源加载器失败: " + ex3.Message + "\n" + ex3.StackTrace)); _是否已初始化 = false; return 0; } } private static void 创建缓存容器() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!((Object)(object)_缓存容器 != (Object)null)) { _缓存容器 = new GameObject("__模型缓存容器__"); _缓存容器.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_缓存容器); Debug.Log((object)"✅ 模型缓存容器已创建(DontDestroyOnLoad)"); } } private static void 清空字典() { foreach (KeyValuePair item in 模型资源字典) { if ((Object)(object)item.Value != (Object)null) { Object.Destroy((Object)(object)item.Value); } } 模型资源字典.Clear(); } public static GameObject 获取模型克隆(string 模型名称, Transform 父物体 = null, Vector3? 位置 = null, Quaternion? 旋转 = null, Vector3? 缩放 = null) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!_是否已初始化) { Debug.LogError((object)"模型资源加载器尚未初始化,请先调用 初始化() 方法"); return null; } if (!模型资源字典.ContainsKey(模型名称)) { Debug.LogError((object)("模型不存在: " + 模型名称)); Debug.Log((object)("可用模型: " + string.Join(", ", 所有模型名称))); return null; } try { GameObject val = 模型资源字典[模型名称]; GameObject val2 = Object.Instantiate(val); if ((Object)(object)父物体 != (Object)null) { val2.transform.SetParent(父物体, false); } else { val2.transform.SetParent((Transform)null, false); } if (位置.HasValue) { val2.transform.localPosition = 位置.Value; } else { val2.transform.localPosition = Vector3.zero; } if (旋转.HasValue) { val2.transform.localRotation = 旋转.Value; } else { val2.transform.localRotation = Quaternion.identity; } if (缩放.HasValue) { val2.transform.localScale = 缩放.Value; } else { val2.transform.localScale = Vector3.one; } val2.SetActive(true); return val2; } catch (Exception ex) { Debug.LogError((object)("克隆模型失败: " + 模型名称 + "\n错误: " + ex.Message)); return null; } } public static GameObject 获取模型(string 模型名称, bool 自动激活 = true) { if (!_是否已初始化) { Debug.LogError((object)"模型资源加载器尚未初始化,请先调用 初始化() 方法"); return null; } if (!模型资源字典.ContainsKey(模型名称)) { Debug.LogError((object)("模型不存在: " + 模型名称)); return null; } GameObject val = 模型资源字典[模型名称]; if (自动激活 && (Object)(object)val != (Object)null) { val.SetActive(true); } return val; } public static bool 尝试获取模型(string 模型名称, out GameObject 模型, bool 自动激活 = true) { 模型 = 获取模型(模型名称, 自动激活); return (Object)(object)模型 != (Object)null; } public static void 释放资源() { 清空字典(); if ((Object)(object)_缓存容器 != (Object)null) { Object.Destroy((Object)(object)_缓存容器); _缓存容器 = null; } _是否已初始化 = false; Debug.Log((object)"模型资源已释放"); } public static bool 卸载模型(string 模型名称) { if (!模型资源字典.ContainsKey(模型名称)) { return false; } GameObject val = 模型资源字典[模型名称]; if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } return 模型资源字典.Remove(模型名称); } public static int 重新加载(bool 是否包含子文件夹 = true) { 清空字典(); return 初始化(是否包含子文件夹); } public static string 获取模型信息(string 模型名称) { if (!模型资源字典.ContainsKey(模型名称)) { return "模型 '" + 模型名称 + "' 不存在"; } GameObject val = 模型资源字典[模型名称]; if ((Object)(object)val == (Object)null) { return "模型 '" + 模型名称 + "' 已被销毁"; } int num = 0; int num2 = 0; int num3 = 0; MeshFilter[] componentsInChildren = val.GetComponentsInChildren(); foreach (MeshFilter val2 in componentsInChildren) { if ((Object)(object)val2.sharedMesh != (Object)null) { num += val2.sharedMesh.vertexCount; num2 += val2.sharedMesh.triangles.Length / 3; num3++; } } return "模型名称: " + 模型名称 + "\n" + $"子物体数: {num3}\n" + $"总顶点数: {num}\n" + $"总三角面数: {num2}\n" + $"是否激活: {val.activeSelf}"; } public static void 打印所有模型信息() { if (!_是否已初始化) { Debug.Log((object)"模型资源加载器未初始化"); return; } Debug.Log((object)$"========== 模型资源列表 (共 {模型总数} 个) =========="); foreach (string item in 所有模型名称) { Debug.Log((object)获取模型信息(item)); Debug.Log((object)"----------------------------------------"); } } private static string 获取唯一名称(string 基础名称) { if (!模型资源字典.ContainsKey(基础名称)) { return 基础名称; } int num = 1; string text; do { text = $"{基础名称}_{num}"; num++; } while (模型资源字典.ContainsKey(text)); return text; } } } namespace PropEditor.配置文件生成类 { public static class 服饰编辑器配置文件生成 { public static string 文件夹名称 = "you_propDATA"; public static Dictionary 字典_配置ID对应服饰数据类 = new Dictionary(); public static Dictionary 字典_配置文件路径对应服饰数据类 = new Dictionary(); public static Dictionary 字典_服饰名称对应游戏对象 = new Dictionary(); public static GameObject 对象存储父级; public static bool 启用详细调试 = true; private static bool 已初始化 = false; private static bool 正在初始化 = false; private static bool 正在加载配置 = false; private static string 当前程序集目录; private static void 记录调试(string 消息) { if (启用详细调试) { Debug.Log((object)("[Config调试] " + 消息)); } } private static void 记录错误(string 消息, Exception e = null) { if (e != null) { Debug.LogError((object)("❌ " + 消息 + ": " + e.Message)); Debug.LogError((object)("堆栈跟踪: " + e.StackTrace)); if (e.InnerException != null) { Debug.LogError((object)("内部异常: " + e.InnerException.Message)); } } else { Debug.LogError((object)("❌ " + 消息)); } } public static void 初始化() { if (已初始化) { return; } if (正在初始化) { 记录调试("⚠\ufe0f 正在初始化中,跳过重复调用"); return; } 正在初始化 = true; 记录调试("开始初始化..."); try { 当前程序集目录 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 记录调试("当前程序集目录: " + 当前程序集目录); 创建存储父级(); 加载所有配置文件(); 已初始化 = true; Debug.Log((object)"✅ 服饰编辑器配置文件生成 初始化完成"); } catch (Exception e) { 记录错误("初始化失败", e); } finally { 正在初始化 = false; } } private static void 创建存储父级() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!((Object)(object)对象存储父级 != (Object)null)) { 对象存储父级 = new GameObject { hideFlags = (HideFlags)61 }; 对象存储父级.SetActive(false); ((Object)对象存储父级).name = "自定义服饰资源库"; 记录调试("✅ 对象存储父级创建成功"); } } public static void 加载所有配置文件() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown if (正在加载配置) { 记录调试("⚠\ufe0f 正在加载配置中,跳过重复调用"); return; } 正在加载配置 = true; 记录调试("开始加载所有配置文件..."); try { string text = Path.Combine(当前程序集目录, 文件夹名称); if (!Directory.Exists(text)) { Debug.Log((object)("配置文件文件夹不存在,将创建: " + text)); Directory.CreateDirectory(text); return; } string[] files = Directory.GetFiles(text, "*.json"); 记录调试($"找到 {files.Length} 个配置文件"); 清空字典数据(); JsonSerializerSettings settings = new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1, NullValueHandling = (NullValueHandling)1 }; int num = 0; string[] array = files; foreach (string 配置文件路径 in array) { if (尝试加载单个配置文件(配置文件路径, settings)) { num++; } } Debug.Log((object)$"\ud83d\udcca 配置文件加载完成: 成功 {num}, 总计 {files.Length}"); } catch (Exception e) { 记录错误("加载配置文件失败", e); } finally { 正在加载配置 = false; } } private static bool 尝试加载单个配置文件(string 配置文件路径, JsonSerializerSettings settings) { try { string text = File.ReadAllText(配置文件路径); 服饰编辑器服饰数据容器 服饰编辑器服饰数据容器 = JsonConvert.DeserializeObject<服饰编辑器服饰数据容器>(text, settings); if (服饰编辑器服饰数据容器 == null) { return false; } 字典_配置文件路径对应服饰数据类[配置文件路径] = 服饰编辑器服饰数据容器; string key = 生成ID键(服饰编辑器服饰数据容器.此服饰id.Modid, 服饰编辑器服饰数据容器.此服饰id.id); 字典_配置ID对应服饰数据类[key] = 服饰编辑器服饰数据容器; GameObject val = 生成服饰对象_内部(服饰编辑器服饰数据容器, 检查初始化: false); if ((Object)(object)val != (Object)null) { 字典_服饰名称对应游戏对象[服饰编辑器服饰数据容器.服饰名称] = val; } 记录调试("✅ 加载配置文件成功: " + Path.GetFileName(配置文件路径)); return true; } catch (Exception e) { 记录错误("加载配置文件失败 " + Path.GetFileName(配置文件路径), e); return false; } } private static void 清空字典数据() { 字典_配置文件路径对应服饰数据类.Clear(); 字典_配置ID对应服饰数据类.Clear(); 字典_服饰名称对应游戏对象.Clear(); } public static void 重新加载所有配置() { 记录调试("重新加载所有配置..."); 销毁所有服饰对象(); 清空字典数据(); 加载所有配置文件(); } private static void 销毁所有服饰对象() { foreach (GameObject value in 字典_服饰名称对应游戏对象.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } } public static bool 保存配置(服饰编辑器服饰数据容器 配置, bool 覆盖已存在 = true) { 记录调试("=== 开始保存配置 ==="); if (配置 == null) { 记录错误("配置为空,无法保存"); return false; } if (配置.此服饰id == null) { 记录错误("配置.此服饰id 为 null"); return false; } 记录调试($"配置名称: {配置.服饰名称}, Modid: {配置.此服饰id.Modid}, id: {配置.此服饰id.id}"); try { 确保程序集目录有效(); string text = Path.Combine(当前程序集目录, 文件夹名称); 确保文件夹存在(text); string text2 = 生成ID键(配置.此服饰id.Modid, 配置.此服饰id.id); 记录调试("生成的ID键: " + text2); if (字典_配置ID对应服饰数据类.ContainsKey(text2)) { if (!覆盖已存在) { Debug.LogWarning((object)("配置ID " + text2 + " 已存在,且不允许覆盖")); return false; } 删除旧配置(text2); } string text3 = 保存配置到文件(配置, text); if (string.IsNullOrEmpty(text3)) { return false; } 更新字典(text3, 配置, text2); GameObject val = 生成服饰对象(配置); if ((Object)(object)val != (Object)null) { 字典_服饰名称对应游戏对象[配置.服饰名称] = val; 记录调试("✅ 服饰对象生成成功: " + 配置.服饰名称); } else { Debug.LogWarning((object)("⚠\ufe0f 服饰对象生成失败: " + 配置.服饰名称)); } Debug.Log((object)("✅ 配置保存成功: " + text3)); 记录调试("=== 保存配置完成 ==="); return true; } catch (Exception e) { 记录错误("保存配置失败", e); return false; } } private static void 确保程序集目录有效() { if (string.IsNullOrEmpty(当前程序集目录)) { 当前程序集目录 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 记录调试("当前程序集目录: " + 当前程序集目录); } } private static void 确保文件夹存在(string 路径) { if (!Directory.Exists(路径)) { Directory.CreateDirectory(路径); 记录调试("创建文件夹: " + 路径); } } private static void 删除旧配置(string id键) { 服饰编辑器服饰数据容器 旧配置 = 字典_配置ID对应服饰数据类[id键]; 记录调试("⚠\ufe0f 发现重复ID: " + id键 + ", 旧配置: " + 旧配置?.服饰名称); string key = 字典_配置文件路径对应服饰数据类.FirstOrDefault((KeyValuePair x) => x.Value == 旧配置).Key; if (!string.IsNullOrEmpty(key) && File.Exists(key)) { File.Delete(key); 记录调试("\ud83d\uddd1\ufe0f 删除旧配置文件: " + Path.GetFileName(key)); 字典_配置文件路径对应服饰数据类.Remove(key); } if (字典_服饰名称对应游戏对象.TryGetValue(旧配置.服饰名称, out var value)) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); 记录调试("\ud83d\uddd1\ufe0f 删除旧游戏对象: " + 旧配置.服饰名称); } 字典_服饰名称对应游戏对象.Remove(旧配置.服饰名称); } 字典_配置ID对应服饰数据类.Remove(id键); } private static string 保存配置到文件(服饰编辑器服饰数据容器 配置, string 文件夹路径) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown string text = $"{配置.服饰名称}_{配置.此服饰id.Modid}_{配置.此服饰id.id}.json"; char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { text = text.Replace(oldChar, '_'); } string text2 = Path.Combine(文件夹路径, text); 记录调试("新配置文件路径: " + text2); if (File.Exists(text2)) { File.Delete(text2); } JsonSerializerSettings val = new JsonSerializerSettings { Formatting = (Formatting)1, ReferenceLoopHandling = (ReferenceLoopHandling)1, NullValueHandling = (NullValueHandling)1 }; string text3 = JsonConvert.SerializeObject((object)配置, val); File.WriteAllText(text2, text3); 记录调试($"✅ 文件写入成功, JSON长度: {text3.Length} 字符"); return text2; } private static void 更新字典(string 配置文件路径, 服饰编辑器服饰数据容器 配置, string id键) { 字典_配置文件路径对应服饰数据类[配置文件路径] = 配置; 字典_配置ID对应服饰数据类[id键] = 配置; 记录调试("✅ 字典更新成功"); } public static string 保存配置并返回路径(服饰编辑器服饰数据容器 配置) { if (保存配置(配置)) { string key = 生成ID键(配置.此服饰id.Modid, 配置.此服饰id.id); if (字典_配置ID对应服饰数据类.TryGetValue(key, out var 保存的配置)) { return 字典_配置文件路径对应服饰数据类.FirstOrDefault((KeyValuePair x) => x.Value == 保存的配置).Key; } } return null; } public static GameObject 生成服饰对象(服饰编辑器服饰数据容器 服饰配置) { return 生成服饰对象_内部(服饰配置, 检查初始化: true); } private static GameObject 生成服饰对象_内部(服饰编辑器服饰数据容器 服饰配置, bool 检查初始化) { if (检查初始化 && !已初始化) { 记录调试("未初始化,执行初始化..."); 初始化(); } if (服饰配置 == null) { 记录错误("服饰配置为空,无法生成服饰"); return null; } try { GameObject val = 创建服饰游戏对象(服饰配置); PropItem val2 = 设置PropItem属性(val, 服饰配置); if ((Object)(object)val2 == (Object)null) { return null; } 设置服饰父级(val); 重置服饰变换(val); 实例化所有服饰网格(val, 服饰配置); 注册道具(val); 记录调试("✅ 服饰生成完成: " + ((Object)val).name); return val; } catch (Exception e) { 记录错误("生成服饰失败: " + 服饰配置.服饰名称, e); return null; } } private static GameObject 创建服饰游戏对象(服饰编辑器服饰数据容器 服饰配置) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown GameObject val = new GameObject(服饰配置.服饰名称); 记录调试("创建GameObject: " + ((Object)val).name); return val; } private static PropItem 设置PropItem属性(GameObject 服饰对象, 服饰编辑器服饰数据容器 服饰配置) { PropItem val = 服饰对象.AddComponent(); 记录调试("添加PropItem组件"); if ((Object)(object)val == (Object)null) { 记录错误("PropItem组件添加失败"); return null; } 设置服饰标签(val, 服饰配置); 设置服饰Entity(val, 服饰配置); 设置服饰装备类型(val, 服饰配置); return val; } private static void 设置服饰标签(PropItem 服饰配置选项, 服饰编辑器服饰数据容器 服饰配置) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) try { if (((CharacterItem)服饰配置选项).tags == null) { ((CharacterItem)服饰配置选项).tags = new List(); } ((CharacterItem)服饰配置选项).tags.Clear(); ((CharacterItem)服饰配置选项).tags.Add(new Tag((TagType)0, 服饰配置.服饰所在分类名称 ?? "默认分类")); 记录调试("设置tags: " + 服饰配置.服饰所在分类名称); } catch (Exception e) { 记录错误("设置tags失败", e); } } private static void 设置服饰Entity(PropItem 服饰配置选项, 服饰编辑器服饰数据容器 服饰配置) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) try { FieldInfo field = typeof(CharacterItem).GetField("m_entity", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Debug.LogWarning((object)"找不到 m_entity 字段"); return; } object? value = field.GetValue(服饰配置选项); DatabaseEntity val = (DatabaseEntity)((value is DatabaseEntity) ? value : null); if (val == null) { val = new DatabaseEntity((WorkshopContentType)5); field.SetValue(服饰配置选项, val); 记录调试("创建新的DatabaseEntity"); } if (服饰配置.此服饰id != null) { val.GUID = new DatabaseID(服饰配置.此服饰id.Modid, 服饰配置.此服饰id.id); 记录调试($"设置GUID: Modid={服饰配置.此服饰id.Modid}, id={服饰配置.此服饰id.id}"); } else { val.GUID = DatabaseID.NewID(); 记录调试("使用自动生成的GUID"); } val.Name = 服饰配置.服饰名称; } catch (Exception e) { 记录错误("设置GUID失败", e); } } private static void 设置服饰装备类型(PropItem 服饰配置选项, 服饰编辑器服饰数据容器 服饰配置) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) try { FieldInfo field = typeof(CharacterItem).GetField("m_gearType", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(服饰配置选项, 服饰配置.服饰分类枚举); 记录调试($"设置装备类型: {服饰配置.服饰分类枚举}"); } } catch (Exception e) { 记录错误("设置装备类型失败", e); } } private static void 设置服饰父级(GameObject 服饰对象) { try { if ((Object)(object)对象存储父级 != (Object)null) { 服饰对象.transform.SetParent(对象存储父级.transform); 记录调试("设置父级: " + ((Object)对象存储父级).name); } } catch (Exception e) { 记录错误("设置父级失败", e); } } private static void 重置服饰变换(GameObject 服饰对象) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) 服饰对象.transform.localPosition = Vector3.zero; 服饰对象.transform.localRotation = Quaternion.identity; 服饰对象.transform.localScale = Vector3.one; } private static void 注册道具(GameObject 服饰对象) { try { 记录调试("正在注册道具..."); SetHideFlagsRecursive(服饰对象, (HideFlags)52); 游戏内容工具.注册道具(服饰对象); 记录调试("✅ 注册道具完成"); } catch (Exception e) { 记录错误("注册道具失败", e); } } private static void 实例化所有服饰网格(GameObject 服饰对象, 服饰编辑器服饰数据容器 服饰配置) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown //IL_03c8: Unknown result type (might be due to invalid IL or missing references) 记录调试("开始实例化所有服饰网格..."); GameObject val = new GameObject("网格容器"); val.transform.SetParent(服饰对象.transform); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; int num = 0; int num2 = 0; if (服饰配置.默认网格实例数据 != null && 服饰配置.默认网格实例数据.Length != 0) { 记录调试($"开始实例化 {服饰配置.默认网格实例数据.Length} 个默认网格..."); for (int i = 0; i < 服饰配置.默认网格实例数据.Length; i++) { 服饰包含默认网格实例数据 服饰包含默认网格实例数据 = 服饰配置.默认网格实例数据[i]; if (服饰包含默认网格实例数据 == null) { continue; } try { GameObject val2 = 创建单个默认网格(服饰包含默认网格实例数据); if ((Object)(object)val2 != (Object)null) { val2.transform.SetParent(val.transform); ((Object)val2).name = $"默认网格_{i + 1}_{服饰包含默认网格实例数据.网格类型}"; 应用变换数据(val2, 服饰包含默认网格实例数据); num++; 记录调试($"✅ 创建默认网格 [{i + 1}]: {服饰包含默认网格实例数据.网格类型}"); } else { num2++; 记录调试($"❌ 创建默认网格 [{i + 1}] 失败"); } } catch (Exception e) { num2++; 记录错误($"创建默认网格 [{i + 1}] 异常", e); } } } if (服饰配置.自定义模型实例数据 != null && 服饰配置.自定义模型实例数据.Length != 0) { 记录调试($"开始实例化 {服饰配置.自定义模型实例数据.Length} 个自定义模型..."); for (int j = 0; j < 服饰配置.自定义模型实例数据.Length; j++) { 服饰包含自定义网格数据 服饰包含自定义网格数据 = 服饰配置.自定义模型实例数据[j]; if (服饰包含自定义网格数据 == null || string.IsNullOrEmpty(服饰包含自定义网格数据.模型名称)) { continue; } try { GameObject val3 = 创建单个自定义模型(服饰包含自定义网格数据); if ((Object)(object)val3 != (Object)null) { val3.transform.SetParent(val.transform); ((Object)val3).name = $"自定义模型_{j + 1}_{服饰包含自定义网格数据.模型名称}"; 应用变换数据(val3, 服饰包含自定义网格数据); num++; 记录调试($"✅ 创建自定义模型 [{j + 1}]: {服饰包含自定义网格数据.模型名称}"); } else { num2++; 记录调试($"❌ 创建自定义模型 [{j + 1}] 失败: {服饰包含自定义网格数据.模型名称}"); } } catch (Exception e2) { num2++; 记录错误($"创建自定义模型 [{j + 1}] 异常", e2); } } } if (num == 0) { Debug.LogWarning((object)("⚠\ufe0f 服饰 '" + 服饰配置.服饰名称 + "' 没有任何有效的网格数据")); GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val4).name = "占位_无网格"; val4.transform.SetParent(val.transform); val4.transform.localPosition = Vector3.zero; val4.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); Renderer component = val4.GetComponent(); if ((Object)(object)component != (Object)null) { Material val5 = new Material(Shader.Find("Standard")); val5.color = new Color(1f, 0.5f, 0f, 0.3f); component.sharedMaterial = val5; } 移除碰撞组件(val4); } if (服饰配置.服饰实例数据 != null) { val.transform.localPosition = Vector3.zero; val.transform.localEulerAngles = Vector3.zero; val.transform.localScale = Vector3.one; 记录调试($"应用整体变换: 位置={服饰配置.服饰实例数据.位置数据}, 旋转={服饰配置.服饰实例数据.旋转数据}, 缩放={服饰配置.服饰实例数据.缩放数据}"); } 记录调试($"✅ 网格实例化完成: 成功 {num}, 失败 {num2}"); } private static GameObject 创建单个默认网格(服饰包含默认网格实例数据 默认数据) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (默认数据 == null) { 记录调试("默认数据为 null"); return null; } try { PrimitiveType val = 转换几何体类型(默认数据.网格类型); GameObject val2 = GameObject.CreatePrimitive(val); 移除碰撞组件(val2); return val2; } catch (Exception e) { 记录错误($"创建默认网格失败: {默认数据.网格类型}", e); return null; } } private static GameObject 创建单个自定义模型(服饰包含自定义网格数据 自定义数据) { if (自定义数据 == null || string.IsNullOrEmpty(自定义数据.模型名称)) { 记录调试("自定义数据为 null 或模型名称为空"); return null; } string text = 自定义数据.模型名称.Trim(); 记录调试("尝试加载自定义模型: " + text); try { if (!模型资源加载类.是否已初始化) { 记录调试("模型资源加载器尚未初始化,正在自动初始化..."); 模型资源加载类.初始化(); if (!模型资源加载类.是否已初始化) { Debug.LogError((object)"❌ 模型资源加载器初始化失败"); return null; } } if (!模型资源加载类.所有模型名称.Contains(text)) { Debug.LogError((object)("❌ 模型不存在: " + text)); Debug.Log((object)("可用模型列表: " + string.Join(", ", 模型资源加载类.所有模型名称))); string text2 = 尝试模糊匹配模型名称(text); if (string.IsNullOrEmpty(text2)) { return 创建占位模型(text); } Debug.Log((object)("\ud83d\udca1 是否想使用: " + text2 + "?")); text = text2; } GameObject val = 模型资源加载类.获取模型克隆(text); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("❌ 获取模型克隆失败: " + text)); return 创建占位模型(text); } 记录调试("✅ 成功加载自定义模型: " + text); return val; } catch (Exception e) { 记录错误("加载自定义模型失败: " + text, e); return 创建占位模型(text); } } private static void 应用变换数据(GameObject 目标对象, 服饰包含自定义网格数据 变换数据) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)目标对象 == (Object)null) && 变换数据 != null) { Transform transform = 目标对象.transform; transform.localPosition = 变换数据.位置数据; transform.localEulerAngles = 变换数据.旋转数据; transform.localScale = 变换数据.缩放数据; } } private static void 应用变换数据(GameObject 目标对象, 服饰包含默认网格实例数据 变换数据) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)目标对象 == (Object)null) && 变换数据 != null) { Transform transform = 目标对象.transform; transform.localPosition = 变换数据.位置数据; transform.localEulerAngles = 变换数据.旋转数据; transform.localScale = 变换数据.缩放数据; } } private static string 尝试模糊匹配模型名称(string 目标名称) { if (string.IsNullOrEmpty(目标名称)) { return null; } List 所有模型名称 = 模型资源加载类.所有模型名称; if (所有模型名称 == null || 所有模型名称.Count == 0) { return null; } string text = 所有模型名称.FirstOrDefault((string n) => string.Equals(n, 目标名称, StringComparison.OrdinalIgnoreCase)); if (!string.IsNullOrEmpty(text)) { return text; } string text2 = 所有模型名称.FirstOrDefault((string n) => n.IndexOf(目标名称, StringComparison.OrdinalIgnoreCase) >= 0); if (!string.IsNullOrEmpty(text2)) { return text2; } string 清理名称 = new string(目标名称.Where((char c) => char.IsLetterOrDigit(c)).ToArray()); if (!string.IsNullOrEmpty(清理名称)) { string text3 = 所有模型名称.FirstOrDefault(delegate(string n) { string a = new string(n.Where((char c) => char.IsLetterOrDigit(c)).ToArray()); return string.Equals(a, 清理名称, StringComparison.OrdinalIgnoreCase); }); if (!string.IsNullOrEmpty(text3)) { return text3; } } return null; } private static GameObject 创建占位模型(string 模型名称) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = "占位_" + 模型名称; Renderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Material val2 = new Material(Shader.Find("Standard")); val2.color = new Color(1f, 0.2f, 0.2f, 0.5f); component.sharedMaterial = val2; } 移除碰撞组件(val); Debug.LogWarning((object)("⚠\ufe0f 创建占位模型: " + 模型名称 + " (请将OBJ模型放入Model文件夹)")); return val; } catch { return null; } } private static void SetHideFlagsRecursive(GameObject obj, HideFlags flags) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)obj == (Object)null) { return; } ((Object)obj).hideFlags = flags; foreach (Transform item in obj.transform) { Transform val = item; if ((Object)(object)val != (Object)null) { SetHideFlagsRecursive(((Component)val).gameObject, flags); } } } private static string 生成ID键(int Modid, int id) { return $"{Modid}_{id}"; } private static PrimitiveType 转换几何体类型(默认网格类型 网格类型) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) return (PrimitiveType)(网格类型 switch { 默认网格类型.立方体 => 3, 默认网格类型.球体 => 0, 默认网格类型.胶囊体 => 1, 默认网格类型.柱体 => 2, _ => 3, }); } private static void 移除碰撞组件(GameObject 目标对象) { if (!((Object)(object)目标对象 == (Object)null)) { Collider[] components = 目标对象.GetComponents(); Collider[] array = components; foreach (Collider val in array) { Object.DestroyImmediate((Object)(object)val); } } } public static 服饰编辑器服饰数据容器 查询配置(int Modid, int id) { string key = 生成ID键(Modid, id); 服饰编辑器服饰数据容器 value; return 字典_配置ID对应服饰数据类.TryGetValue(key, out value) ? value : null; } public static 服饰编辑器服饰数据容器 查询配置(string 服饰名称) { return 字典_配置文件路径对应服饰数据类.Values.FirstOrDefault((服饰编辑器服饰数据容器 x) => x.服饰名称 == 服饰名称); } public static bool 配置ID是否存在(int Modid, int id) { string key = 生成ID键(Modid, id); return 字典_配置ID对应服饰数据类.ContainsKey(key); } public static List<服饰编辑器服饰数据容器> 获取所有配置() { return 字典_配置ID对应服饰数据类.Values.ToList(); } public static List 获取所有服饰名称() { return 字典_服饰名称对应游戏对象.Keys.ToList(); } public static GameObject 获取服饰对象(string 服饰名称) { GameObject value; return 字典_服饰名称对应游戏对象.TryGetValue(服饰名称, out value) ? value : null; } public static bool 删除配置(int Modid, int id) { string key = 生成ID键(Modid, id); if (!字典_配置ID对应服饰数据类.TryGetValue(key, out var 配置)) { Debug.LogWarning((object)$"未找到配置: Modid={Modid}, id={id}"); return false; } try { string key2 = 字典_配置文件路径对应服饰数据类.FirstOrDefault((KeyValuePair x) => x.Value == 配置).Key; if (!string.IsNullOrEmpty(key2) && File.Exists(key2)) { File.Delete(key2); Debug.Log((object)("\ud83d\uddd1\ufe0f 删除配置文件: " + Path.GetFileName(key2))); 字典_配置文件路径对应服饰数据类.Remove(key2); } if (字典_服饰名称对应游戏对象.TryGetValue(配置.服饰名称, out var value)) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } 字典_服饰名称对应游戏对象.Remove(配置.服饰名称); } 字典_配置ID对应服饰数据类.Remove(key); Debug.Log((object)("✅ 配置删除成功: " + 配置.服饰名称)); return true; } catch (Exception e) { 记录错误("删除配置失败: " + 配置.服饰名称, e); return false; } } public static void 删除所有配置() { 销毁所有服饰对象(); 字典_服饰名称对应游戏对象.Clear(); foreach (string item in 字典_配置文件路径对应服饰数据类.Keys.ToList()) { try { if (File.Exists(item)) { File.Delete(item); } } catch (Exception ex) { Debug.LogError((object)("删除文件失败 " + item + ": " + ex.Message)); } } 字典_配置文件路径对应服饰数据类.Clear(); 字典_配置ID对应服饰数据类.Clear(); Debug.Log((object)"\ud83d\uddd1\ufe0f 所有配置已删除"); } } } namespace PropEditor.翻译器 { internal class 服饰编辑器ui翻译器 { public static void 添加语言() { 语言添加("UI_EXIT_PropEditor", "退出#Exit#終了#Beenden#Quitter#Выход#Salir#Esci"); 语言添加("UI_SAVE_PropEditor", "保存#Save#保存#Speichern#Enregistrer#Сохранить#Guardar#Salva"); 语言添加("UI_PropEditor_BindPos", "绑定位置#Bind Pos#装着位置#Bindepos#Pos. liaison#Поз. привязки#Pos. vinculación#Pos. legame"); 语言添加("UI_PropEditor_PropName", "服饰名称#Prop Name#衣装名#Name#Nom#Название#Nombre#Nome"); 语言添加("UI_PropEditor_CateName", "分类名称#Category#カテゴリ#Kategorie#Catégorie#Категория#Categoría#Categoria"); 语言添加("UI_PropEditor_PropID", "服饰ID#Prop ID#衣装ID#ID#ID#ID#ID#ID"); 语言添加("UI_PropEditor_AddType", "添加类型#Add Type#追加種別#Typ#Type#Тип#Tipo#Tipo"); 语言添加("UI_PropEditor_Scale", "缩放#Scale#拡縮#Skalierung#Échelle#Масштаб#Escala#Scala"); 语言添加("UI_PropEditor_Position", "位置#Position#位置#Position#Position#Позиция#Posición#Posizione"); 语言添加("UI_PropEditor_Rotation", "旋转#Rotation#回転#Rotation#Rotation#Вращение#Rotación#Rotazione"); 语言添加("UI_PropEditor_DefaultGeo", "默认几何体#Default#デフォルト#Standard#Défaut#По умолч.#Por defecto#Predef."); 语言添加("UI_PropEditor_CustomModel", "自定义模型#Custom#カスタム#Benutzerdef.#Personnal.#Пользов.#Personalizada#Personalizz."); 语言添加("UI_PropEditor_SaveSuccess", "保存成功#Saved#保存完了#Gespeichert#Sauvegardé#Сохранено#Guardado#Salvato"); } public static void 语言添加(string key, string trans) { //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(key)) { Debug.LogError((object)"翻译键不能为空!"); return; } if (string.IsNullOrEmpty(trans)) { Debug.LogError((object)"翻译内容不能为空!"); return; } string[] array = trans.Split(new string[1] { "#" }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 8) { Debug.LogError((object)$"翻译格式错误:需要8种语言,但只提供了{array.Length}种。格式应为:中文#英文#日文#德文#法文#俄文#西班牙文#意大利文"); return; } for (int i = 0; i < array.Length; i++) { if (string.IsNullOrWhiteSpace(array[i])) { string[] array2 = new string[8] { "中文", "英文", "日文", "德文", "法文", "俄文", "西班牙文", "意大利文" }; Debug.LogError((object)$"第{i}个位置({array2[i]})的翻译内容为空!"); return; } } try { Dictionary dictionary = new Dictionary(); dictionary.Add(0, (Language)7); dictionary.Add(1, (Language)0); dictionary.Add(2, (Language)8); dictionary.Add(3, (Language)3); dictionary.Add(4, (Language)1); dictionary.Add(5, (Language)6); dictionary.Add(6, (Language)4); dictionary.Add(7, (Language)2); FieldInfo field = typeof(Localizer).GetField("m_localization", BindingFlags.Static | BindingFlags.NonPublic); if (field == null) { Debug.LogError((object)"无法访问Localizer的m_localization字段!"); return; } if (!(field.GetValue(null) is Dictionary> dictionary2)) { Debug.LogError((object)"本地化字典为空或类型不匹配!"); return; } foreach (Language value in dictionary.Values) { if (!dictionary2.ContainsKey(value)) { Debug.LogError((object)$"本地化字典中缺少语言:{value}"); return; } } int num = 0; for (int j = 0; j < dictionary.Count; j++) { Language val = dictionary[j]; if (!dictionary2[val].ContainsKey(key)) { dictionary2[val].Add(key, array[j]); num++; } else { Debug.LogWarning((object)$"语言{val}中已存在键'{key}',跳过添加"); } } field.SetValue(null, dictionary2); if (num > 0) { Debug.Log((object)$"成功为{num}种语言添加了翻译键:{key}"); } else { Debug.Log((object)("所有语言中都已存在键'" + key + "',未添加任何新翻译")); } } catch (Exception ex) { Debug.LogError((object)("添加翻译时发生错误:" + ex.Message + "\n" + ex.StackTrace)); } } } } namespace PropEditor.物品添加类 { public static class 便携添加工具 { public enum 对象类 { 单位模型, 武器, 技能, 服饰, 抛射物 } public static int MYmodid = 228472303; public static int MYmodunitid = 62847203; public static GameObject 注册创建游戏对象自动id分配(GameObject 对象, 对象类 类型 = 对象类.技能) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) switch (类型) { case 对象类.技能: { GameObject result5 = 游戏内容工具.注册能力(懒得发字典添加物品类.Instance.创建物品(((Object)对象).name, 对象, new DatabaseID(-3, MYmodid))); MYmodid++; return result5; } case 对象类.服饰: { GameObject result4 = 游戏内容工具.注册道具(懒得发字典添加物品类.Instance.创建物品(((Object)对象).name, 对象, new DatabaseID(-3, MYmodid))); MYmodid++; return result4; } case 对象类.抛射物: { GameObject result3 = 游戏内容工具.注册投射物(懒得发字典添加物品类.Instance.创建物品(((Object)对象).name, 对象, new DatabaseID(-3, MYmodid))); MYmodid++; return result3; } case 对象类.单位模型: { GameObject result2 = 游戏内容工具.注册单位Base(懒得发字典添加物品类.Instance.创建物品(((Object)对象).name, 对象, new DatabaseID(-3, MYmodid))); MYmodid++; return result2; } case 对象类.武器: { GameObject result = 游戏内容工具.注册武器(懒得发字典添加物品类.Instance.创建物品(((Object)对象).name, 对象, new DatabaseID(-3, MYmodid))); MYmodid++; return result; } default: return null; } } public static void 添加单位到指定派系(UnitBlueprint[] 指定的所有单位, Faction 指定派系, bool 自动排序 = false, bool 去重 = false) { if (指定的所有单位 == null || 指定的所有单位.Length == 0) { return; } List list = new List(); if (指定派系.Units != null) { list.AddRange(指定派系.Units); } list.AddRange(指定的所有单位); if (去重) { list = (from unit in list where ((unit != null) ? unit.Entity : null) != null group unit by unit.Entity.GUID into @group select @group.First()).ToList(); } if (自动排序) { list.Sort((UnitBlueprint unit1, UnitBlueprint unit2) => unit1.GetUnitCost(true).CompareTo(unit2.GetUnitCost(true))); } 指定派系.Units = list.ToArray(); } public static void 添加单位到指定派系(UnitBlueprint 指定单位, Faction 指定派系, bool 自动排序 = false, bool 去重 = false) { if (!((Object)(object)指定单位 == (Object)null)) { 添加单位到指定派系((UnitBlueprint[])(object)new UnitBlueprint[1] { 指定单位 }, 指定派系, 自动排序, 去重); } } public static void 设置单位蓝图声音(UnitBlueprint 此单位, string 单位声音, string 单位阵亡声音, float 音调, string 单位脚步声音) { 此单位.SetUnitSounds(单位声音, 单位阵亡声音, 音调, 单位脚步声音); } public static void 设置单位蓝图骑手(UnitBlueprint 此单位, UnitBlueprint[] 骑手组) { 此单位.SetRiders(骑手组); } } public static class UnitBlueprintExtensions { public static bool SetField(this UnitBlueprint blueprint, string fieldName, object value) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[SetField] 兵种蓝图为空"); return false; } FieldInfo field = typeof(UnitBlueprint).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { PropertyInfo property = typeof(UnitBlueprint).GetProperty(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { try { if (value != null && !property.PropertyType.IsAssignableFrom(value.GetType())) { value = Convert.ChangeType(value, property.PropertyType); } property.SetValue(blueprint, value); return true; } catch (Exception ex) { Debug.LogError((object)("[SetField] 设置属性 '" + fieldName + "' 失败: " + ex.Message)); return false; } } Debug.LogError((object)("[SetField] 字段/属性 '" + fieldName + "' 不存在")); return false; } try { if (value != null && !field.FieldType.IsAssignableFrom(value.GetType())) { value = Convert.ChangeType(value, field.FieldType); } field.SetValue(blueprint, value); return true; } catch (Exception ex2) { Debug.LogError((object)("[SetField] 设置字段 '" + fieldName + "' 失败: " + ex2.Message)); return false; } } public static T GetField(this UnitBlueprint blueprint, string fieldName) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[GetField] 兵种蓝图为空"); return default(T); } FieldInfo field = typeof(UnitBlueprint).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { PropertyInfo property = typeof(UnitBlueprint).GetProperty(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanRead) { try { object value = property.GetValue(blueprint); return (value != null) ? ((T)value) : default(T); } catch (Exception ex) { Debug.LogError((object)("[GetField] 获取属性 '" + fieldName + "' 失败: " + ex.Message)); return default(T); } } return default(T); } try { object value2 = field.GetValue(blueprint); return (value2 != null) ? ((T)value2) : default(T); } catch (Exception ex2) { Debug.LogError((object)("[GetField] 获取字段 '" + fieldName + "' 失败: " + ex2.Message)); return default(T); } } public static bool SetUnitSounds(this UnitBlueprint blueprint, string vocalSound, string deathSound, float pitch = 1f, string footstepSound = "Footsteps/Minotaur") { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[SetUnitSounds] 兵种蓝图为空"); return false; } bool result = true; if (!blueprint.SetField("vocalRef", vocalSound)) { result = false; } if (!blueprint.SetField("deathRef", deathSound)) { result = false; } if (!blueprint.SetField("footRef", footstepSound)) { result = false; } if (!blueprint.SetField("voicePitch", pitch)) { result = false; } VoiceBundle field = blueprint.GetField("voiceBundle"); if ((Object)(object)field != (Object)null) { blueprint.SetField("voiceBundle", null); } typeof(UnitBlueprint).GetMethod("Validate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(blueprint, null); return result; } public static bool SetRider(this UnitBlueprint blueprint, UnitBlueprint riderBlueprint) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[SetRider] 兵种蓝图为空"); return false; } if ((Object)(object)riderBlueprint == (Object)null) { Debug.LogError((object)"[SetRider] 骑手蓝图为空"); return false; } blueprint.SetCustomRider(riderBlueprint.Entity.GUID); return true; } public static bool SetRiders(this UnitBlueprint blueprint, UnitBlueprint[] riderBlueprints) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[SetRiders] 兵种蓝图为空"); return false; } if (riderBlueprints == null || riderBlueprints.Length == 0) { blueprint.SetNoCustomRider(); return blueprint.SetField("Riders", null); } return blueprint.SetField("Riders", riderBlueprints); } public static bool AddRider(this UnitBlueprint blueprint, UnitBlueprint riderBlueprint) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[AddRider] 兵种蓝图为空"); return false; } if ((Object)(object)riderBlueprint == (Object)null) { Debug.LogError((object)"[AddRider] 骑手蓝图为空"); return false; } UnitBlueprint[] field = blueprint.GetField("Riders"); UnitBlueprint[] value; if (field == null || field.Length == 0) { value = (UnitBlueprint[])(object)new UnitBlueprint[1] { riderBlueprint }; } else { if (field.Any((UnitBlueprint r) => r.Entity.GUID == riderBlueprint.Entity.GUID)) { Debug.LogWarning((object)("[AddRider] 骑手 '" + riderBlueprint.Name + "' 已存在")); return false; } value = field.Concat((IEnumerable)(object)new UnitBlueprint[1] { riderBlueprint }).ToArray(); } return blueprint.SetField("Riders", value); } public static bool RemoveRider(this UnitBlueprint blueprint, UnitBlueprint riderBlueprint) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[RemoveRider] 兵种蓝图为空"); return false; } if ((Object)(object)riderBlueprint == (Object)null) { Debug.LogError((object)"[RemoveRider] 骑手蓝图为空"); return false; } UnitBlueprint[] field = blueprint.GetField("Riders"); if (field == null || field.Length == 0) { return true; } UnitBlueprint[] array = field.Where((UnitBlueprint r) => r.Entity.GUID != riderBlueprint.Entity.GUID).ToArray(); if (array.Length == field.Length) { Debug.LogWarning((object)("[RemoveRider] 未找到骑手 '" + riderBlueprint.Name + "'")); return false; } if (array.Length == 0) { blueprint.SetNoCustomRider(); return blueprint.SetField("Riders", null); } return blueprint.SetField("Riders", array); } public static bool ClearRiders(this UnitBlueprint blueprint) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[ClearRiders] 兵种蓝图为空"); return false; } blueprint.SetNoCustomRider(); return blueprint.SetField("Riders", null); } public static UnitBlueprint[] GetRiders(this UnitBlueprint blueprint) { if ((Object)(object)blueprint == (Object)null) { Debug.LogError((object)"[GetRiders] 兵种蓝图为空"); return Array.Empty(); } return blueprint.UnitRiders ?? Array.Empty(); } } public class 懒得发字典添加物品类 { private static 懒得发字典添加物品类 _instance; private GameObject 物品对象池; public static 懒得发字典添加物品类 Instance { get { if (_instance == null) { _instance = new 懒得发字典添加物品类(); } return _instance; } } private 懒得发字典添加物品类() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Debug.Log((object)"开始创建对象池"); 物品对象池 = new GameObject { hideFlags = (HideFlags)61 }; ((Object)物品对象池).name = UManager.mod名字; 物品对象池.SetActive(false); Debug.Log((object)"对象池创建完毕"); } public GameObject 创建物品(string 名字, GameObject 要复制的物体, DatabaseID 物体标识, Sprite icon = null) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"开始创建物品"); GameObject val = Object.Instantiate(要复制的物体, 物品对象池.transform); ((Object)val).hideFlags = (HideFlags)52; SetHideFlagsRecursive(val, (HideFlags)52); ((Object)val).name = 名字 + Assembly.GetCallingAssembly().GetName().Name; IDatabaseEntity componentInChildren = val.GetComponentInChildren(); if (componentInChildren != null) { CharacterItem val2 = (CharacterItem)(object)((componentInChildren is CharacterItem) ? componentInChildren : null); componentInChildren.Entity.GUID = 物体标识; componentInChildren.Entity.Name = 名字; if ((Object)(object)icon != (Object)null) { componentInChildren.Entity.SpriteIcon = icon; } } Debug.Log((object)("物品创建完毕" + ((Object)val).name)); return val; } private void SetHideFlagsRecursive(GameObject obj, HideFlags flags) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)obj == (Object)null) { return; } ((Object)obj).hideFlags = flags; foreach (Transform item in obj.transform) { Transform val = item; if ((Object)(object)val != (Object)null) { SetHideFlagsRecursive(((Component)val).gameObject, flags); } } } } public static class 游戏内容工具 { private static LandfallContentDatabase 内容数据库 => ContentDatabase.Instance().LandfallContentDatabase; private static AssetLoader 资源加载器 => ContentDatabase.Instance().AssetLoader; private static Dictionary 非流式资源字典 => (Dictionary)(typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(资源加载器)); public static GameObject 注册单位Base(GameObject 单位基础) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return 注册游戏对象到数据库(单位基础, 单位基础.GetComponent().Entity.GUID, "m_unitBases", (GameObject db) => db.GetComponent().Entity.GUID); } public static GameObject 注册武器(GameObject 武器对象) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return 注册游戏对象到数据库(武器对象, ((CharacterItem)武器对象.GetComponent()).Entity.GUID, "m_weapons", (GameObject obj) => ((CharacterItem)obj.GetComponent()).Entity.GUID); } public static GameObject 注册能力(GameObject 能力对象) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return 注册游戏对象到数据库(能力对象, ((CharacterItem)能力对象.GetComponent()).Entity.GUID, "m_combatMoves", (GameObject obj) => ((CharacterItem)obj.GetComponent()).Entity.GUID); } public static GameObject 注册投射物(GameObject 投射物对象) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return 注册游戏对象到数据库(投射物对象, 投射物对象.GetComponent().Entity.GUID, "m_projectiles", (GameObject obj) => obj.GetComponent().Entity.GUID); } public static GameObject 注册道具(GameObject 道具对象) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return 注册游戏对象到数据库(道具对象, ((CharacterItem)道具对象.GetComponent()).Entity.GUID, "m_characterProps", (GameObject obj) => ((CharacterItem)obj.GetComponent()).Entity.GUID); } private static GameObject 注册游戏对象到数据库(GameObject 游戏对象, DatabaseID 对象ID, string 数据库字段名, Func 获取ID函数) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = 获取字典(数据库字段名); if (!dictionary.ContainsKey(对象ID)) { dictionary.Add(对象ID, 游戏对象); 非流式资源字典.Add(对象ID, (Object)(object)游戏对象); 设置字典值(数据库字段名, dictionary); } return 游戏对象; } public static UnitBlueprint 获取原版单位蓝图(DatabaseID id) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = 获取字典("m_unitBlueprints"); UnitBlueprint value; return dictionary.TryGetValue(id, out value) ? value : null; } public static Faction 获取原版派系(DatabaseID id) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = 获取字典("m_factions"); Faction value; return dictionary.TryGetValue(id, out value) ? value : null; } public static UnitBlueprint 复制单位(string 名称, UnitBlueprint 源单位蓝图 = null, Faction 所属派系 = null, Sprite 图标 = null, DatabaseID? 自定义ID = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)源单位蓝图 == (Object)null) { 源单位蓝图 = 获取原版单位蓝图(new DatabaseID(-1, 1166250463)); } if ((Object)(object)源单位蓝图 == (Object)null) { Debug.LogError((object)"无法获取源单位蓝图"); return null; } Debug.LogWarning((object)"开始创建蓝图"); UnitBlueprint val = Object.Instantiate(源单位蓝图); val.Entity.GUID = (DatabaseID)(((??)自定义ID) ?? DatabaseID.NewID()); val.Entity.Name = 名称; ((Object)val).name = 名称; if ((Object)(object)图标 != (Object)null) { val.Entity.SpriteIcon = 图标; } Debug.LogWarning((object)"完成蓝图创建并指定ID"); Dictionary dictionary = 获取字典("m_unitBlueprints"); if (!dictionary.ContainsKey(val.Entity.GUID)) { 非流式资源字典.Add(val.Entity.GUID, (Object)(object)val); dictionary.Add(val.Entity.GUID, val); 设置字典值("m_unitBlueprints", dictionary); Debug.LogWarning((object)"成功添加到数据库"); } if ((Object)(object)所属派系 != (Object)null && (Object)(object)val != (Object)null) { List list = 所属派系.Units?.ToList() ?? new List(); if (!list.Contains(val)) { list.Add(val); 所属派系.Units = list.ToArray(); } } return val; } public static Faction 创建派系(string 名称, UnitBlueprint[] 单位列表 = null, Sprite 图标 = null, int 模组ID = 0, int 派系ID = 0) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Faction val = ScriptableObject.CreateInstance(); val.Init(); val.Entity.GUID = (DatabaseID)((模组ID != 0 && 派系ID != 0) ? new DatabaseID(模组ID, 派系ID) : DatabaseID.NewID()); val.Entity.Name = 名称; ((Object)val).name = 名称; val.Units = (UnitBlueprint[])(((object)单位列表) ?? ((object)new UnitBlueprint[0])); val.Entity.SpriteIcon = 图标; Dictionary dictionary = 获取字典("m_factions"); if (!dictionary.ContainsKey(val.Entity.GUID)) { 非流式资源字典.Add(val.Entity.GUID, (Object)(object)val); dictionary.Add(val.Entity.GUID, val); List list = 获取默认快捷栏派系ID列表(); if (!list.Contains(val.Entity.GUID)) { list.Add(val.Entity.GUID); 排序并设置默认快捷栏列表(list, dictionary); } 设置字典值("m_factions", dictionary); } return val; } private static Dictionary 获取字典(string 字段名) where T : Object { return (Dictionary)(typeof(LandfallContentDatabase).GetField(字段名, BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(内容数据库)); } private static void 设置字典值(string 字段名, Dictionary 字典) where T : Object { typeof(LandfallContentDatabase).GetField(字段名, BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(内容数据库, 字典); } private static List 获取默认快捷栏派系ID列表() { return (List)(typeof(LandfallContentDatabase).GetField("m_defaultHotbarFactionIds", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(内容数据库)); } private static void 排序并设置默认快捷栏列表(List 列表, Dictionary 派系字典) { Faction value2; List value = 列表.OrderBy((DatabaseID id) => 派系字典.TryGetValue(id, out value2) ? value2.index : int.MaxValue).ToList(); typeof(LandfallContentDatabase).GetField("m_defaultHotbarFactionIds", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(内容数据库, value); } } public static class 获取工具 { private static LandfallContentDatabase 内容数据库 => ContentDatabase.Instance().LandfallContentDatabase; private static AssetLoader 资源加载器 => ContentDatabase.Instance().AssetLoader; private static Dictionary 非流式资源字典 => (Dictionary)(typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(资源加载器)); private static Dictionary 获取字典(string 字段名) where T : Object { return (Dictionary)(typeof(LandfallContentDatabase).GetField(字段名, BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(内容数据库)); } public static GameObject 获取原版内容游戏物品(string 字典名, DatabaseID id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return 获取字典(字典名)[id]; } } } namespace PropEditor.模组配置项 { public class 服饰编辑器配置文件 { public float 延迟加载 = 10f; public bool 启用调试模式 = false; public string 数据存储路径 = "./Data"; } public static class 模组配置项配置文件生成工具 { private const string 默认配置文件名 = "服饰编辑器配置.json"; public static string 获取程序集目录() { string location = Assembly.GetExecutingAssembly().Location; return Path.GetDirectoryName(location); } public static string 获取配置文件路径(string 配置文件名 = null) { string path = 获取程序集目录(); string path2 = (string.IsNullOrEmpty(配置文件名) ? "服饰编辑器配置.json" : 配置文件名); return Path.Combine(path, path2); } public static 服饰编辑器配置文件 读取或生成配置文件(string 配置文件名 = null) { string text = 获取配置文件路径(配置文件名); if (File.Exists(text)) { try { string text2 = File.ReadAllText(text); 服饰编辑器配置文件 result = JsonConvert.DeserializeObject<服饰编辑器配置文件>(text2); Console.WriteLine("成功读取配置文件: " + text); return result; } catch (Exception ex) { Console.WriteLine("读取配置文件失败: " + ex.Message); Console.WriteLine("将生成新的默认配置文件..."); return 生成默认配置文件(配置文件名); } } Console.WriteLine("配置文件不存在: " + text); Console.WriteLine("正在生成默认配置文件..."); return 生成默认配置文件(配置文件名); } public static 服饰编辑器配置文件 生成默认配置文件(string 配置文件名 = null) { 服饰编辑器配置文件 服饰编辑器配置文件2 = new 服饰编辑器配置文件(); 保存配置文件(服饰编辑器配置文件2, 配置文件名); Console.WriteLine("已生成默认配置文件: " + 获取配置文件路径(配置文件名)); return 服饰编辑器配置文件2; } public static void 保存配置文件(服饰编辑器配置文件 配置, string 配置文件名 = null, bool 格式化 = true) { string text = 获取配置文件路径(配置文件名); try { string contents = JsonConvert.SerializeObject((object)配置, (Formatting)(格式化 ? 1 : 0)); File.WriteAllText(text, contents); Console.WriteLine("配置文件已保存: " + text); } catch (Exception ex) { Console.WriteLine("保存配置文件失败: " + ex.Message); throw; } } public static bool 配置文件是否存在(string 配置文件名 = null) { string path = 获取配置文件路径(配置文件名); return File.Exists(path); } public static bool 删除配置文件(string 配置文件名 = null) { string text = 获取配置文件路径(配置文件名); if (File.Exists(text)) { try { File.Delete(text); Console.WriteLine("配置文件已删除: " + text); return true; } catch (Exception ex) { Console.WriteLine("删除配置文件失败: " + ex.Message); return false; } } return false; } } } namespace PropEditor.模型解析类 { public class OBJ解析结果 { public GameObject 游戏物体 { get; set; } public List<网格数据> 网格列表 { get; set; } = new List<网格数据>(); public Dictionary 材质字典 { get; set; } = new Dictionary(); public int 顶点总数 { get; set; } public int 三角面总数 { get; set; } public string 模型名称 { get; set; } } public class 网格数据 { public Mesh 网格 { get; set; } public Material 材质 { get; set; } public string 网格名称 { get; set; } public int 顶点数量 { get { Mesh obj = 网格; return (obj != null) ? obj.vertexCount : 0; } } public int 三角面数量 { get { Mesh obj = 网格; return (obj != null) ? (obj.triangles.Length / 3) : 0; } } } public class OBJ模型解析类 { private List _顶点列表 = new List(); private List _法线列表 = new List(); private List _UV列表 = new List(); private Dictionary _材质字典 = new Dictionary(); private Dictionary _构建器字典 = new Dictionary(); private OBJ子物体构建器 _当前构建器; private string _当前材质 = "default"; private string _模型所在目录 = ""; private string _模型名称 = ""; public OBJ解析结果 解析模型(string 模型路径) { if (!File.Exists(模型路径)) { Debug.LogError((object)("OBJ文件不存在: " + 模型路径)); return null; } _顶点列表.Clear(); _法线列表.Clear(); _UV列表.Clear(); _材质字典.Clear(); _构建器字典.Clear(); _模型所在目录 = Path.GetDirectoryName(模型路径); _模型名称 = Path.GetFileNameWithoutExtension(模型路径); _当前构建器 = 获取或创建构建器("default"); _当前材质 = "default"; using (StreamReader streamReader = new StreamReader(模型路径)) { int num = 0; string text; while ((text = streamReader.ReadLine()) != null) { num++; try { 解析行(text); } catch (Exception ex) { Debug.LogWarning((object)$"解析第{num}行时出错: {text}\n错误: {ex.Message}"); } } } return 构建游戏物体(); } public OBJ解析结果 从字节数组解析(byte[] 数据, string 模型名称 = "模型") { if (数据 == null || 数据.Length == 0) { Debug.LogError((object)"数据为空"); return null; } _顶点列表.Clear(); _法线列表.Clear(); _UV列表.Clear(); _材质字典.Clear(); _构建器字典.Clear(); _模型名称 = 模型名称; _模型所在目录 = ""; _当前构建器 = 获取或创建构建器("default"); _当前材质 = "default"; using (MemoryStream stream = new MemoryStream(数据)) { using StreamReader streamReader = new StreamReader(stream); string 行; while ((行 = streamReader.ReadLine()) != null) { 解析行(行); } } return 构建游戏物体(); } private void 解析行(string 行) { if (string.IsNullOrWhiteSpace(行)) { return; } string[] array = 行.Trim().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 0) { string text = array[0]; switch (text) { case "#": break; case "v": 解析顶点(array); break; case "vn": 解析法线(array); break; case "vt": 解析UV(array); break; case "f": 解析面(array); break; case "usemtl": 解析材质切换(array); break; case "mtllib": 解析材质库(array); break; case "o": case "g": 解析对象分组(text, array); break; } } } private void 解析顶点(string[] 部分) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (部分.Length >= 4) { float num = float.Parse(部分[1]); float num2 = float.Parse(部分[2]); float num3 = float.Parse(部分[3]); _顶点列表.Add(new Vector3(num, num2, num3)); } } private void 解析法线(string[] 部分) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (部分.Length >= 4) { float num = float.Parse(部分[1]); float num2 = float.Parse(部分[2]); float num3 = float.Parse(部分[3]); _法线列表.Add(new Vector3(num, num2, num3)); } } private void 解析UV(string[] 部分) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (部分.Length >= 3) { float num = float.Parse(部分[1]); float num2 = float.Parse(部分[2]); _UV列表.Add(new Vector2(num, num2)); } } private void 解析面(string[] 部分) { if (部分.Length < 4) { return; } List list = new List(); List list2 = new List(); List list3 = new List(); for (int i = 1; i < 部分.Length; i++) { 解析顶点索引(部分[i], out var 顶点索引, out var UV索引, out var 法线索引); list.Add(顶点索引); list2.Add(法线索引); list3.Add(UV索引); } if (list.Count >= 3) { for (int j = 1; j < list.Count - 1; j++) { List 顶点索引2 = new List { list[0], list[j], list[j + 1] }; List 法线索引2 = new List { list2[0], list2[j], list2[j + 1] }; List uv索引 = new List { list3[0], list3[j], list3[j + 1] }; _当前构建器.添加面(_当前材质, 顶点索引2, 法线索引2, uv索引); } } } private void 解析顶点索引(string 索引字符串, out int 顶点索引, out int UV索引, out int 法线索引) { 顶点索引 = -1; UV索引 = -1; 法线索引 = -1; string[] array = 索引字符串.Split(new char[1] { '/' }); if (array.Length != 0 && !string.IsNullOrEmpty(array[0])) { 顶点索引 = 解析索引(array[0], _顶点列表.Count); } if (array.Length > 1 && !string.IsNullOrEmpty(array[1])) { UV索引 = 解析索引(array[1], _UV列表.Count); } if (array.Length > 2 && !string.IsNullOrEmpty(array[2])) { 法线索引 = 解析索引(array[2], _法线列表.Count); } } private int 解析索引(string 索引字符串, int 总数量) { if (string.IsNullOrEmpty(索引字符串)) { return -1; } int num = int.Parse(索引字符串); if (num > 0) { return num - 1; } if (num < 0) { return 总数量 + num; } return -1; } private void 解析材质切换(string[] 部分) { if (部分.Length >= 2) { _当前材质 = 部分[1]; _当前构建器 = 获取或创建构建器(_当前材质); } } private void 解析材质库(string[] 部分) { if (部分.Length < 2 || string.IsNullOrEmpty(_模型所在目录)) { return; } string text = Path.Combine(_模型所在目录, 部分[1]); if (!File.Exists(text)) { return; } try { MTL材质加载器 mTL材质加载器 = new MTL材质加载器(); Dictionary dictionary = mTL材质加载器.加载材质(text); foreach (KeyValuePair item in dictionary) { if (!_材质字典.ContainsKey(item.Key)) { _材质字典.Add(item.Key, item.Value); } } } catch (Exception ex) { Debug.LogWarning((object)("加载材质库失败: " + text + "\n错误: " + ex.Message)); } } private void 解析对象分组(string 命令, string[] 部分) { if (部分.Length >= 2) { string 名称 = 部分[1]; _当前构建器 = 获取或创建构建器(名称); } } private OBJ子物体构建器 获取或创建构建器(string 名称) { if (_构建器字典.TryGetValue(名称, out var value)) { return value; } value = new OBJ子物体构建器(名称); _构建器字典[名称] = value; return value; } private OBJ解析结果 构建游戏物体() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown GameObject val = new GameObject(_模型名称); OBJ解析结果 oBJ解析结果 = new OBJ解析结果 { 模型名称 = _模型名称, 材质字典 = _材质字典 }; int num = 0; int num2 = 0; foreach (KeyValuePair item2 in _构建器字典) { if (item2.Value.顶点索引列表.Count == 0) { continue; } 网格构建结果 网格构建结果2 = item2.Value.构建网格(_顶点列表, _法线列表, _UV列表); if (网格构建结果2 != null) { GameObject val2 = new GameObject(item2.Key); val2.transform.SetParent(val.transform, false); MeshFilter val3 = val2.AddComponent(); MeshRenderer val4 = val2.AddComponent(); val3.sharedMesh = 网格构建结果2.网格; Material value = null; if (_材质字典.TryGetValue(网格构建结果2.材质名称, out value)) { ((Renderer)val4).sharedMaterial = value; } else { ((Renderer)val4).sharedMaterial = new Material(Shader.Find("Standard")); } 网格数据 item = new 网格数据 { 网格 = 网格构建结果2.网格, 材质 = ((Renderer)val4).sharedMaterial, 网格名称 = item2.Key }; oBJ解析结果.网格列表.Add(item); num += 网格构建结果2.网格.vertexCount; num2 += 网格构建结果2.网格.triangles.Length / 3; } } oBJ解析结果.游戏物体 = val; oBJ解析结果.顶点总数 = num; oBJ解析结果.三角面总数 = num2; if (oBJ解析结果.网格列表.Count == 0) { Object.Destroy((Object)(object)val); return null; } return oBJ解析结果; } } internal class OBJ子物体构建器 { public string 名称 { get; private set; } public List 顶点索引列表 { get; private set; } = new List(); public List 法线索引列表 { get; private set; } = new List(); public List UV索引列表 { get; private set; } = new List(); public string 材质名称 { get; private set; } = "default"; public OBJ子物体构建器(string 名称) { this.名称 = 名称; } public void 添加面(string 材质, List 顶点索引, List 法线索引, List uv索引) { if (顶点索引.Count == 3) { 材质名称 = 材质; 顶点索引列表.AddRange(顶点索引); 法线索引列表.AddRange(法线索引); UV索引列表.AddRange(uv索引); } } public 网格构建结果 构建网格(List 所有顶点, List 所有法线, List 所有UV) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) if (顶点索引列表.Count == 0) { return null; } Mesh val = new Mesh(); ((Object)val).name = 名称; Vector3[] array = (Vector3[])(object)new Vector3[顶点索引列表.Count]; Vector3[] array2 = (Vector3[])(object)new Vector3[顶点索引列表.Count]; Vector2[] array3 = (Vector2[])(object)new Vector2[顶点索引列表.Count]; bool flag = 法线索引列表.Count == 顶点索引列表.Count && 法线索引列表.All((int i) => i >= 0 && i < 所有法线.Count); bool flag2 = UV索引列表.Count == 顶点索引列表.Count && UV索引列表.All((int i) => i >= 0 && i < 所有UV.Count); for (int num = 0; num < 顶点索引列表.Count; num++) { int num2 = 顶点索引列表[num]; if (num2 >= 0 && num2 < 所有顶点.Count) { array[num] = 所有顶点[num2]; } if (flag) { int num3 = 法线索引列表[num]; if (num3 >= 0 && num3 < 所有法线.Count) { array2[num] = 所有法线[num3]; } } if (flag2) { int num4 = UV索引列表[num]; if (num4 >= 0 && num4 < 所有UV.Count) { array3[num] = 所有UV[num4]; } } } val.vertices = array; if (flag) { val.normals = array2; } else { val.RecalculateNormals(); } if (flag2) { val.uv = array3; } int[] array4 = new int[顶点索引列表.Count]; for (int num5 = 0; num5 < 顶点索引列表.Count; num5++) { array4[num5] = num5; } val.triangles = array4; val.RecalculateBounds(); val.RecalculateTangents(); return new 网格构建结果 { 网格 = val, 材质名称 = 材质名称 }; } } internal class 网格构建结果 { public Mesh 网格 { get; set; } public string 材质名称 { get; set; } } internal class MTL材质加载器 { public Dictionary 加载材质(string 材质文件路径) { //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Expected O, but got Unknown //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); if (!File.Exists(材质文件路径)) { return dictionary; } string text = ""; Material val = null; foreach (string item in File.ReadLines(材质文件路径)) { if (string.IsNullOrWhiteSpace(item) || item.StartsWith("#")) { continue; } string[] array = item.Trim().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { continue; } string text2 = array[0]; switch (text2) { case "newmtl": text = ((array.Length > 1) ? array[1] : ("材质_" + dictionary.Count)); val = new Material(Shader.Find("Standard")); ((Object)val).name = text; dictionary[text] = val; break; case "Ka": if ((Object)(object)val != (Object)null && array.Length >= 4) { float num9 = float.Parse(array[1]); float num10 = float.Parse(array[2]); float num11 = float.Parse(array[3]); val.SetColor("_Color", new Color(num9, num10, num11)); } break; case "Kd": if ((Object)(object)val != (Object)null && array.Length >= 4) { float num6 = float.Parse(array[1]); float num7 = float.Parse(array[2]); float num8 = float.Parse(array[3]); val.SetColor("_Color", new Color(num6, num7, num8)); } break; case "Ks": if ((Object)(object)val != (Object)null && array.Length >= 4) { float num3 = float.Parse(array[1]); float num4 = float.Parse(array[2]); float num5 = float.Parse(array[3]); val.SetColor("_SpecColor", new Color(num3, num4, num5)); val.EnableKeyword("_SPECULAR_SETUP"); } break; case "Ns": if ((Object)(object)val != (Object)null && array.Length >= 2) { float num2 = float.Parse(array[1]); val.SetFloat("_Glossiness", num2 / 1000f); } break; case "d": case "Tr": if ((Object)(object)val != (Object)null && array.Length >= 2) { float num = float.Parse(array[1]); if (text2 == "Tr") { num = 1f - num; } Color color = val.GetColor("_Color"); color.a = num; val.SetColor("_Color", color); if (num < 1f) { val.SetFloat("_Mode", 2f); val.SetInt("_SrcBlend", 5); val.SetInt("_DstBlend", 10); val.SetInt("_ZWrite", 0); val.DisableKeyword("_ALPHATEST_ON"); val.EnableKeyword("_ALPHABLEND_ON"); val.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val.renderQueue = 3000; } } break; case "map_Kd": if ((Object)(object)val != (Object)null && array.Length >= 2) { string 路径2 = array[1]; Texture2D val3 = 加载纹理(路径2, Path.GetDirectoryName(材质文件路径)); if ((Object)(object)val3 != (Object)null) { val.SetTexture("_MainTex", (Texture)(object)val3); } } break; case "map_bump": case "bump": if ((Object)(object)val != (Object)null && array.Length >= 2) { string 路径 = array[1]; Texture2D val2 = 加载纹理(路径, Path.GetDirectoryName(材质文件路径)); if ((Object)(object)val2 != (Object)null) { val.SetTexture("_BumpMap", (Texture)(object)val2); val.EnableKeyword("_NORMALMAP"); } } break; } } return dictionary; } private Texture2D 加载纹理(string 路径, string 目录) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown try { string path = Path.Combine(目录, 路径); if (!File.Exists(path)) { return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)1; return val; } catch { return null; } } } } namespace PropEditor.服饰编辑器配置文件1 { public class ui获取并生成对应配置 : MonoBehaviour { public TMP_InputField 获取输入_服饰名称; public TMP_InputField 获取输入_服饰所在分类名称; public TMP_InputField 获取输入_服饰MOdid; public TMP_InputField 获取输入_服饰id; public TMP_Dropdown 分类下拉菜单; public List<实例化服饰数据核心类> 所有核心数据 = new List<实例化服饰数据核心类>(); public UnityEvent 输入失效事件; public bool 启用详细调试 = true; private void 记录调试(string 消息) { if (启用详细调试) { Debug.Log((object)("[UI调试] " + 消息)); } } public 服饰编辑器服饰数据容器 生成对应配置类() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) 记录调试("开始生成配置类..."); if (!引用有效检测()) { 记录调试("引用检测失败,触发输入失效事件"); UnityEvent obj = 输入失效事件; if (obj != null) { obj.Invoke(); } return null; } try { 服饰编辑器服饰数据容器 服饰编辑器服饰数据容器2 = new 服饰编辑器服饰数据容器(); TMP_InputField obj2 = 获取输入_服饰名称; 服饰编辑器服饰数据容器2.服饰名称 = ((obj2 != null) ? obj2.text : null) ?? ""; TMP_InputField obj3 = 获取输入_服饰所在分类名称; 服饰编辑器服饰数据容器2.服饰所在分类名称 = ((obj3 != null) ? obj3.text : null) ?? ""; 记录调试("服饰名称: " + 服饰编辑器服饰数据容器2.服饰名称 + ", 分类: " + 服饰编辑器服饰数据容器2.服饰所在分类名称); if ((Object)(object)分类下拉菜单 != (Object)null && 分类下拉菜单.options.Count > 0) { int value = 分类下拉菜单.value; 服饰编辑器服饰数据容器2.服饰分类枚举 = 处理枚举转换(分类下拉菜单.options[value].text); 记录调试($"分类枚举: {服饰编辑器服饰数据容器2.服饰分类枚举}"); } else { 服饰编辑器服饰数据容器2.服饰分类枚举 = (GearType)3; 记录调试("分类下拉菜单无效,使用默认枚举 TORSO"); } if (服饰编辑器服饰数据容器2.此服饰id == null) { 服饰编辑器服饰数据容器2.此服饰id = new id标识存储类(); } int result = 0; int result2 = 0; if ((Object)(object)获取输入_服饰MOdid != (Object)null) { int.TryParse(获取输入_服饰MOdid.text, out result); } if ((Object)(object)获取输入_服饰id != (Object)null) { int.TryParse(获取输入_服饰id.text, out result2); } 服饰编辑器服饰数据容器2.此服饰id.Modid = result; 服饰编辑器服饰数据容器2.此服饰id.id = result2; 记录调试($"Modid: {result}, id: {result2}"); if (服饰编辑器服饰数据容器2.服饰实例数据 == null) { 服饰编辑器服饰数据容器2.服饰实例数据 = new 服饰包含实例数据(); } if (所有核心数据.Count > 0 && (Object)(object)所有核心数据[0] != (Object)null) { 提取整体变换数据(所有核心数据[0], 服饰编辑器服饰数据容器2); } List<服饰包含默认网格实例数据> list = new List<服饰包含默认网格实例数据>(); List<服饰包含自定义网格数据> list2 = new List<服饰包含自定义网格数据>(); 收集所有网格数据(list, list2); 服饰编辑器服饰数据容器2.默认网格实例数据 = list.ToArray(); 服饰编辑器服饰数据容器2.自定义模型实例数据 = list2.ToArray(); 记录调试($"收集到 {list.Count} 个默认网格, {list2.Count} 个自定义模型"); 记录调试("✅ 配置生成完成"); return 服饰编辑器服饰数据容器2; } catch (Exception ex) { Debug.LogError((object)("❌ 生成配置类失败: " + ex.Message)); Debug.LogError((object)("堆栈跟踪: " + ex.StackTrace)); return null; } } private void 提取整体变换数据(实例化服饰数据核心类 核心数据, 服饰编辑器服饰数据容器 配置) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)核心数据 == (Object)null) && 配置.服饰实例数据 != null) { TMP_InputField 位置数据x = 核心数据.位置数据x; float num = 解析浮点数((位置数据x != null) ? 位置数据x.text : null, 0f); TMP_InputField 位置数据y = 核心数据.位置数据y; float num2 = 解析浮点数((位置数据y != null) ? 位置数据y.text : null, 0f); TMP_InputField 位置数据z = 核心数据.位置数据z; float num3 = 解析浮点数((位置数据z != null) ? 位置数据z.text : null, 0f); 配置.服饰实例数据.位置数据 = new Vector3(num, num2, num3); TMP_InputField 旋转数据x = 核心数据.旋转数据x; float num4 = 解析浮点数((旋转数据x != null) ? 旋转数据x.text : null, 0f); TMP_InputField 旋转数据y = 核心数据.旋转数据y; float num5 = 解析浮点数((旋转数据y != null) ? 旋转数据y.text : null, 0f); TMP_InputField 旋转数据z = 核心数据.旋转数据z; float num6 = 解析浮点数((旋转数据z != null) ? 旋转数据z.text : null, 0f); 配置.服饰实例数据.旋转数据 = new Vector3(num4, num5, num6); TMP_InputField 缩放数据x = 核心数据.缩放数据x; float num7 = 解析浮点数((缩放数据x != null) ? 缩放数据x.text : null, 1f); TMP_InputField 缩放数据y = 核心数据.缩放数据y; float num8 = 解析浮点数((缩放数据y != null) ? 缩放数据y.text : null, 1f); TMP_InputField 缩放数据z = 核心数据.缩放数据z; float num9 = 解析浮点数((缩放数据z != null) ? 缩放数据z.text : null, 1f); 配置.服饰实例数据.缩放数据 = new Vector3(num7, num8, num9); 记录调试($"整体变换: 位置={配置.服饰实例数据.位置数据}, 旋转={配置.服饰实例数据.旋转数据}, 缩放={配置.服饰实例数据.缩放数据}"); } } private void 收集所有网格数据(List<服饰包含默认网格实例数据> 默认网格列表, List<服饰包含自定义网格数据> 自定义模型列表) { if (所有核心数据 == null || 所有核心数据.Count == 0) { 记录调试("没有核心数据"); return; } int num = 0; int num2 = 0; foreach (实例化服饰数据核心类 item in 所有核心数据) { if ((Object)(object)item == (Object)null) { continue; } int num3 = (((Object)(object)item.指定下拉菜单 != (Object)null) ? item.指定下拉菜单.value : 0); switch (num3) { case 1: { 服饰包含默认网格实例数据 服饰包含默认网格实例数据2 = 提取默认几何体数据(item); if (服饰包含默认网格实例数据2 != null) { 默认网格列表.Add(服饰包含默认网格实例数据2); num++; 记录调试($"添加默认网格 [{num}]: {服饰包含默认网格实例数据2.网格类型}"); } break; } case 2: { 服饰包含自定义网格数据 服饰包含自定义网格数据2 = 提取自定义模型数据(item); if (服饰包含自定义网格数据2 != null) { 自定义模型列表.Add(服饰包含自定义网格数据2); num2++; 记录调试($"添加自定义模型 [{num2}]: {服饰包含自定义网格数据2.模型名称}"); } break; } default: 记录调试($"跳过模式 {num3} (无显示模式)"); break; } } } private 服饰包含默认网格实例数据 提取默认几何体数据(实例化服饰数据核心类 核心数据) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)核心数据 == (Object)null || (Object)(object)核心数据.默认实例几何体下拉菜单 == (Object)null) { return null; } try { int value = 核心数据.默认实例几何体下拉菜单.value; 服饰包含默认网格实例数据 obj = new 服饰包含默认网格实例数据 { 网格类型 = 转换几何体类型(value) }; TMP_InputField 位置数据x = 核心数据.位置数据x; string xText = ((位置数据x != null) ? 位置数据x.text : null); TMP_InputField 位置数据y = 核心数据.位置数据y; string yText = ((位置数据y != null) ? 位置数据y.text : null); TMP_InputField 位置数据z = 核心数据.位置数据z; obj.位置数据 = 提取Vector3(xText, yText, (位置数据z != null) ? 位置数据z.text : null, 0f); TMP_InputField 旋转数据x = 核心数据.旋转数据x; string xText2 = ((旋转数据x != null) ? 旋转数据x.text : null); TMP_InputField 旋转数据y = 核心数据.旋转数据y; string yText2 = ((旋转数据y != null) ? 旋转数据y.text : null); TMP_InputField 旋转数据z = 核心数据.旋转数据z; obj.旋转数据 = 提取Vector3(xText2, yText2, (旋转数据z != null) ? 旋转数据z.text : null, 0f); TMP_InputField 缩放数据x = 核心数据.缩放数据x; string xText3 = ((缩放数据x != null) ? 缩放数据x.text : null); TMP_InputField 缩放数据y = 核心数据.缩放数据y; string yText3 = ((缩放数据y != null) ? 缩放数据y.text : null); TMP_InputField 缩放数据z = 核心数据.缩放数据z; obj.缩放数据 = 提取Vector3(xText3, yText3, (缩放数据z != null) ? 缩放数据z.text : null, 1f); return obj; } catch (Exception ex) { Debug.LogError((object)("提取默认几何体数据失败: " + ex.Message)); return null; } } private 服饰包含自定义网格数据 提取自定义模型数据(实例化服饰数据核心类 核心数据) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)核心数据 == (Object)null || (Object)(object)核心数据.模型名称输入类 == (Object)null) { return null; } string text = 核心数据.模型名称输入类.text.Trim(); if (string.IsNullOrEmpty(text)) { 记录调试("模型名称为空,跳过"); return null; } try { 服饰包含自定义网格数据 obj = new 服饰包含自定义网格数据 { 模型名称 = text }; TMP_InputField 位置数据x = 核心数据.位置数据x; string xText = ((位置数据x != null) ? 位置数据x.text : null); TMP_InputField 位置数据y = 核心数据.位置数据y; string yText = ((位置数据y != null) ? 位置数据y.text : null); TMP_InputField 位置数据z = 核心数据.位置数据z; obj.位置数据 = 提取Vector3(xText, yText, (位置数据z != null) ? 位置数据z.text : null, 0f); TMP_InputField 旋转数据x = 核心数据.旋转数据x; string xText2 = ((旋转数据x != null) ? 旋转数据x.text : null); TMP_InputField 旋转数据y = 核心数据.旋转数据y; string yText2 = ((旋转数据y != null) ? 旋转数据y.text : null); TMP_InputField 旋转数据z = 核心数据.旋转数据z; obj.旋转数据 = 提取Vector3(xText2, yText2, (旋转数据z != null) ? 旋转数据z.text : null, 0f); TMP_InputField 缩放数据x = 核心数据.缩放数据x; string xText3 = ((缩放数据x != null) ? 缩放数据x.text : null); TMP_InputField 缩放数据y = 核心数据.缩放数据y; string yText3 = ((缩放数据y != null) ? 缩放数据y.text : null); TMP_InputField 缩放数据z = 核心数据.缩放数据z; obj.缩放数据 = 提取Vector3(xText3, yText3, (缩放数据z != null) ? 缩放数据z.text : null, 1f); return obj; } catch (Exception ex) { Debug.LogError((object)("提取自定义模型数据失败: " + ex.Message)); return null; } } private Vector3 提取Vector3(string xText, string yText, string zText, float defaultValue) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) float num = 解析浮点数(xText, defaultValue); float num2 = 解析浮点数(yText, defaultValue); float num3 = 解析浮点数(zText, defaultValue); return new Vector3(num, num2, num3); } private 默认网格类型 转换几何体类型(int 索引) { return 索引 switch { 0 => 默认网格类型.立方体, 1 => 默认网格类型.球体, 2 => 默认网格类型.胶囊体, 3 => 默认网格类型.柱体, _ => 默认网格类型.立方体, }; } private float 解析浮点数(string text, float defaultValue) { if (string.IsNullOrEmpty(text)) { return defaultValue; } if (float.TryParse(text, out var result)) { return result; } return defaultValue; } private bool 引用有效检测() { return (Object)(object)获取输入_服饰名称 != (Object)null && (Object)(object)获取输入_服饰MOdid != (Object)null && (Object)(object)获取输入_服饰id != (Object)null && (Object)(object)获取输入_服饰所在分类名称 != (Object)null && (Object)(object)分类下拉菜单 != (Object)null && 所有核心数据 != null && 所有核心数据.Count > 0; } private GearType 处理枚举转换(string 选择内容) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) return (GearType)(选择内容 switch { "Neck" => 1, "Body" => 3, "Hips" => 7, "Arm" => 4, "Forearm" => 5, "Thigh" => 8, "Leg" => 9, _ => 1, }); } public 服饰编辑器服饰数据容器 生成配置FromCoreData(实例化服饰数据核心类 核心数据) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)核心数据 == (Object)null) { return null; } 服饰编辑器服饰数据容器 服饰编辑器服饰数据容器2 = new 服饰编辑器服饰数据容器(); int num = (((Object)(object)核心数据.指定下拉菜单 != (Object)null) ? 核心数据.指定下拉菜单.value : 0); TMP_InputField obj = 获取输入_服饰名称; 服饰编辑器服饰数据容器2.服饰名称 = ((obj != null) ? obj.text : null) ?? ""; TMP_InputField obj2 = 获取输入_服饰所在分类名称; 服饰编辑器服饰数据容器2.服饰所在分类名称 = ((obj2 != null) ? obj2.text : null) ?? ""; TMP_Dropdown obj3 = 分类下拉菜单; object obj4; if (obj3 == null) { obj4 = null; } else { OptionData obj5 = obj3.options[分类下拉菜单.value]; obj4 = ((obj5 != null) ? obj5.text : null); } if (obj4 == null) { obj4 = "Body"; } 服饰编辑器服饰数据容器2.服饰分类枚举 = 处理枚举转换((string)obj4); int result = 0; int result2 = 0; TMP_InputField obj6 = 获取输入_服饰MOdid; int.TryParse((obj6 != null) ? obj6.text : null, out result); TMP_InputField obj7 = 获取输入_服饰id; int.TryParse((obj7 != null) ? obj7.text : null, out result2); 服饰编辑器服饰数据容器2.此服饰id.Modid = result; 服饰编辑器服饰数据容器2.此服饰id.id = result2; if (服饰编辑器服饰数据容器2.服饰实例数据 == null) { 服饰编辑器服饰数据容器2.服饰实例数据 = new 服饰包含实例数据(); } 提取整体变换数据(核心数据, 服饰编辑器服饰数据容器2); switch (num) { case 1: { 服饰包含默认网格实例数据 服饰包含默认网格实例数据2 = 提取默认几何体数据(核心数据); if (服饰包含默认网格实例数据2 != null) { 服饰编辑器服饰数据容器2.默认网格实例数据 = new 服饰包含默认网格实例数据[1] { 服饰包含默认网格实例数据2 }; } break; } case 2: { 服饰包含自定义网格数据 服饰包含自定义网格数据2 = 提取自定义模型数据(核心数据); if (服饰包含自定义网格数据2 != null) { 服饰编辑器服饰数据容器2.自定义模型实例数据 = new 服饰包含自定义网格数据[1] { 服饰包含自定义网格数据2 }; } break; } } return 服饰编辑器服饰数据容器2; } public List<服饰包含默认网格实例数据> 获取所有默认网格数据() { List<服饰包含默认网格实例数据> list = new List<服饰包含默认网格实例数据>(); foreach (实例化服饰数据核心类 item in 所有核心数据) { if ((Object)(object)item == (Object)null) { continue; } int num = (((Object)(object)item.指定下拉菜单 != (Object)null) ? item.指定下拉菜单.value : 0); if (num == 1) { 服饰包含默认网格实例数据 服饰包含默认网格实例数据2 = 提取默认几何体数据(item); if (服饰包含默认网格实例数据2 != null) { list.Add(服饰包含默认网格实例数据2); } } } return list; } public List<服饰包含自定义网格数据> 获取所有自定义模型数据() { List<服饰包含自定义网格数据> list = new List<服饰包含自定义网格数据>(); foreach (实例化服饰数据核心类 item in 所有核心数据) { if ((Object)(object)item == (Object)null) { continue; } int num = (((Object)(object)item.指定下拉菜单 != (Object)null) ? item.指定下拉菜单.value : 0); if (num == 2) { 服饰包含自定义网格数据 服饰包含自定义网格数据2 = 提取自定义模型数据(item); if (服饰包含自定义网格数据2 != null) { list.Add(服饰包含自定义网格数据2); } } } return list; } } public class ui返回生成并创建服饰 : MonoBehaviour { public ui获取并生成对应配置 获取类; public Button 保存按钮; public Button 重新加载按钮; public TextMeshProUGUI 状态提示文本; public bool 启用详细调试 = true; private void Start() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown 记录调试信息("=== UI初始化开始 ==="); try { 记录调试信息("正在初始化服饰编辑器配置文件生成..."); 服饰编辑器配置文件生成.初始化(); 记录调试信息("✅ 服饰编辑器配置文件生成 初始化完成"); if ((Object)(object)保存按钮 != (Object)null) { ((UnityEvent)保存按钮.onClick).AddListener(new UnityAction(执行保存)); 记录调试信息("✅ 保存按钮事件已绑定"); } else { 记录调试信息("⚠\ufe0f 保存按钮未绑定"); } if ((Object)(object)重新加载按钮 != (Object)null) { ((UnityEvent)重新加载按钮.onClick).AddListener(new UnityAction(执行重新加载)); 记录调试信息("✅ 重新加载按钮事件已绑定"); } else { 记录调试信息("⚠\ufe0f 重新加载按钮未绑定"); } int count = 服饰编辑器配置文件生成.获取所有配置().Count; 更新状态提示($"✅ 已加载 {count} 个服饰配置"); 记录调试信息($"当前配置数量: {count}"); if ((Object)(object)获取类 == (Object)null) { 记录调试信息("⚠\ufe0f 警告: 获取类未绑定"); 更新状态提示("⚠\ufe0f 警告: 获取类未绑定,请检查Inspector设置"); } else { 记录调试信息("✅ 获取类已绑定"); } } catch (Exception ex) { 记录调试信息("❌ 初始化失败: " + ex.Message); 记录调试信息("堆栈跟踪: " + ex.StackTrace); 更新状态提示("❌ 初始化失败: " + ex.Message); } 记录调试信息("=== UI初始化结束 ==="); } public void 执行保存() { 记录调试信息("=== 开始执行保存操作 ==="); try { 记录调试信息("步骤1: 检查获取类是否为空..."); if ((Object)(object)获取类 == (Object)null) { string 消息 = "❌ 错误: 获取类未绑定 (ui获取并生成对应配置)"; 记录调试信息(消息); 更新状态提示(消息); return; } 记录调试信息("✅ 获取类不为空"); 记录调试信息("步骤2: 检查获取类的输入字段..."); if (!检查获取类字段()) { string 消息2 = "❌ 错误: 获取类的输入字段不完整,请检查Inspector设置"; 记录调试信息(消息2); 更新状态提示(消息2); return; } 记录调试信息("✅ 所有输入字段有效"); 记录调试信息("步骤3: 调用生成对应配置类()..."); 服饰编辑器服饰数据容器 服饰编辑器服饰数据容器2 = null; try { 服饰编辑器服饰数据容器2 = 获取类.生成对应配置类(); } catch (Exception ex) { 记录调试信息("❌ 生成配置时发生异常: " + ex.Message); 记录调试信息("异常类型: " + ex.GetType().Name); 记录调试信息("堆栈跟踪: " + ex.StackTrace); 更新状态提示("❌ 生成配置异常: " + ex.Message); return; } if (服饰编辑器服饰数据容器2 == null) { string 消息3 = "❌ 错误: 配置生成失败,返回null (请检查输入数据)"; 记录调试信息(消息3); UpdateStatusWithInputValues(); return; } 记录调试信息($"✅ 配置生成成功: 服饰名称={服饰编辑器服饰数据容器2.服饰名称}, Modid={服饰编辑器服饰数据容器2.此服饰id.Modid}, id={服饰编辑器服饰数据容器2.此服饰id.id}"); 记录调试信息("步骤4: 检查配置ID是否重复..."); bool flag = 服饰编辑器配置文件生成.配置ID是否存在(服饰编辑器服饰数据容器2.此服饰id.Modid, 服饰编辑器服饰数据容器2.此服饰id.id); 记录调试信息($"配置ID存在: {flag}"); 记录调试信息("步骤5: 调用保存配置..."); bool flag2 = false; try { if (flag) { 记录调试信息($"⚠\ufe0f 发现重复ID,将覆盖旧配置 (Modid:{服饰编辑器服饰数据容器2.此服饰id.Modid}, id:{服饰编辑器服饰数据容器2.此服饰id.id})"); flag2 = 服饰编辑器配置文件生成.保存配置(服饰编辑器服饰数据容器2); if (flag2) { 更新状态提示($"✅ 配置已覆盖更新: {服饰编辑器服饰数据容器2.服饰名称} (Modid:{服饰编辑器服饰数据容器2.此服饰id.Modid}, id:{服饰编辑器服饰数据容器2.此服饰id.id})"); 记录调试信息("✅ 配置覆盖保存成功"); } else { 更新状态提示("❌ 配置覆盖失败: " + 服饰编辑器服饰数据容器2.服饰名称); 记录调试信息("❌ 配置覆盖保存失败"); } } else { 记录调试信息("配置ID不重复,直接保存"); flag2 = 服饰编辑器配置文件生成.保存配置(服饰编辑器服饰数据容器2); if (flag2) { 更新状态提示($"✅ 配置保存成功: {服饰编辑器服饰数据容器2.服饰名称} (Modid:{服饰编辑器服饰数据容器2.此服饰id.Modid}, id:{服饰编辑器服饰数据容器2.此服饰id.id})"); 记录调试信息("✅ 配置保存成功"); } else { 更新状态提示("❌ 配置保存失败: " + 服饰编辑器服饰数据容器2.服饰名称); 记录调试信息("❌ 配置保存失败"); } } } catch (Exception ex2) { 记录调试信息("❌ 保存配置时发生异常: " + ex2.Message); 记录调试信息("异常类型: " + ex2.GetType().Name); 记录调试信息("堆栈跟踪: " + ex2.StackTrace); 更新状态提示("❌ 保存配置异常: " + ex2.Message); return; } 记录调试信息("=== 保存操作完成,结果: " + (flag2 ? "成功" : "失败") + " ==="); if (flag2) { 输出当前配置列表(); } } catch (Exception ex3) { 记录调试信息("❌ 执行保存时发生未预期的异常: " + ex3.Message); 记录调试信息("异常类型: " + ex3.GetType().Name); 记录调试信息("堆栈跟踪: " + ex3.StackTrace); 更新状态提示("❌ 保存操作失败: " + ex3.Message); } } private bool 检查获取类字段() { bool result = true; if ((Object)(object)获取类.获取输入_服饰名称 == (Object)null) { 记录调试信息("⚠\ufe0f 获取输入_服饰名称 为 null"); result = false; } if ((Object)(object)获取类.获取输入_服饰所在分类名称 == (Object)null) { 记录调试信息("⚠\ufe0f 获取输入_服饰所在分类名称 为 null"); result = false; } if ((Object)(object)获取类.获取输入_服饰MOdid == (Object)null) { 记录调试信息("⚠\ufe0f 获取输入_服饰MOdid 为 null"); result = false; } if ((Object)(object)获取类.获取输入_服饰id == (Object)null) { 记录调试信息("⚠\ufe0f 获取输入_服饰id 为 null"); result = false; } if ((Object)(object)获取类.分类下拉菜单 == (Object)null) { 记录调试信息("⚠\ufe0f 分类下拉菜单 为 null"); result = false; } if (获取类.所有核心数据 == null) { 记录调试信息("⚠\ufe0f 所有核心数据 为 null"); result = false; } else if (获取类.所有核心数据.Count == 0) { 记录调试信息("⚠\ufe0f 所有核心数据 列表为空 (Count=0)"); result = false; } else { 记录调试信息($"✅ 所有核心数据 数量: {获取类.所有核心数据.Count}"); for (int i = 0; i < 获取类.所有核心数据.Count; i++) { 实例化服饰数据核心类 实例化服饰数据核心类 = 获取类.所有核心数据[i]; if ((Object)(object)实例化服饰数据核心类 == (Object)null) { 记录调试信息($"⚠\ufe0f 所有核心数据[{i}] 为 null"); result = false; continue; } 记录调试信息($"✅ 所有核心数据[{i}] 有效: {((Object)((Component)实例化服饰数据核心类).gameObject).name}"); if ((Object)(object)实例化服饰数据核心类.指定下拉菜单 == (Object)null) { 记录调试信息($" ⚠\ufe0f 核心数据[{i}].指定下拉菜单 为 null"); } if ((Object)(object)实例化服饰数据核心类.默认实例几何体下拉菜单 == (Object)null) { 记录调试信息($" ⚠\ufe0f 核心数据[{i}].默认实例几何体下拉菜单 为 null"); } if ((Object)(object)实例化服饰数据核心类.模型名称输入类 == (Object)null) { 记录调试信息($" ⚠\ufe0f 核心数据[{i}].模型名称输入类 为 null"); } if ((Object)(object)实例化服饰数据核心类.缩放数据x == (Object)null) { 记录调试信息($" ⚠\ufe0f 核心数据[{i}].缩放数据x 为 null"); } if ((Object)(object)实例化服饰数据核心类.位置数据x == (Object)null) { 记录调试信息($" ⚠\ufe0f 核心数据[{i}].位置数据x 为 null"); } if ((Object)(object)实例化服饰数据核心类.旋转数据x == (Object)null) { 记录调试信息($" ⚠\ufe0f 核心数据[{i}].旋转数据x 为 null"); } } } return result; } private void UpdateStatusWithInputValues() { string text = "\ud83d\udccb 当前输入值:\n"; text = ((!((Object)(object)获取类.获取输入_服饰名称 != (Object)null)) ? (text + "服饰名称: null\n") : (text + "服饰名称: '" + 获取类.获取输入_服饰名称.text + "'\n")); text = ((!((Object)(object)获取类.获取输入_服饰所在分类名称 != (Object)null)) ? (text + "分类名称: null\n") : (text + "分类名称: '" + 获取类.获取输入_服饰所在分类名称.text + "'\n")); text = ((!((Object)(object)获取类.获取输入_服饰MOdid != (Object)null)) ? (text + "Modid: null\n") : (text + "Modid: '" + 获取类.获取输入_服饰MOdid.text + "'\n")); text = ((!((Object)(object)获取类.获取输入_服饰id != (Object)null)) ? (text + "id: null\n") : (text + "id: '" + 获取类.获取输入_服饰id.text + "'\n")); text = ((!((Object)(object)获取类.分类下拉菜单 != (Object)null)) ? (text + "分类: null\n") : (text + "分类: '" + 获取类.分类下拉菜单.options[获取类.分类下拉菜单.value].text + "'\n")); 更新状态提示(text); 记录调试信息(text); } private void 输出当前配置列表() { List<服饰编辑器服饰数据容器> list = 服饰编辑器配置文件生成.获取所有配置(); 记录调试信息($"=== 当前共有 {list.Count} 个配置 ==="); foreach (服饰编辑器服饰数据容器 item in list) { 记录调试信息($" - {item.服饰名称} (Modid:{item.此服饰id.Modid}, id:{item.此服饰id.id})"); } } public void 执行重新加载() { 记录调试信息("=== 开始执行重新加载 ==="); try { 记录调试信息("正在重新加载所有配置..."); 服饰编辑器配置文件生成.重新加载所有配置(); int count = 服饰编辑器配置文件生成.获取所有配置().Count; 更新状态提示($"\ud83d\udd04 重新加载完成,共加载 {count} 个服饰配置"); 记录调试信息($"重新加载完成,共加载 {count} 个服饰配置"); 输出当前配置列表(); } catch (Exception ex) { 记录调试信息("❌ 重新加载失败: " + ex.Message); 记录调试信息("堆栈跟踪: " + ex.StackTrace); 更新状态提示("❌ 重新加载失败: " + ex.Message); } 记录调试信息("=== 重新加载结束 ==="); } private void 更新状态提示(string 消息) { if ((Object)(object)状态提示文本 != (Object)null) { ((TMP_Text)状态提示文本).text = 消息; } Debug.Log((object)("[UI] " + 消息)); } private void 记录调试信息(string 消息) { if (启用详细调试) { Debug.Log((object)("[调试] " + 消息)); } } public int 获取配置数量() { return 服饰编辑器配置文件生成.获取所有配置().Count; } public List 获取所有服饰名称() { return 服饰编辑器配置文件生成.获取所有服饰名称(); } public void 清除所有配置() { 记录调试信息("⚠\ufe0f 正在删除所有配置..."); 服饰编辑器配置文件生成.删除所有配置(); 更新状态提示("\ud83d\uddd1\ufe0f 所有配置已删除"); 记录调试信息("所有配置已删除"); } private void OnDestroy() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if ((Object)(object)保存按钮 != (Object)null) { ((UnityEvent)保存按钮.onClick).RemoveListener(new UnityAction(执行保存)); } if ((Object)(object)重新加载按钮 != (Object)null) { ((UnityEvent)重新加载按钮.onClick).RemoveListener(new UnityAction(执行重新加载)); } 记录调试信息("UI已销毁,事件绑定已清理"); } private void Update() { if (Input.GetKeyDown((KeyCode)282)) { Debug.Log((object)"=== 手动触发调试输出 ==="); 记录调试信息("获取类: " + (((Object)(object)获取类 != (Object)null) ? "已绑定" : "null")); if ((Object)(object)获取类 != (Object)null) { 检查获取类字段(); UpdateStatusWithInputValues(); } int count = 服饰编辑器配置文件生成.获取所有配置().Count; Debug.Log((object)$"当前配置数量: {count}"); 输出当前配置列表(); } } } public class 服饰编辑器服饰数据容器 { public id标识存储类 此服饰id = new id标识存储类(); public string 服饰名称 = ""; public string 服饰所在分类名称 = ""; public GearType 服饰分类枚举 = (GearType)3; public 服饰包含实例数据 服饰实例数据 = new 服饰包含实例数据(); public 服饰包含默认网格实例数据[] 默认网格实例数据; public 服饰包含自定义网格数据[] 自定义模型实例数据; } public class id标识存储类 { public int Modid = 0; public int id = 0; } public class 服饰包含实例数据 { public id标识存储类 服饰id = new id标识存储类(); public Vector3 缩放数据 = Vector3.zero; public Vector3 位置数据 = Vector3.zero; public Vector3 旋转数据 = Vector3.zero; } public enum 默认网格类型 { 立方体, 球体, 柱体, 胶囊体 } public class 服饰包含默认网格实例数据 { public 默认网格类型 网格类型 = 默认网格类型.立方体; public Vector3 缩放数据 = Vector3.zero; public Vector3 位置数据 = Vector3.zero; public Vector3 旋转数据 = Vector3.zero; } public class 服饰包含自定义网格数据 { public string 模型名称 = ""; public Vector3 缩放数据 = Vector3.zero; public Vector3 位置数据 = Vector3.zero; public Vector3 旋转数据 = Vector3.zero; } } namespace PropEditor.ui类 { public class 回到主菜单ui工具11 : MonoBehaviour { public void 回到主菜单() { TABSSceneManager.LoadMainMenu(); } } }