1
This commit is contained in:
@@ -5,17 +5,16 @@ using System.Linq;
|
||||
using MonKey;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public partial class BITMonkeyCommands
|
||||
{
|
||||
[Command(nameof(ExportPrefabPreview), "导出已选的预制预览图", QuickName = "exp"), MenuItem("Tools/Instance Material")]
|
||||
[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 Selection.objects.Select(AssetPreview.GetAssetPreview))
|
||||
foreach (var image in UnityEditor.Selection.objects.Select(AssetPreview.GetAssetPreview))
|
||||
{
|
||||
var path = Path.Combine(exportPath, GUID.Generate() + ".png");
|
||||
File.WriteAllBytes( path, image.EncodeToPNG());
|
||||
|
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
using MonKey;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Selection = UnityEditor.Selection;
|
||||
namespace BITKit
|
||||
{
|
||||
public partial class BITMonkeyCommands
|
||||
@@ -13,12 +13,12 @@ namespace BITKit
|
||||
[Command(nameof(InstanceRendererMaterial), "Instance Material From Selected GameObject", QuickName = "ins"), MenuItem("Tools/Instance Material")]
|
||||
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>());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user