This commit is contained in:
CortexCore
2023-10-20 19:31:12 +08:00
parent 5cd094ed9a
commit a160813262
1878 changed files with 630581 additions and 4485 deletions

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

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