浏览代码

Fixes in Find/Replace window

/main
peeweek 5 年前
当前提交
34dfd8f4
共有 1 个文件被更改,包括 44 次插入35 次删除
  1. 79
      Editor/FindAndReplace/FindAndReplaceWindow.cs

79
Editor/FindAndReplace/FindAndReplaceWindow.cs


static readonly Dictionary<string, Type> s_assemblyTypes = GetTypes();
private static Dictionary<string,Type> GetTypes()
private static Dictionary<string, Type> GetTypes()
foreach(var assembly in AppDomain.CurrentDomain.GetAssemblies())
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
foreach(Type t in assembly.GetTypes())
foreach (Type t in assembly.GetTypes())
if(typeof(Component).IsAssignableFrom(t) && !all.ContainsKey(t.Name))
if (typeof(Component).IsAssignableFrom(t) && !all.ContainsKey(t.Name))
all.Add(t.Name, t);
}
}

Material materialSearch;
[SerializeField]
bool replacePosition = true;
bool keepPosition = true;
bool replaceRotation = true;
bool keepRotation = true;
bool replaceScale = false;
bool keepScale = false;
bool replaceParenting = true;
bool keepParenting = true;
bool replaceName = true;
bool keepName = true;
bool replaceTag = false;
bool keepTag = false;
bool replaceLayer = true;
bool keepLayer = true;
bool replaceStatic = false;
bool keepStatic = false;
[SerializeField]
bool unpackPrefab = false;

{
EditorGUIUtility.labelWidth = 120;
GUILayout.Space(4);
GUILayout.Label("Search and Filter", Styles.boldLabel);
GUILayout.Label("Search Scene Objects", Styles.boldLabel);
switch(searchBy)
switch (searchBy)
{
case SearchBy.Name:
nameSearch = EditorGUILayout.TextField(Contents.nameSearch, nameSearch);

GUILayout.FlexibleSpace();
GUILayout.Label("Replace By", Styles.boldLabel);
GUILayout.Label("Replace Results", Styles.boldLabel);
if (prefabReplacement != null)
{
PrefabAssetType type = PrefabUtility.GetPrefabAssetType(prefabReplacement);
bool isAPrefab = type == PrefabAssetType.Model || type == PrefabAssetType.Regular || type == PrefabAssetType.Variant;
if(isAPrefab)
unpackPrefab = EditorGUILayout.Toggle("Unpack Prefab", unpackPrefab);
}
EditorGUI.BeginDisabledGroup(prefabReplacement == null);
GUILayout.Label("Keep Properties:");
replacePosition = GUILayout.Toggle(replacePosition, "Position", EditorStyles.miniButtonLeft, GUILayout.Height(16));
replaceRotation = GUILayout.Toggle(replaceRotation, "Rotation", EditorStyles.miniButtonMid, GUILayout.Height(16));
replaceScale = GUILayout.Toggle(replaceScale, "Scale", EditorStyles.miniButtonMid, GUILayout.Height(16));
replaceParenting = GUILayout.Toggle(replaceParenting, "Parenting", EditorStyles.miniButtonRight, GUILayout.Height(16));
keepPosition = GUILayout.Toggle(keepPosition, "Position", EditorStyles.miniButtonLeft, GUILayout.Height(16));
keepRotation = GUILayout.Toggle(keepRotation, "Rotation", EditorStyles.miniButtonMid, GUILayout.Height(16));
keepScale = GUILayout.Toggle(keepScale, "Scale", EditorStyles.miniButtonMid, GUILayout.Height(16));
keepParenting = GUILayout.Toggle(keepParenting, "Parenting", EditorStyles.miniButtonRight, GUILayout.Height(16));
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", EditorStyles.miniButtonMid, GUILayout.Height(16));
unpackPrefab = GUILayout.Toggle(unpackPrefab, "Unpack Prefab", EditorStyles.miniButtonRight, GUILayout.Height(16));
keepName = GUILayout.Toggle(keepName, "Name", EditorStyles.miniButtonLeft, GUILayout.Height(16));
keepTag = GUILayout.Toggle(keepTag, "Tag", EditorStyles.miniButtonMid, GUILayout.Height(16));
keepLayer = GUILayout.Toggle(keepLayer, "Layer", EditorStyles.miniButtonMid, GUILayout.Height(16));
keepStatic = GUILayout.Toggle(keepStatic, "Static", EditorStyles.miniButtonRight, GUILayout.Height(16));
}
if (GUILayout.Button("Replace All", Styles.bigButton, GUILayout.Height(24)) && prefabReplacement != null)

searchResults[i] = newObj;
}
}
EditorGUI.EndDisabledGroup();
GUILayout.Space(8);
}

if (PrefabUtility.GetPrefabAssetType(replacement) != PrefabAssetType.NotAPrefab && !unpackPrefab)
newObj = (GameObject)PrefabUtility.InstantiatePrefab(replacement);
else
newObj = (GameObject)Instantiate<GameObject>(replacement);
newObj = Instantiate(replacement);
if (replaceName)
newObj.name = replacement.name;
else
if (keepName)
if(replacePosition)
if(keepPosition)
if(replaceRotation)
if(keepRotation)
if(replaceParenting)
if(keepParenting)
if(replaceScale)
if(keepScale)
if(replaceTag)
if(keepTag)
if(replaceLayer)
if(keepLayer)
if(replaceStatic)
if(keepStatic)
newObj.isStatic = toReplace.isStatic;
foreach(var other in others)

正在加载...
取消
保存