浏览代码

[Bot] Automated dotnet-format update

/UI
Bronson Zgeb 4 年前
当前提交
e4eb624c
共有 3 个文件被更改,包括 43 次插入43 次删除
  1. 24
      UOP1_Project/Assets/Scripts/SaveSystem/Database.cs
  2. 48
      UOP1_Project/Assets/Scripts/SaveSystem/Editor/UuidDrawer.cs
  3. 14
      UOP1_Project/Assets/Scripts/SaveSystem/Uuid.cs

24
UOP1_Project/Assets/Scripts/SaveSystem/Database.cs


public abstract class Database<T> : ScriptableObject where T : IDesc
{
[SerializeField] protected List<T> _descs = new List<T>();
[SerializeField] protected List<T> _descs = new List<T>();
public virtual object FindByUuid(string uuid)
{
foreach (var desc in _descs)
{
if (desc.DescId.uuid == uuid)
{
return desc;
}
}
public virtual object FindByUuid(string uuid)
{
foreach (var desc in _descs)
{
if (desc.DescId.uuid == uuid)
{
return desc;
}
}
return null;
}
return null;
}
}

48
UOP1_Project/Assets/Scripts/SaveSystem/Editor/UuidDrawer.cs


[CustomPropertyDrawer(typeof(Uuid))]
public class UuidDrawer : PropertyDrawer
{
public override void OnGUI(Rect a_Position, SerializedProperty a_Property, GUIContent a_Label)
{
EditorGUI.BeginProperty(a_Position, a_Label, a_Property);
public override void OnGUI(Rect a_Position, SerializedProperty a_Property, GUIContent a_Label)
{
EditorGUI.BeginProperty(a_Position, a_Label, a_Property);
a_Position = EditorGUI.PrefixLabel(a_Position, GUIUtility.GetControlID(FocusType.Passive), a_Label);
a_Position = EditorGUI.PrefixLabel(a_Position, GUIUtility.GetControlID(FocusType.Passive), a_Label);
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
const int uuidButtonWidth = 80;
Rect uuidRect = new Rect(a_Position.x, a_Position.y, a_Position.width - uuidButtonWidth, a_Position.height);
Rect newUuidButtonRect =
new Rect(a_Position.x + uuidRect.width, a_Position.y, uuidButtonWidth, a_Position.height);
const int uuidButtonWidth = 80;
Rect uuidRect = new Rect(a_Position.x, a_Position.y, a_Position.width - uuidButtonWidth, a_Position.height);
Rect newUuidButtonRect =
new Rect(a_Position.x + uuidRect.width, a_Position.y, uuidButtonWidth, a_Position.height);
SerializedProperty uuidProperty = a_Property.FindPropertyRelative("uuid");
EditorGUI.SelectableLabel(uuidRect, uuidProperty.stringValue);
if (GUI.Button(newUuidButtonRect, "New Uuid"))
{
if (EditorUtility.DisplayDialog("Generate new UUID?",
"Generating a new UUID will break any data using the current uuid", "Yes", "Cancel"))
{
uuidProperty.stringValue = Guid.NewGuid().ToString();
}
}
SerializedProperty uuidProperty = a_Property.FindPropertyRelative("uuid");
EditorGUI.SelectableLabel(uuidRect, uuidProperty.stringValue);
if (GUI.Button(newUuidButtonRect, "New Uuid"))
{
if (EditorUtility.DisplayDialog("Generate new UUID?",
"Generating a new UUID will break any data using the current uuid", "Yes", "Cancel"))
{
uuidProperty.stringValue = Guid.NewGuid().ToString();
}
}
EditorGUI.indentLevel = indent;
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
EditorGUI.EndProperty();
}
}

14
UOP1_Project/Assets/Scripts/SaveSystem/Uuid.cs


[System.Serializable]
public class Uuid
{
public string uuid;
public string uuid;
public static Uuid Generate()
{
Uuid newUuid = new Uuid {uuid = System.Guid.NewGuid().ToString()};
return newUuid;
}
}
public static Uuid Generate()
{
Uuid newUuid = new Uuid { uuid = System.Guid.NewGuid().ToString() };
return newUuid;
}
}
正在加载...
取消
保存