You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
306 lines
14 KiB
306 lines
14 KiB
8 months ago
|
using UnityEngine;
|
||
|
using UnityEditor;
|
||
|
using AX.GeneralTools;
|
||
|
|
||
|
|
||
|
public class GeneralToolsUI : EditorWindow
|
||
|
{
|
||
|
|
||
|
[MenuItem("Tools/通用工具")]
|
||
|
static void GeneralToolWindow()
|
||
|
{
|
||
|
var wr = new Rect(0, 0, 300, 550);
|
||
|
var window = (GeneralToolsUI)EditorWindow.GetWindowWithRect(typeof(GeneralToolsUI), wr, true, "通用工具");
|
||
|
window.Show();
|
||
|
}
|
||
|
//定义滑条
|
||
|
private Vector2 UIScrollow;
|
||
|
private void OnEnable()
|
||
|
{
|
||
|
//GeneralTools.monoScript = CameraOrbit.FindSceneObjectsOfType;
|
||
|
}
|
||
|
void OnGUI()
|
||
|
{
|
||
|
UIScrollow = GUILayout.BeginScrollView(UIScrollow, GUILayout.Width(300), GUILayout.Height(520));
|
||
|
#region 重命名工具
|
||
|
EditorGUILayout.Space();
|
||
|
GeneralTools.isRenameTools = GUILayout.Toggle(GeneralTools.isRenameTools, "命名工具", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isRenameTools)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.renameType = (RenameType)EditorGUILayout.EnumPopup("类型", GeneralTools.renameType);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
switch (GeneralTools.renameType)
|
||
|
{
|
||
|
case RenameType.重命名:
|
||
|
GeneralTools.BaseName = EditorGUILayout.TextField("名称:", GeneralTools.BaseName);
|
||
|
GeneralTools.BaseCount = EditorGUILayout.IntField("基数:", GeneralTools.BaseCount);
|
||
|
GeneralTools.Increment = EditorGUILayout.IntField("间隔:", GeneralTools.Increment);
|
||
|
if (GUILayout.Button("确定"))
|
||
|
GeneralTools.OnRename();
|
||
|
break;
|
||
|
case RenameType.添加前缀:
|
||
|
GeneralTools.Prefix = EditorGUILayout.TextField("前缀:", GeneralTools.Prefix);
|
||
|
if (GUILayout.Button("确定"))
|
||
|
GeneralTools.OnAddPrefix();
|
||
|
break;
|
||
|
case RenameType.添加后缀:
|
||
|
GeneralTools.Suffix = EditorGUILayout.TextField("后缀:", GeneralTools.Suffix);
|
||
|
if (GUILayout.Button("确定"))
|
||
|
GeneralTools.OnAddSuffix();
|
||
|
break;
|
||
|
case RenameType.查找替换:
|
||
|
GeneralTools.FindName = EditorGUILayout.TextField("查找:", GeneralTools.FindName);
|
||
|
GeneralTools.ReplaceName = EditorGUILayout.TextField("替换:", GeneralTools.ReplaceName);
|
||
|
if (GUILayout.Button("确定"))
|
||
|
GeneralTools.OnReplace();
|
||
|
break;
|
||
|
}
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.EndVertical();
|
||
|
}//Rename End
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 复制选择物体名字
|
||
|
GeneralTools.isShowSelectedName = GUILayout.Toggle(GeneralTools.isShowSelectedName, "复制选择物体名字", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isShowSelectedName)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
if (GUILayout.Button("Copy"))
|
||
|
{
|
||
|
GameObject go = Selection.activeGameObject;
|
||
|
string fullName =GeneralTools.GetName(go.transform.parent, go.name);
|
||
|
GUIUtility.systemCopyBuffer = fullName;
|
||
|
}
|
||
|
|
||
|
GUILayout.EndVertical();
|
||
|
}
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 反转法线
|
||
|
GeneralTools.isFlip = GUILayout.Toggle(GeneralTools.isFlip, "反转法线", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isFlip)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
EditorGUILayout.HelpBox("选择单个物体,点击法线反转", MessageType.Info);
|
||
|
if (GUILayout.Button("法线反转"))
|
||
|
{
|
||
|
GeneralTools.FlipNormal();
|
||
|
}
|
||
|
GUILayout.EndVertical();
|
||
|
}
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 常用材质
|
||
|
GeneralTools.isCommonMaterial = GUILayout.Toggle(GeneralTools.isCommonMaterial, "常用材质", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isCommonMaterial)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GUILayout.BeginHorizontal();
|
||
|
if (GUILayout.Button("基础材质")) { GeneralTools.OnCommomMaterial(CommonMaterial.基础材质); }
|
||
|
if (GUILayout.Button("金属材质")) { GeneralTools.OnCommomMaterial(CommonMaterial.金属材质); }
|
||
|
if (GUILayout.Button("透明文字")) { GeneralTools.OnCommomMaterial(CommonMaterial.透明文字); }
|
||
|
GUILayout.EndHorizontal();
|
||
|
|
||
|
GUILayout.BeginHorizontal();
|
||
|
if (GUILayout.Button("主体透明")) { GeneralTools.OnCommomMaterial(CommonMaterial.主体透明); }
|
||
|
if (GUILayout.Button("周边配楼")) { GeneralTools.OnCommomMaterial(CommonMaterial.周边配楼); }
|
||
|
if (GUILayout.Button("玻璃门窗")) { GeneralTools.OnCommomMaterial(CommonMaterial.玻璃门窗); }
|
||
|
GUILayout.EndHorizontal();
|
||
|
GUILayout.EndVertical();
|
||
|
}
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
// #region 切换标准Shader为URP Shader
|
||
|
//GeneralTools.isConvertShander = GUILayout.Toggle(GeneralTools.isConvertShander, "切换Standart Shader 为 URP Shader", "ToolbarDropDownToggle");
|
||
|
//if (GeneralTools.isConvertShander)
|
||
|
//{
|
||
|
// GUILayout.BeginVertical("HelpBox");
|
||
|
|
||
|
// //GeneralTools.m_Material = EditorGUILayout.ObjectField(GeneralTools.m_Material, typeof(Material), true) as Material;
|
||
|
// //EditorGUILayout.Space();
|
||
|
// //GUILayout.BeginHorizontal();
|
||
|
// //GeneralTools.m_BaseMap = EditorGUILayout.ObjectField(GeneralTools.m_BaseMap, typeof(Texture2D), true) as Texture2D;
|
||
|
// //GUILayout.Label("BaseMap");
|
||
|
// //GeneralTools.m_BaseColor = EditorGUILayout.ColorField(GeneralTools.m_BaseColor);
|
||
|
// //GUILayout.EndHorizontal();
|
||
|
// //EditorGUILayout.Space();
|
||
|
// //GUILayout.BeginHorizontal();
|
||
|
// //GeneralTools.m_MetallicGlossMap = EditorGUILayout.ObjectField(GeneralTools.m_MetallicGlossMap, typeof(Texture2D), true) as Texture2D;
|
||
|
// //GUILayout.Label("MetallicMap");
|
||
|
// //GeneralTools.m_Metallic = EditorGUILayout.Slider(GeneralTools.m_Metallic,0,1);
|
||
|
// //GUILayout.EndHorizontal();
|
||
|
// //EditorGUILayout.Space();
|
||
|
// //GUILayout.BeginHorizontal();
|
||
|
// //GUILayout.Label("Smothness");
|
||
|
// //GeneralTools.m_Smothness = EditorGUILayout.Slider(GeneralTools.m_Smothness, 0, 1);
|
||
|
// //GUILayout.EndHorizontal();
|
||
|
// //EditorGUILayout.Space();
|
||
|
// //GUILayout.BeginHorizontal();
|
||
|
// //GeneralTools.m_BumpMap = EditorGUILayout.ObjectField(GeneralTools.m_BumpMap, typeof(Texture2D), true) as Texture2D;
|
||
|
// //GUILayout.Label("NormalMap");
|
||
|
// //GUILayout.EndHorizontal();
|
||
|
// //EditorGUILayout.Space();
|
||
|
// //GUILayout.BeginHorizontal();
|
||
|
// if (GUILayout.Button("Convert")) { GeneralTools.CovertShaderAttrube(); }
|
||
|
|
||
|
// if (GUILayout.Button("Component"))
|
||
|
// {
|
||
|
// var go = Selection.activeGameObject;
|
||
|
|
||
|
// if(go.GetComponent<DragObject>() == null)
|
||
|
// {
|
||
|
// go.AddComponent<DragObject>();
|
||
|
// }
|
||
|
|
||
|
// if (go.GetComponent<HighlightEffect>() == null)
|
||
|
// {
|
||
|
// go.AddComponent<HighlightEffect>();
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
|
||
|
//GUILayout.EndHorizontal();
|
||
|
|
||
|
|
||
|
|
||
|
// GUILayout.EndVertical();
|
||
|
//}
|
||
|
//EditorGUILayout.Space();
|
||
|
// #endregion
|
||
|
#region 切换材质颜色
|
||
|
GeneralTools.isMainColor = GUILayout.Toggle(GeneralTools.isMainColor, "切换标准材质颜色", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isMainColor)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.SelectMode = (ObjectMode)EditorGUILayout.EnumPopup("类型", GeneralTools.SelectMode);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
switch (GeneralTools.SelectMode)
|
||
|
{
|
||
|
case ObjectMode.所有物体:
|
||
|
GeneralTools.defaultColor = EditorGUILayout.ColorField("当前颜色:", GeneralTools.defaultColor);
|
||
|
GeneralTools.targetColor = EditorGUILayout.ColorField("目标颜色:", GeneralTools.targetColor);
|
||
|
break;
|
||
|
case ObjectMode.选择的物体:
|
||
|
GeneralTools.targetColor = EditorGUILayout.ColorField("目标颜色:", GeneralTools.targetColor);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (GUILayout.Button("切换")) { GeneralTools.OnMainColor(); }
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginHorizontal("Box");
|
||
|
GUILayout.BeginVertical();
|
||
|
GUILayout.Label("常用颜色:");
|
||
|
GUILayout.BeginHorizontal();
|
||
|
if (GUILayout.Button("黑色"))
|
||
|
GeneralTools.targetColor = Color.black;
|
||
|
if (GUILayout.Button("白色"))
|
||
|
GeneralTools.targetColor = Color.white;
|
||
|
if (GUILayout.Button("灰色"))
|
||
|
GeneralTools.targetColor = new Color(0.588f, 0.588f, 0.588f, 1f);
|
||
|
GUILayout.EndHorizontal();
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.EndHorizontal();
|
||
|
GUILayout.EndVertical();
|
||
|
}//MainColor End
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 添加常用组件
|
||
|
EditorGUILayout.Space();
|
||
|
GeneralTools.isCompent = GUILayout.Toggle(GeneralTools.isCompent, "添加或删除常用组件", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isCompent)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GeneralTools.compentType = (CompentType)EditorGUILayout.EnumPopup("类型", GeneralTools.compentType);
|
||
|
EditorGUILayout.BeginHorizontal();
|
||
|
GUILayout.BeginHorizontal("Box");
|
||
|
if (GUILayout.Button("BoxCollider"))
|
||
|
{
|
||
|
GeneralTools.Compents(ComponentMode.BoxCollider);
|
||
|
}
|
||
|
|
||
|
if (GUILayout.Button("MeshCollider"))
|
||
|
{
|
||
|
GeneralTools.Compents(ComponentMode.MeshCollider);
|
||
|
}
|
||
|
GUILayout.EndVertical();
|
||
|
EditorGUILayout.EndHorizontal();
|
||
|
GUILayout.EndVertical();
|
||
|
}//end AddCompent
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 设置父物体
|
||
|
GeneralTools.isSetParent = GUILayout.Toggle(GeneralTools.isSetParent, "设置父物体", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isSetParent)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GeneralTools.Parent = EditorGUILayout.ObjectField("Parent", GeneralTools.Parent, typeof(Transform), true) as Transform;
|
||
|
|
||
|
if (GUILayout.Button("Set")) { GeneralTools.SetParent(); }
|
||
|
GUILayout.EndVertical();
|
||
|
}
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 设置物体属性
|
||
|
GeneralTools.isAttribut = GUILayout.Toggle(GeneralTools.isAttribut, "设置物体属性", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isAttribut)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GeneralTools.NormalTag = EditorGUILayout.TagField("Tag:", GeneralTools.NormalTag);
|
||
|
GeneralTools.NormalLayer = EditorGUILayout.LayerField("Layer:", GeneralTools.NormalLayer);
|
||
|
GeneralTools.defualtCollider = (DefualtCollider)EditorGUILayout.EnumPopup("Collider:", GeneralTools.defualtCollider);
|
||
|
//GeneralTools.isAddInstantiateObjectInfo = EditorGUILayout.Toggle("添加实例化脚本:", GeneralTools.isAddInstantiateObjectInfo);
|
||
|
//if (GeneralTools.isAddInstantiateObjectInfo)
|
||
|
//{
|
||
|
// GeneralTools.FloorNum = EditorGUILayout.IntField("FloorNum", GeneralTools.FloorNum);
|
||
|
//}
|
||
|
if (GUILayout.Button("确定"))
|
||
|
GeneralTools.SetObjectAttribute();
|
||
|
GUILayout.EndVertical();
|
||
|
}
|
||
|
EditorGUILayout.Space();
|
||
|
#endregion
|
||
|
#region 替换场景中的prefab
|
||
|
GeneralTools.isReplacePrefab = GUILayout.Toggle(GeneralTools.isReplacePrefab, "替换Prefab", "ToolbarDropDownToggle");
|
||
|
if (GeneralTools.isReplacePrefab)
|
||
|
{
|
||
|
GUILayout.BeginVertical("HelpBox");
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.OriginalPrefab = EditorGUILayout.ObjectField("OriginalPrefab", GeneralTools.OriginalPrefab, typeof(GameObject), true) as GameObject;
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.isName = EditorGUILayout.Toggle("名称是否与原物体一致", GeneralTools.isName);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.isParent = EditorGUILayout.Toggle("父物体是否与原物体一致", GeneralTools.isParent);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.isPosition = EditorGUILayout.Toggle("位置是否与原物体一致", GeneralTools.isPosition);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.isRotation = EditorGUILayout.Toggle("旋转是否与原物体一致", GeneralTools.isRotation);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.isScale = EditorGUILayout.Toggle("缩放是否与原物体一致", GeneralTools.isScale);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
GeneralTools.isDestroyOriginalPrefab = EditorGUILayout.Toggle("是否删除原始物体", GeneralTools.isDestroyOriginalPrefab);
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.BeginVertical("Box");
|
||
|
if (GUILayout.Button("替换"))
|
||
|
{
|
||
|
GeneralTools.OnReplacePrefab();
|
||
|
}
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.EndVertical();
|
||
|
}
|
||
|
#endregion
|
||
|
//滑条结束,所有包含在滑条内的UI在此之上
|
||
|
GUILayout.EndScrollView();
|
||
|
}
|
||
|
}
|