浏览代码

Replacement Options

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

71
Editor/FindAndReplace/FindAndReplaceWindow.cs


[SerializeField]
Material materialSearch;
[SerializeField]
bool replacePosition = true;
[SerializeField]
bool replaceRotation = true;
[SerializeField]
bool replaceScale = false;
[SerializeField]
bool replaceParenting = true;
[SerializeField]
bool replaceTag = false;
[SerializeField]
bool replaceLayer = true;
[SerializeField]
bool replaceStatic = false;
enum SearchOp
{
Find,

void SearchControlsGUI()
{
EditorGUIUtility.labelWidth = 120;
GUILayout.Space(4);
GUILayout.Label("Search and Filter", Styles.boldLabel);
searchBy = (SearchBy)EditorGUILayout.EnumPopup(Contents.searchBy, searchBy);
switch(searchBy)

GUILayout.FlexibleSpace();
GUILayout.Label("Replace By", Styles.boldLabel);
prefabReplacement = (GameObject)EditorGUILayout.ObjectField(Contents.prefabReplacement, prefabReplacement, typeof(GameObject), true);
if (GUILayout.Button("Replace All", GUILayout.Height(32)) && prefabReplacement != null)
using (new GUILayout.HorizontalScope())
{
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));
}
using (new GUILayout.HorizontalScope())
{
replaceTag = GUILayout.Toggle(replaceTag, "Tag", EditorStyles.miniButtonLeft, GUILayout.Height(16));
replaceLayer = GUILayout.Toggle(replaceLayer, "Layer", EditorStyles.miniButtonMid, GUILayout.Height(16));
replaceStatic = GUILayout.Toggle(replaceStatic, "Static Flag", EditorStyles.miniButtonRight, GUILayout.Height(16));
}
if (GUILayout.Button("Replace All", Styles.bigButton, GUILayout.Height(24)) && prefabReplacement != null)
{
Undo.RecordObjects(searchResults.ToArray(), "Replace Objects");

{
var newObj = Instantiate<GameObject>(replacement);
newObj.name = replacement.name;
newObj.transform.position = toReplace.transform.position;
newObj.transform.rotation = toReplace.transform.rotation;
newObj.transform.parent = toReplace.transform.parent;
newObj.transform.localScale = toReplace.transform.localScale;
newObj.tag = toReplace.tag;
newObj.layer = toReplace.layer;
newObj.isStatic = toReplace.isStatic;
if(replacePosition)
newObj.transform.position = toReplace.transform.position;
if(replaceRotation)
newObj.transform.rotation = toReplace.transform.rotation;
if(replaceParenting)
newObj.transform.parent = toReplace.transform.parent;
if(replaceScale)
newObj.transform.localScale = toReplace.transform.localScale;
if(replaceTag)
newObj.tag = toReplace.tag;
if(replaceLayer)
newObj.layer = toReplace.layer;
if(replaceStatic)
newObj.isStatic = toReplace.isStatic;
foreach(var other in others)
{

{
using (new GUILayout.HorizontalScope())
{
if (GUILayout.Button("Find", GUILayout.Height(32)))
if (GUILayout.Button("Find", Styles.bigButton, GUILayout.Height(24)))
if (GUILayout.Button("Add", GUILayout.Height(32)))
if (GUILayout.Button("Add", Styles.bigButton, GUILayout.Height(24)))
if (GUILayout.Button("Refine", GUILayout.Height(32)))
if (GUILayout.Button("Refine", Styles.bigButton, GUILayout.Height(24)))
Search(SearchOp.Refine, by, criteria);
}

}
static class Styles
public static readonly GUIStyle bigButton = GetBigButton();
style.fontSize = 14;
return style;
}
static GUIStyle GetBigButton()
{
var style = new GUIStyle(EditorStyles.miniButton);
style.fontSize = 14;
return style;
}

正在加载...
取消
保存