26 lines
928 B
C#
26 lines
928 B
C#
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>());
|
|
}
|
|
}
|
|
|
|
}
|