1
This commit is contained in:
33
Src/UnityPluginsSupport/MonkeyCommand/QuickFixFloatModel.cs
Normal file
33
Src/UnityPluginsSupport/MonkeyCommand/QuickFixFloatModel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using MonKey;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.GameEditor
|
||||
{
|
||||
public class QuickFixFloatModel
|
||||
{
|
||||
[Command(nameof(FixedSelectedFloat), "Fixed Selected Model Position", QuickName = "ins"), MenuItem("Tools/Scenes/Fix Float Model Position")]
|
||||
public static void FixedSelectedFloat()
|
||||
{
|
||||
var transforms = UnityEditor.Selection.transforms;
|
||||
if (transforms is null or {Length:0}) return;
|
||||
|
||||
var reportBuilder = new StringBuilder();
|
||||
reportBuilder.AppendLine($"已选择{transforms.Length}个物体:");
|
||||
foreach (var x in transforms)
|
||||
{
|
||||
if (Physics.Raycast(x.position, Vector3.down, out var hit, 1000) is false) continue;
|
||||
x.position = hit.point;
|
||||
EditorUtility.SetDirty(x);
|
||||
reportBuilder.AppendLine($"已修复{x.name}的位置于{hit.point}");
|
||||
}
|
||||
Undo.RecordObjects(transforms,"修复浮动");
|
||||
|
||||
Debug.Log(reportBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user