-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from DerpyNewbie/add-role-manager-preprocess
Add RoleManager preprocessing to prevent runtime crashes
- Loading branch information
Showing
9 changed files
with
1,080 additions
and
10 deletions.
There are no files selected for viewing
9 changes: 6 additions & 3 deletions
9
Packages/dev.derpynewbie.common/Editor/DerpyNewbie.Common.Editor.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
651 changes: 651 additions & 0 deletions
651
Packages/dev.derpynewbie.common/Editor/Inspector/RoleManagerEditor.cs
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
Packages/dev.derpynewbie.common/Editor/Inspector/RoleManagerEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using UnityEditor; | ||
|
||
namespace DerpyNewbie.Common.Editor | ||
{ | ||
public readonly struct Issue | ||
{ | ||
public string Message { get; } | ||
public MessageType MessageType { get; } | ||
public Action AutoFixAction { get; } | ||
public Action SelectAction { get; } | ||
|
||
public Issue(string message, MessageType messageType, Action autoFixAction = null, Action selectAction = null) | ||
{ | ||
Message = message; | ||
MessageType = messageType; | ||
AutoFixAction = autoFixAction; | ||
SelectAction = selectAction; | ||
} | ||
|
||
public void HelpBoxWithButton(float buttonWidth = 100F) | ||
{ | ||
if (AutoFixAction != null && SelectAction != null) | ||
{ | ||
NewbieCommonsEditorUtil.HelpBoxWithButton( | ||
Message, MessageType, | ||
"Select", SelectAction, | ||
"Auto Fix", AutoFixAction, | ||
buttonWidth | ||
); | ||
} | ||
else if (AutoFixAction != null) | ||
{ | ||
NewbieCommonsEditorUtil.HelpBoxWithButton( | ||
Message, MessageType, | ||
"Auto Fix", AutoFixAction, | ||
buttonWidth: buttonWidth | ||
); | ||
} | ||
else if (SelectAction != null) | ||
{ | ||
NewbieCommonsEditorUtil.HelpBoxWithButton( | ||
Message, MessageType, | ||
"Select", SelectAction, | ||
buttonWidth: buttonWidth | ||
); | ||
} | ||
else | ||
{ | ||
NewbieCommonsEditorUtil.HelpBoxWithButton( | ||
Message, MessageType | ||
); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 34 additions & 5 deletions
39
Packages/dev.derpynewbie.common/Editor/NewbieCommonsEditorUtil.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,46 @@ | ||
using UnityEngine; | ||
using System; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace DerpyNewbie.Common.Editor | ||
{ | ||
public static class NewbieCommonsEditorUtil | ||
{ | ||
public static void Log(object message) | ||
public static void Log(object message, UnityEngine.Object context = null) | ||
{ | ||
Debug.Log($"[NewbieCommons] {message}"); | ||
Debug.Log($"[NewbieCommons] {message}", context); | ||
} | ||
|
||
public static void LogError(object message) | ||
public static void LogError(object message, UnityEngine.Object context = null) | ||
{ | ||
Debug.LogError($"[NewbieCommons] {message}"); | ||
Debug.LogError($"[NewbieCommons] {message}", context); | ||
} | ||
|
||
public static void HelpBoxWithButton( | ||
string message, MessageType type, | ||
string button1Label = null, Action button1Action = null, | ||
string button2Label = null, Action button2Action = null, | ||
float buttonWidth = 100F) | ||
{ | ||
if (button1Label != null) | ||
EditorGUILayout.BeginHorizontal(); | ||
EditorGUILayout.HelpBox(message, type, true); | ||
|
||
if (button2Label != null) | ||
EditorGUILayout.BeginVertical(GUILayout.Width(buttonWidth)); | ||
|
||
if (button1Label != null && | ||
GUILayout.Button(button1Label, GUILayout.Width(buttonWidth), GUILayout.ExpandHeight(button2Label == null))) | ||
button1Action?.Invoke(); | ||
|
||
if (button2Label != null && GUILayout.Button(button2Label)) | ||
button2Action?.Invoke(); | ||
|
||
if (button2Label != null) | ||
EditorGUILayout.EndVertical(); | ||
|
||
if (button1Label != null) | ||
EditorGUILayout.EndHorizontal(); | ||
} | ||
} | ||
} |
Oops, something went wrong.