加了两个常用的快捷键,还是很有用的
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class GameObjectAct
{
//快捷键控制游戏对象的开关 alt + `
[MenuItem("Tools/Custom/Active GameObject &`")]
public static void ActiveGameObject()
{
GameObject go = Selection.activeGameObject;
if (go == null) return;
bool isActive = !go.activeSelf;
go.SetActive(isActive);
}
//快捷键控制保存Prefab alt + fs
[MenuItem("Tools/Custom/Apply GameObject &f")]
public static void ApplyPrefab()
{
GameObject go = Selection.activeGameObject;
if (go == null) return;
PrefabType type = PrefabUtility.GetPrefabType(go);
if (type == PrefabType.PrefabInstance)
{
Object target = PrefabUtility.GetCorrespondingObjectFromSource(go);
PrefabUtility.ReplacePrefab(go, target, ReplacePrefabOptions.ConnectToPrefab);
}
}
}
网友评论