This commit is contained in:
CortexCore
2024-11-03 16:42:23 +08:00
commit b125894cc3
5904 changed files with 1070129 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
{
"name": "BITKit.Extensions.MonkeyCommand",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:39db31f0562d9184c92881e43adea352"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"UNITY_EDITOR"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MonKey;
using UnityEditor;
using UnityEngine;
namespace BITKit
{
public partial class BITMonkeyCommands
{
[Command(nameof(ExportPrefabPreview), "导出已选的预制预览图", QuickName = "exp"), MenuItem("Tools/Export Selected Prefab Preview")]
private static void ExportPrefabPreview()
{
var exportPath = Path.Combine(Application.dataPath, "Temps");
PathHelper.EnsureDirectoryCreated(exportPath);
foreach (var image in UnityEditor.Selection.objects.Select(AssetPreview.GetAssetPreview))
{
var path = Path.Combine(exportPath, GUID.Generate() + ".png");
File.WriteAllBytes( path, image.EncodeToPNG());
}
}
}
}

View File

@@ -0,0 +1,25 @@
using System.Collections;
// ReSharper disable RedundantUsingDirective
using System.Collections.Generic;
// ReSharper restore RedundantUsingDirective
using MonKey;
using UnityEditor;
using UnityEngine;
using Selection = UnityEditor.Selection;
namespace BITKit
{
public partial class BITMonkeyCommands
{
[Command(nameof(InstanceRendererMaterial), "Instance Material From Selected GameObject", QuickName = "ins"), MenuItem("Tools/Instance Material")]
private static void InstanceRendererMaterial()
{
if (UnityEditor.Selection.activeTransform is null) return;
if (UnityEditor.Selection.activeTransform.TryGetComponent<Renderer>(out var renderer))
{
renderer.sharedMaterial = Object.Instantiate(renderer.material);
}
EditorUtility.SetDirty(UnityEditor.Selection.activeTransform.GetComponent<Renderer>());
}
}
}

View 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);
}
}
}

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using UnityEditor;
using MonKey;
using MonKey.Editor;
namespace BITKit
{
public class RestartUnity
{
[Command(nameof(Restart), "Restart Unity Now", QuickName = "re"), MenuItem("Restart/Now")]
static void Restart()
{
EditorApplication.OpenProject(Application.dataPath.Replace("Assets", string.Empty));
}
}
}