1.Unity Prefab Apply All 设置快捷键,修改预设体之后快捷键应用
打包会出问题:The type or namespace name ‘EditorWindow‘ could not be found
EditorWindow类无法打包出EXE 添加unity关键字定义如下文所示:
#if UNITY_EDITOR
using UnityEditor;
...
...
...
#endif
2. Unity 的自定义快捷键 菜单栏 Edit->Shortcuts
上面的如果不想下插件:
using UnityEditor;
using UnityEngine;
namespace Tim
{
public class TimShortCuts : MonoBehaviour
{
[MenuItem("Tools/Reset Transform &r")]
static void ResetTransform()
{
GameObject[] selection = Selection.gameObjects;
if (selection.Length < 1) return;
Undo.RegisterCompleteObjectUndo(selection, "Zero Position");
foreach (GameObject go in selection)
{
InternalZeroPosition(go);
InternalZeroRotation(go);
InternalZeroScale(go);
}
}
private static void InternalZeroPosition(GameObject go)
{
go.transform.localPosition = Vector3.zero;
}
private static void InternalZeroRotation(GameObject go)
{
go.transform.localRotation = Quaternion.Euler(Vector3.zero);
}
private static void InternalZeroScale(GameObject go)
{
go.transform.localScale = Vector3.one;
}
[MenuItem("Tools/Apply changes to Prefab &a")]
static void SaveChangesToPrefab()
{
GameObject[] selection = Selection.gameObjects;
if (selection.Length < 1) return;
Undo.RegisterCompleteObjectUndo(selection, "Apply Prefab");
foreach (GameObject go in selection)
{
if (PrefabUtility.GetPrefabType(go) == PrefabType.PrefabInstance)
{
PrefabUtility.ReplacePrefab(go, PrefabUtility.GetPrefabParent(go));
PrefabUtility.RevertPrefabInstance(go);
}
}
}
}
}