Skip to content

Commit 63bab14

Browse files
committed
重新修改编辑器的扩展
1 parent 95de9a3 commit 63bab14

10 files changed

+353
-365
lines changed

Assets/Game/Scripts/Editor/GameModeEditor.cs

Lines changed: 32 additions & 365 deletions
Large diffs are not rendered by default.

Assets/Game/Scripts/Editor/Module.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Zhang Yang. All rights reserved.
4+
// </copyright>
5+
// <describe> #资源模块编辑器# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年12月15日 17点24分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
using System.Collections;
11+
using System.Collections.Generic;
12+
using UnityEditor;
13+
using UnityEngine;
14+
15+
namespace GameFramework.Taurus
16+
{
17+
public class ResourceModuleEditor : ModuleEditorBase
18+
{
19+
public ResourceModuleEditor(string name, Color mainColor, GameMode gameMode)
20+
: base(name, mainColor, gameMode)
21+
{
22+
23+
}
24+
25+
public override void OnDrawGUI()
26+
{
27+
GUILayout.BeginVertical("HelpBox");
28+
29+
_gameMode.ResUpdateType =
30+
(ResourceUpdateType)EditorGUILayout.EnumPopup("Resource Update Type", _gameMode.ResUpdateType);
31+
if (_gameMode.ResUpdateType != ResourceUpdateType.Editor)
32+
{
33+
// _gameMode.ResUpdateType =
34+
//(ResourceUpdateType)EditorGUILayout.EnumPopup("Resource Update Type", _gameMode.ResUpdateType);
35+
if (_gameMode.ResUpdateType == ResourceUpdateType.Update)
36+
{
37+
_gameMode.ResUpdatePath =
38+
EditorGUILayout.TextField("Resource Update Path", _gameMode.ResUpdatePath);
39+
_gameMode.LocalPathType =
40+
(PathType)EditorGUILayout.EnumPopup("Local Path Type", PathType.ReadWrite);
41+
}
42+
else
43+
{
44+
_gameMode.LocalPathType =
45+
(PathType)EditorGUILayout.EnumPopup("Local Path Type", _gameMode.LocalPathType);
46+
}
47+
string path = "";
48+
switch (_gameMode.LocalPathType)
49+
{
50+
case PathType.DataPath:
51+
path = Application.dataPath;
52+
break;
53+
case PathType.ReadOnly:
54+
path = Application.streamingAssetsPath;
55+
break;
56+
case PathType.ReadWrite:
57+
path = Application.persistentDataPath;
58+
break;
59+
case PathType.TemporaryCache:
60+
path = Application.temporaryCachePath;
61+
break;
62+
}
63+
64+
EditorGUILayout.LabelField("Path", path);
65+
}
66+
67+
GUILayout.EndVertical();
68+
}
69+
70+
71+
public override void OnClose()
72+
{
73+
}
74+
75+
}
76+
}

Assets/Game/Scripts/Editor/Module/ResourceModuleEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Zhang Yang. All rights reserved.
4+
// </copyright>
5+
// <describe> #设置模块编辑器# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年12月15日 17点27分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
using System.Collections;
11+
using System.Collections.Generic;
12+
using UnityEngine;
13+
using UnityEditor;
14+
15+
namespace GameFramework.Taurus
16+
{
17+
public class SettingModuleEditor : ModuleEditorBase
18+
{
19+
public SettingModuleEditor(string name, Color mainColor, GameMode gameMode)
20+
: base(name, mainColor, gameMode)
21+
{ }
22+
23+
public override void OnDrawGUI()
24+
{
25+
GUILayout.BeginVertical("HelpBox");
26+
27+
GUI.color = _gameMode.DebugEnable ? Color.white : Color.gray;
28+
_gameMode.DebugEnable = GUILayout.Toggle(_gameMode.DebugEnable, "Debug Enable");
29+
GUI.color = Color.white;
30+
31+
GUILayout.EndVertical();
32+
}
33+
34+
public override void OnClose()
35+
{
36+
}
37+
}
38+
}

Assets/Game/Scripts/Editor/Module/SettingModuleEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Zhang Yang. All rights reserved.
4+
// </copyright>
5+
// <describe> #状态模块编辑器# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年12月15日 17点29分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
using System;
11+
using System.Collections;
12+
using System.Collections.Generic;
13+
using UnityEditor;
14+
using UnityEngine;
15+
using UnityEngine.Profiling;
16+
17+
namespace GameFramework.Taurus
18+
{
19+
public class StateModuleEditor : ModuleEditorBase
20+
{
21+
//所有状态
22+
private List<string> _listState;
23+
24+
public StateModuleEditor(string name, Color mainColor, GameMode gameMode)
25+
: base(name, mainColor, gameMode)
26+
{
27+
_listState = new List<string>();
28+
Type[] types = typeof(GameMode).Assembly.GetTypes();
29+
foreach (var item in types)
30+
{
31+
object[] attribute = item.GetCustomAttributes(typeof(GameStateAttribute), false);
32+
if (attribute.Length <= 0 || item.IsAbstract)
33+
continue;
34+
GameStateAttribute stateAttribute = (GameStateAttribute)attribute[0];
35+
//if (stateAttribute.StateType == VirtualStateType.Ignore)
36+
// continue;
37+
object obj = Activator.CreateInstance(item);
38+
GameState gs = obj as GameState;
39+
if (gs != null)
40+
_listState.Add("[" + stateAttribute.StateType.ToString() + "]\t" + item.FullName);
41+
}
42+
}
43+
44+
45+
public override void OnDrawGUI()
46+
{
47+
GUILayout.BeginVertical("HelpBox");
48+
49+
foreach (var item in _listState)
50+
{
51+
//正在运行
52+
if (EditorApplication.isPlaying)
53+
{
54+
string runName = "";
55+
if (GameMode.State.CurrentState != null)
56+
runName = GameMode.State.CurrentState.GetType().Name;
57+
if (item.Contains(runName))
58+
{
59+
GUILayout.BeginHorizontal();
60+
GUI.color = Color.green;
61+
GUILayout.Label("", GUI.skin.GetStyle("Icon.ExtrapolationContinue"));
62+
GUI.color = _defaultColor;
63+
GUILayout.Label(item);
64+
GUILayout.FlexibleSpace();
65+
GUILayout.Label((Profiler.GetMonoUsedSizeLong() / 1000000.0f).ToString("f3"));
66+
GUILayout.EndHorizontal();
67+
68+
continue;
69+
}
70+
}
71+
//默认状态
72+
GUI.enabled = false;
73+
GUILayout.BeginHorizontal();
74+
GUILayout.Label("", GUI.skin.GetStyle("Icon.ExtrapolationContinue"));
75+
GUILayout.Label(item);
76+
GUILayout.EndHorizontal();
77+
GUI.enabled = true;
78+
}
79+
80+
GUILayout.EndVertical();
81+
}
82+
83+
84+
public override void OnClose()
85+
{
86+
_listState.Clear();
87+
}
88+
89+
}
90+
}

Assets/Game/Scripts/Editor/Module/StateModuleEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Zhang Yang. All rights reserved.
4+
// </copyright>
5+
// <describe> #模块编辑器的基础类# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年12月15日 17点21分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
using System.Collections;
11+
using System.Collections.Generic;
12+
using UnityEditor;
13+
using UnityEngine;
14+
15+
namespace GameFramework.Taurus
16+
{
17+
public abstract class ModuleEditorBase
18+
{
19+
#region property
20+
//名称
21+
protected string _name;
22+
//主颜色
23+
protected Color _mainColor;
24+
//默认颜色
25+
protected Color _defaultColor;
26+
//主类
27+
protected GameMode _gameMode;
28+
//展开
29+
protected bool _isExpand;
30+
#endregion
31+
32+
public ModuleEditorBase(string name, Color mainColor, GameMode gameMode)
33+
{
34+
_name = name;
35+
_mainColor = mainColor;
36+
_defaultColor = GUI.color;
37+
_gameMode = gameMode;
38+
_isExpand = true;
39+
}
40+
41+
42+
//默认绘制界面
43+
public virtual void OnInspectorGUI()
44+
{
45+
GUI.color = _mainColor;
46+
GUILayout.BeginVertical("Box");
47+
GUI.color = _defaultColor;
48+
GUILayout.BeginHorizontal();
49+
GUILayout.Space(12);
50+
_isExpand = EditorGUILayout.Foldout(_isExpand, _name, true);
51+
GUILayout.EndHorizontal();
52+
if (_isExpand)
53+
OnDrawGUI();
54+
GUILayout.EndVertical();
55+
}
56+
57+
//绘制界面
58+
public abstract void OnDrawGUI();
59+
60+
//关闭界面
61+
public abstract void OnClose();
62+
63+
}
64+
65+
}

Assets/Game/Scripts/Editor/ModuleEditorBase.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)