浏览代码

Better handling of Prefab Replacement

/main
Thomas ICHÉ 6 年前
当前提交
c60c58ab
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 12
      Editor/FindAndReplace/FindAndReplaceWindow.cs

12
Editor/FindAndReplace/FindAndReplaceWindow.cs


bool replaceLayer = true;
[SerializeField]
bool replaceStatic = false;
[SerializeField]
bool unpackPrefab = false;
enum SearchOp
{

replaceName = GUILayout.Toggle(replaceName, "Name", EditorStyles.miniButtonLeft, GUILayout.Height(16));
replaceTag = GUILayout.Toggle(replaceTag, "Tag", EditorStyles.miniButtonMid, GUILayout.Height(16));
replaceLayer = GUILayout.Toggle(replaceLayer, "Layer", EditorStyles.miniButtonMid, GUILayout.Height(16));
replaceStatic = GUILayout.Toggle(replaceStatic, "Static Flag", EditorStyles.miniButtonRight, GUILayout.Height(16));
replaceStatic = GUILayout.Toggle(replaceStatic, "Static", EditorStyles.miniButtonMid, GUILayout.Height(16));
unpackPrefab = GUILayout.Toggle(unpackPrefab, "Unpack Prefab", EditorStyles.miniButtonRight, GUILayout.Height(16));
}
if (GUILayout.Button("Replace All", Styles.bigButton, GUILayout.Height(24)) && prefabReplacement != null)

GameObject SwapObject(GameObject toReplace, GameObject replacement, List<GameObject> others)
{
var newObj = Instantiate<GameObject>(replacement);
GameObject newObj;
if (PrefabUtility.GetPrefabAssetType(replacement) != PrefabAssetType.NotAPrefab && !unpackPrefab)
newObj = (GameObject)PrefabUtility.InstantiatePrefab(replacement);
else
newObj = (GameObject)Instantiate<GameObject>(replacement);
if (replaceName)
newObj.name = replacement.name;

正在加载...
取消
保存