导入绳插件

This commit is contained in:
2025-11-03 23:13:35 +08:00
parent 7cf7f545bc
commit 32f07eb14e
2026 changed files with 12683 additions and 342462 deletions

View File

@@ -0,0 +1,44 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.UIElements;
namespace RopeToolkit
{
[CustomPropertyDrawer(typeof(DisableInPlayModeAttribute))]
public class BeginLockInPlayModeDecoratorDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var playing = Application.isPlaying;
if (playing)
{
GUI.enabled = false;
}
var ranges = fieldInfo.GetCustomAttributes(typeof(RangeAttribute), true);
var range = ranges != null && ranges.Length > 0 ? ranges[0] as RangeAttribute : null;
if (range != null && property.propertyType == SerializedPropertyType.Float)
{
EditorGUI.Slider(position, property, range.min, range.max);
}
else if (range != null && property.propertyType == SerializedPropertyType.Integer)
{
EditorGUI.IntSlider(position, property, (int)range.min, (int)range.max);
}
else
{
EditorGUI.PropertyField(position, property, label, true);
}
if (playing)
{
GUI.enabled = true;
}
}
}
}

View File

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

View File

@@ -0,0 +1,80 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Mathematics;
namespace RopeToolkit
{
[CustomEditor(typeof(Rope)), CanEditMultipleObjects]
public class RopeEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
}
public void OnSceneGUI()
{
if (Application.isPlaying)
{
return;
}
var rope = target as Rope;
if (rope == null)
{
return;
}
// Draw floating window with buttons
if (Selection.objects.Length == 1)
{
Handles.BeginGUI();
GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
var lastSpawn = rope.spawnPoints.Count > 0 ? rope.spawnPoints[rope.spawnPoints.Count - 1] : float3.zero;
var location = HandleUtility.WorldToGUIPoint(rope.transform.TransformPoint(lastSpawn)) + Vector2.right * 64.0f;
GUILayout.Window(0, new Rect(location, Vector2.one), (id) =>
{
if (GUILayout.Button("Push spawn point"))
{
Undo.RecordObject(rope, "Push Rope Spawn Point");
rope.PushSpawnPoint();
}
if (rope.spawnPoints.Count > 2 && GUILayout.Button("Pop spawn point"))
{
Undo.RecordObject(rope, "Pop Rope Spawn Point");
rope.PopSpawnPoint();
}
}, rope.gameObject.name);
Handles.EndGUI();
}
// Draw position handles
Handles.color = Rope.Colors.spawnPointHandle;
for (int i = 0; i < rope.spawnPoints.Count; i++)
{
var spawnPoint = rope.spawnPoints[i];
var position = rope.transform.TransformPoint(spawnPoint);
EditorGUI.BeginChangeCheck();
if (Event.current.modifiers.HasFlag(EventModifiers.Shift))
{
position = Handles.PositionHandle(position, Quaternion.identity);
}
else
{
var fmh_69_65_638978072337815361 = Quaternion.identity; position = Handles.FreeMoveHandle(position, rope.radius * 4.0f, Vector3.one * 0.5f, Handles.SphereHandleCap);
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(rope, "Move Rope Spawn Point");
spawnPoint = rope.transform.InverseTransformPoint(position);
rope.spawnPoints[i] = spawnPoint;
}
}
}
}
}

View File

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