Decompiled source of Prop Editor v1.0.1
PropEditor.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
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<RectTransform>(); parentCanvas = ((Component)this).GetComponentInParent<Canvas>(); 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<RectTransform>().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<Image>(); if ((Object)(object)cachedImage == (Object)null) { cachedSprite = ((Component)this).GetComponent<SpriteRenderer>(); } } 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<AudioSource>(); if ((Object)(object)audioSource == (Object)null) { audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); } } 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<GameObject>(实例化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<int>)(object)指定下拉菜单.onValueChanged).AddListener((UnityAction<int>)OnDropdownValueChanged); } if (Object.op_Implicit((Object)(object)默认实例几何体下拉菜单)) { ((UnityEvent<int>)(object)默认实例几何体下拉菜单.onValueChanged).AddListener((UnityAction<int>)OnDefaultGeometryChanged); } BindInputEvents(); ui获取并生成对应配置 component = ((Component)((Component)this).transform.root).GetComponent<ui获取并生成对应配置>(); if (Object.op_Implicit((Object)(object)component)) { component.所有核心数据.Add(this); } } private void BindInputEvents() { if (Object.op_Implicit((Object)(object)缩放数据x)) { ((UnityEvent<string>)(object)缩放数据x.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)缩放数据y)) { ((UnityEvent<string>)(object)缩放数据y.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)缩放数据z)) { ((UnityEvent<string>)(object)缩放数据z.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)位置数据x)) { ((UnityEvent<string>)(object)位置数据x.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)位置数据y)) { ((UnityEvent<string>)(object)位置数据y.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)位置数据z)) { ((UnityEvent<string>)(object)位置数据z.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)旋转数据x)) { ((UnityEvent<string>)(object)旋转数据x.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)旋转数据y)) { ((UnityEvent<string>)(object)旋转数据y.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)旋转数据z)) { ((UnityEvent<string>)(object)旋转数据z.onEndEdit).AddListener((UnityAction<string>)OnInputChanged); } if (Object.op_Implicit((Object)(object)模型名称输入类)) { ((UnityEvent<string>)(object)模型名称输入类.onEndEdit).AddListener((UnityAction<string>)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<ui获取并生成对应配置>(); 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<RectTransform>(); 原始大小 = (((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<TMP_Dropdown>(); } ((UnityEvent<int>)(object)myDropdown.onValueChanged).AddListener((UnityAction<int>)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<TMP_InputField>(); } ((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)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<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null)); yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != 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<GameObject>(((Component)val3).gameObject, val4); GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val4); Sprite sprite = UManager.ab包_普通资源.LoadAsset<Sprite>("ui图标we山地车fkjsdfip1"); Image component = ((Component)val5.transform.GetChild(0).GetChild(1)).GetComponent<Image>(); if (Object.op_Implicit((Object)(object)component)) { component.sprite = sprite; } Image component2 = ((Component)val5.transform.GetChild(1).GetChild(1)).GetComponent<Image>(); if (Object.op_Implicit((Object)(object)component2)) { component2.sprite = sprite; } LocalizeText component3 = ((Component)val5.transform.GetChild(1).GetChild(0)).GetComponent<LocalizeText>(); if (Object.op_Implicit((Object)(object)component3)) { component3.LocaleID = "服饰编辑器"; } Toggle componentInChildren = val5.GetComponentInChildren<Toggle>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return; } ((UnityEventBase)componentInChildren.onValueChanged).RemoveAllListeners(); ((UnityEvent<bool>)(object)componentInChildren.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { if (isOn) { SceneManager.LoadScene("FUshibianjiq"); } }); EventTrigger componentInChildren2 = val5.GetComponentInChildren<EventTrigger>(); 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<string> _支持的扩展名 = new List<string> { ".obj", ".OBJ" }; public static Dictionary<string, GameObject> 模型资源字典 { get; private set; } = new Dictionary<string, GameObject>(); public static bool 是否已初始化 => _是否已初始化; public static int 模型总数 => 模型资源字典.Count; public static List<string> 所有模型名称 => 模型资源字典.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<string, GameObject> 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<GameObject>(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<MeshFilter>(); 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<string, 服饰编辑器服饰数据容器> 字典_配置ID对应服饰数据类 = new Dictionary<string, 服饰编辑器服饰数据容器>(); public static Dictionary<string, 服饰编辑器服饰数据容器> 字典_配置文件路径对应服饰数据类 = new Dictionary<string, 服饰编辑器服饰数据容器>(); public static Dictionary<string, GameObject> 字典_服饰名称对应游戏对象 = new Dictionary<string, GameObject>(); 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<string, 服饰编辑器服饰数据容器> 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<string, 服饰编辑器服饰数据容器> 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>(); 记录调试("添加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<Tag>(); } ((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) { con