Skip to content

Commit

Permalink
avoid null reference spam for InputManager when grabbing axis for inv…
Browse files Browse the repository at this point in the history
…alid action, avoid null reference spam for modal manager inspector when controllers no longer exist, added UI_common.prefab for Unity UI
  • Loading branch information
ddionisio committed Jan 5, 2015
1 parent 2e421af commit 5d7dbe6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
9 changes: 4 additions & 5 deletions Editor/UI/UIModalManagerInspector.cs
Expand Up @@ -25,14 +25,13 @@ public class UIModalManagerInspector : Editor {

for(int i = 0; i < input.uis.Length; i++) {
UIModalManager.UIData dat = input.uis[i];
string goName = dat.e_ui.name;

GUILayout.BeginVertical(GUI.skin.box);

GUILayout.BeginHorizontal();

if(dat.e_ui != null) {
GUILayout.Label(goName);
GUILayout.Label(dat.e_ui.name);
}
else {
GUILayout.Label("(Need target!)");
Expand All @@ -42,7 +41,7 @@ public class UIModalManagerInspector : Editor {

if(dat.e_ui != null) {
if(M8.EditorExt.Utility.DrawCopyButton("Click to copy name.")) {
mTE.content = new GUIContent(goName);
mTE.content = new GUIContent(dat.e_ui.name);
mTE.SelectAll();
mTE.Copy();
}
Expand All @@ -58,7 +57,7 @@ public class UIModalManagerInspector : Editor {

dat.e_ui = EditorGUILayout.ObjectField("target", dat.e_ui, typeof(UIController), true) as UIController;
if(dat.e_ui) {
dat.name = goName;
dat.name = dat.e_ui.name;

dat.isPrefab = PrefabUtility.GetPrefabType(dat.e_ui) == PrefabType.Prefab;
if(dat.isPrefab) {
Expand Down
Binary file added Prefabs/UI_common.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Prefabs/UI_common.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Scripts/Input/InputManager.cs
Expand Up @@ -341,6 +341,8 @@ private struct ButtonCallSetData {
}

public float GetAxis(int player, int action) {
if(action == ActionInvalid) return 0f;

BindData bindData = mBinds[action];
PlayerData pd = bindData.players[player];
Key[] keys = pd.keys;
Expand All @@ -362,8 +364,7 @@ private struct ButtonCallSetData {

public float GetAxis(int player, string action) {
int actionInd = GetActionIndex(action);
if(actionInd != -1) return GetAxis(player, actionInd);
return 0f;
return GetAxis(player, actionInd);
}

public bool IsPressed(int player, string action) {
Expand Down

0 comments on commit 5d7dbe6

Please sign in to comment.