Skip to content

Commit

Permalink
修改增加删除枚举类型是显示错误
Browse files Browse the repository at this point in the history
  • Loading branch information
a13782425 committed Sep 2, 2018
1 parent 83b7003 commit 0915faa
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Assets/NewBehaviourScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
using System.Collections.Generic;
using UnityEngine;

public enum MyTestEnum
{
None
}

public enum TestEnum
{
None,
Expand Down
Binary file modified Assets/TSDatabase/Editor/Config/Global/PrimaryKey
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/TSDatabase/Editor/Config/Global/TableConfig.asset
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ MonoBehaviour:
FieldIndex: 15
GenericType: enum
GenericIndex: 4
EnumIndex: 0
EnumIndex: 1
EnumName: TestEnum
IsExport: 1
HasForeignKey: 0
Expand Down
32 changes: 31 additions & 1 deletion Assets/TSDatabase/Editor/EditorWindows/CreateTableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,38 @@ private void ShowConfigInfo()
}
else
{
#region 当项目增加枚举时候确保枚举是之前设置的值
if (_enumArray.Length > fieldConfig.EnumIndex && fieldConfig.EnumIndex != -1)
{
if (_enumArray[fieldConfig.EnumIndex] != fieldConfig.EnumName)
{
bool isFind = false;
for (int j = 0; j < _enumArray.Length; j++)
{
if (_enumArray[j] == fieldConfig.EnumName)
{
isFind = true;
fieldConfig.EnumIndex = j;
break;
}
}
if (!isFind)
{
fieldConfig.EnumIndex = -1;
}
}
}
else
{
fieldConfig.EnumIndex = -1;
}
#endregion

fieldConfig.EnumIndex = EditorGUILayout.Popup(fieldConfig.EnumIndex, _enumArray, GUILayout.Width(INFO_INPUT_WIDTH));
fieldConfig.EnumName = _enumArray[fieldConfig.EnumIndex];
if (fieldConfig.EnumIndex != -1)
{
fieldConfig.EnumName = _enumArray[fieldConfig.EnumIndex];
}
}
}
GUILayout.EndHorizontal();
Expand Down

0 comments on commit 0915faa

Please sign in to comment.