| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- using System.IO;
- using System.Text;
- using System.Linq;
- using System.Text.RegularExpressions;
- public class QiuQiuEditor : EditorWindow
- {
-
- private string m_DynamicBonePrefabPath;
-
- private static QiuQiuEditor m_Window;
-
- // 界面相关
- Color m_BlueColor = new Color(129 / 255f, 209 / 255f, 248 / 255f, 1);
- Color m_PinkColor = new Color(253 / 255f, 184 / 255f, 225 / 255f, 1);
- Color m_RedColor = new Color(233 / 255f, 74 / 255f, 110 / 255f, 1);
- Color m_PurpColor = new Color(125 / 255f, 128 / 255f, 227 / 255f, 1);
-
-
- float m_RowHeight = 20f;
- int m_RowFontSize = 12;
-
-
- GUIStyle m_MainHeaderStyle;
- GUIStyle m_SubHeaderStyle;
- GUIStyle m_ButtonStyle;
- GUIStyle m_TipsStyle;
- GUIStyle m_RedTipsStyle;
- GUIStyle m_LabelStyle;
- GUIStyle m_TagLabelStyle;
- GUIStyle m_ParamsLabelStyle;
-
-
- [MenuItem("球球测试/UI工具", false, 1)]
- static void ShowWindow()
- {
- if (m_Window == null)
- {
- m_Window = (QiuQiuEditor)GetWindow(typeof(QiuQiuEditor), true, "QiuQiuEditor");
- m_Window.Show();
- }
- else
- {
- m_Window.Close();
- m_Window = null;
- }
- }
- #region GUI
-
- void OnGUI()
- {
-
- InitStyle();
-
- EditorGUILayout.BeginVertical();
-
- EditorGUILayout.LabelField("球球 编辑器", m_MainHeaderStyle, GUILayout.Height(30));
-
- DrawSplitLine(25);
-
- if (GUILayout.Button("测试按钮", m_ButtonStyle, GUILayout.Width(150), GUILayout.Height(m_RowHeight)))
- {
-
- }
-
- EditorGUILayout.TextArea("部件模型路径", m_LabelStyle);
- Rect modelRect = EditorGUILayout.GetControlRect(GUILayout.Width(500));
- m_DynamicBonePrefabPath = EditorGUI.TextField(modelRect, m_DynamicBonePrefabPath);
- EditorGUILayout.Space();
- if ((Event.current.type == EventType.DragUpdated)
- && modelRect.Contains(Event.current.mousePosition))
- {
- DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
- }
- if ((Event.current.type == EventType.DragPerform) && modelRect.Contains(Event.current.mousePosition))
- {
- if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
- {
- m_DynamicBonePrefabPath = DragAndDrop.paths[0];
- }
- }
-
- if (GUILayout.Button("生成DynamicBone参数", m_ButtonStyle, GUILayout.Width(150),
- GUILayout.Height(m_RowHeight)))
- {
- OnClickCreateDynamicBoneParams();
- }
-
-
- EditorGUILayout.Space();
-
- EditorGUILayout.TextArea("测试文本:\n", m_TipsStyle);
-
- EditorGUILayout.TextArea("测试列表 \n", m_RedTipsStyle);
-
- EditorGUILayout.Space();
- OnDrawListView();
-
- EditorGUILayout.EndVertical();
- }
- #endregion
-
-
- void InitStyle()
- {
- if (m_MainHeaderStyle == null)
- {
- m_MainHeaderStyle = new GUIStyle(GUI.skin.label);
- m_MainHeaderStyle.fontSize = 20;
- m_MainHeaderStyle.fontStyle = FontStyle.Bold;
- m_MainHeaderStyle.normal.textColor = m_BlueColor;
- }
-
- if (m_ButtonStyle == null)
- {
- m_ButtonStyle = new GUIStyle(GUI.skin.button);
- m_ButtonStyle.fontSize = 14;
- }
-
- if (m_TipsStyle == null)
- {
- m_TipsStyle = new GUIStyle(GUI.skin.label);
- m_TipsStyle.normal.textColor = m_PinkColor;
- m_TipsStyle.fontSize = m_RowFontSize;
- }
-
- if (m_RedTipsStyle == null)
- {
- m_RedTipsStyle = new GUIStyle(GUI.skin.label);
- m_RedTipsStyle.normal.textColor = m_RedColor;
- m_RedTipsStyle.fontSize = m_RowFontSize;
- }
-
- if (m_TagLabelStyle == null)
- {
- m_TagLabelStyle = new GUIStyle(GUI.skin.label);
- m_TagLabelStyle.normal.textColor = m_PinkColor;
- m_TagLabelStyle.fontSize = 16;
- }
-
- if (m_ParamsLabelStyle == null)
- {
- m_ParamsLabelStyle = new GUIStyle(GUI.skin.label);
- m_ParamsLabelStyle.normal.textColor = m_PurpColor;
- m_ParamsLabelStyle.fontSize = 13;
- }
-
- if (m_LabelStyle == null)
- {
- m_LabelStyle = new GUIStyle(GUI.skin.label);
- m_LabelStyle.normal.textColor = m_BlueColor;
- m_LabelStyle.fontSize = 18;
- }
-
- }
-
-
- void DrawSplitLine(float height)
- {
- GUI.Box(new Rect(0, height, position.width, 1), string.Empty);
- }
- #region ScrollView
- Vector2 _scrollPos;
- void OnDrawListView()
- {
- _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, false, false, GUILayout.Width(500), GUILayout.Height(400));
- for (int i = 0; i < 100; i++)
- {
- var Damping = EditorGUILayout.FloatField("Damping",i , m_ParamsLabelStyle);
-
- EditorGUILayout.BeginHorizontal();
-
- if (GUILayout.Button("+", m_ButtonStyle, GUILayout.Width(50), GUILayout.Height(m_RowHeight)))
- {
- Debug.Log("+");
- }
- if (GUILayout.Button("-", m_ButtonStyle, GUILayout.Width(50), GUILayout.Height(m_RowHeight)))
- {
- Debug.Log("-");
- }
-
- EditorGUILayout.EndHorizontal();
-
- }
-
-
-
- EditorGUILayout.EndScrollView(); // 组结束
-
-
- }
- void OnClickCreateDynamicBoneParams()
- {
- if (string.IsNullOrEmpty(m_DynamicBonePrefabPath))
- {
- return;
- }
-
- Debug.Log(m_DynamicBonePrefabPath);
- }
- #endregion
- }
|