Fixes to PR + assign null to remove warnings

This commit is contained in:
Adam Ramberg 2019-04-08 16:14:50 +02:00
parent e65b69d8e9
commit 77cfaa1f24
27 changed files with 122 additions and 101 deletions

View File

@ -126,10 +126,17 @@ There is an `.editorconfig` at the root of the repository located [here](/.edito
* **White Space:** Trim empty whitespace from the ends of lines.
#### Naming and Formatting
* Namespaces, Defined Types, Methods, and Events should all be in upper pascal case.
* Public fields should be in lower pascal case like `isLoaded` while private fields should be lower pascal case prefixed with a `_` character like `_isLoaded`.
* Public and private properties should be in upper pascal case `IsLoaded`.
* Readonly, static, or const fields should be in upper pascal case `IsLoaded`.
| Object Name | Notation | Example |
| ----------- | -------- | ------- |
| Namespaces | PascalCase | UnityAtoms |
| Classes | PascalCase | AtomicTags |
| Methods | PascalCase | GetTags |
| Method arguments | camelCase | oldValue |
| Properties | PascalCase | Value |
| Public fields | PascalCase | Value |
| Private fields | _camelCase | _value |
| Constants | SNAKE_CASE | NETWORK_ACCESS_TOKEN_SIZE |
| Inline variables | camelCase | value |
#### Structure
* Follow good encapsulation principles and try to limit exposing fields directly as public; unless necessary everything should be marked as private/protected unless necessary. Where public access to a field is needed, use a public property instead.

View File

@ -8,7 +8,7 @@ namespace UnityAtoms
/// </summary>
public class ReadOnlyList<T> : IEnumerable<T>
{
private readonly IList<T> _referenceList;
private readonly IList<T> _referenceList = null;
public ReadOnlyList(IList<T> referenceList)
{

View File

@ -8,11 +8,11 @@ namespace UnityAtoms.UI
{
[FormerlySerializedAs("UIStateVariable")]
[SerializeField]
private StringVariable _UIStateVariable;
private StringVariable _UIStateVariable = null;
[FormerlySerializedAs("VisibleForStates")]
[SerializeField]
private List<StringConstant> _visibleForStates;
private List<StringConstant> _visibleForStates = null;
private void Start()
{

View File

@ -11,23 +11,23 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Condition")]
[SerializeField]
private C _condition;
private C _condition = null;
[FormerlySerializedAs("Action")]
[SerializeField]
private GA _action;
private GA _action = null;
[FormerlySerializedAs("VoidAction")]
[SerializeField]
private VoidAction _voidAction;
private VoidAction _voidAction = null;
[FormerlySerializedAs("ElseAction")]
[SerializeField]
private GA _elseAction;
private GA _elseAction = null;
[FormerlySerializedAs("ElseVoidAction")]
[SerializeField]
private VoidAction _elseVoidAction;
private VoidAction _elseVoidAction = null;
public void Do(T1 t1)
{
@ -85,19 +85,19 @@ namespace UnityAtoms
where C : GameFunction<bool, T1, T2, T3>
{
[SerializeField]
private C _condition;
private C _condition = null;
[SerializeField]
private GA _action;
private GA _action = null;
[SerializeField]
private VoidAction _voidAction;
private VoidAction _voidAction = null;
[SerializeField]
private GA _elseAction;
private GA _elseAction = null;
[SerializeField]
private VoidAction _elseVoidAction;
private VoidAction _elseVoidAction = null;
public void Do(T1 t1, T2 t2, T3 t3)
{
@ -120,19 +120,19 @@ namespace UnityAtoms
where C : GameFunction<bool, T1, T2, T3, T4>
{
[SerializeField]
private C _condition;
private C _condition = null;
[SerializeField]
private GA _action;
private GA _action = null;
[SerializeField]
private VoidAction _voidAction;
private VoidAction _voidAction = null;
[SerializeField]
private GA _elseAction;
private GA _elseAction = null;
[SerializeField]
private VoidAction _elseVoidAction;
private VoidAction _elseVoidAction = null;
public void Do(T1 t1, T2 t2, T3 t3, T4 t4)
{
@ -155,19 +155,19 @@ namespace UnityAtoms
where C : GameFunction<bool, T1, T2, T3, T4, T5>
{
[SerializeField]
private C _condition;
private C _condition = null;
[SerializeField]
private GA _action;
private GA _action = null;
[SerializeField]
private VoidAction _voidAction;
private VoidAction _voidAction = null;
[SerializeField]
private GA _elseAction;
private GA _elseAction = null;
[SerializeField]
private VoidAction _elseVoidAction;
private VoidAction _elseVoidAction = null;
public void Do(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
namespace UnityAtoms
{
@ -11,43 +12,53 @@ namespace UnityAtoms
where UER1 : UnityEvent<T> where UER2 : UnityEvent<T, GameObject>
where MH : MonoHook<E1, E2, T, GameObjectGameObjectFunction>
{
public bool CreateEvent = true;
[FormerlySerializedAs("CreateEvent")]
[SerializeField]
private bool _createEvent = true;
public bool CreateEventWithGameObject;
[FormerlySerializedAs("CreateEventWithGameObject")]
[SerializeField]
private bool _createEventWithGameObject = true;
public List<MH> MonoHooks;
[FormerlySerializedAs("MonoHooks")]
[SerializeField]
private List<MH> _monoHooks = null;
public L1 Listener;
[FormerlySerializedAs("Listener")]
[SerializeField]
private L1 _listener = null;
public L2 ListenerWithGameObject;
[FormerlySerializedAs("ListenerWithGameObject")]
[SerializeField]
private L2 _listenerWithGameObject = null;
private void Awake()
{
var e1 = CreateEvent ? ScriptableObject.CreateInstance<E1>() : null;
var e2 = CreateEventWithGameObject ? ScriptableObject.CreateInstance<E2>() : null;
var e1 = _createEvent ? ScriptableObject.CreateInstance<E1>() : null;
var e2 = _createEventWithGameObject ? ScriptableObject.CreateInstance<E2>() : null;
if (e1 != null)
{
for (int i = 0; MonoHooks != null && i < MonoHooks.Count; ++i)
for (int i = 0; _monoHooks != null && i < _monoHooks.Count; ++i)
{
MonoHooks[i].Event = e1;
_monoHooks[i].Event = e1;
}
if (Listener != null)
if (_listener != null)
{
Listener.GameEvent = e1;
e1.RegisterListener(Listener);
_listener.GameEvent = e1;
e1.RegisterListener(_listener);
}
}
if (e2 != null)
{
for (int i = 0; MonoHooks != null && i < MonoHooks.Count; ++i)
for (int i = 0; _monoHooks != null && i < _monoHooks.Count; ++i)
{
MonoHooks[i].EventWithGameObjectReference = e2;
_monoHooks[i].EventWithGameObjectReference = e2;
}
if (ListenerWithGameObject != null)
if (_listenerWithGameObject != null)
{
ListenerWithGameObject.GameEvent = e2;
e2.RegisterListener(ListenerWithGameObject);
_listenerWithGameObject.GameEvent = e2;
e2.RegisterListener(_listenerWithGameObject);
}
}
}

View File

@ -22,27 +22,27 @@ namespace UnityAtoms
[FormerlySerializedAs("CreateClearedEvent")]
[SerializeField]
private bool _createClearedEvent;
private bool _createClearedEvent = false;
[FormerlySerializedAs("AddedListener")]
[SerializeField]
private TEL _addedListener;
private TEL _addedListener = null;
[FormerlySerializedAs("RemovedListener")]
[SerializeField]
private TEL _removedListener;
private TEL _removedListener = null;
[FormerlySerializedAs("ClearedListener")]
[SerializeField]
private VoidListener _clearedListener;
private VoidListener _clearedListener = null;
[FormerlySerializedAs("OnListCreate")]
[SerializeField]
private GA1 _onListCreate;
private GA1 _onListCreate = null;
[FormerlySerializedAs("OnListCreateWithGO")]
[SerializeField]
private GA2 _onListCreateWithGO;
private GA2 _onListCreateWithGO = null;
private void Awake()
{

View File

@ -24,23 +24,23 @@ namespace UnityAtoms
[FormerlySerializedAs("CreateChangedWithHistoryEvent")]
[SerializeField]
private bool _createChangedWithHistoryEvent;
private bool _createChangedWithHistoryEvent = false;
[FormerlySerializedAs("Listener")]
[SerializeField]
private L1 _listener;
private L1 _listener = null;
[FormerlySerializedAs("ListenerWithHistory")]
[SerializeField]
private L2 _listenerWithHistory;
private L2 _listenerWithHistory = null;
[FormerlySerializedAs("OnVariableCreate")]
[SerializeField]
private GA3 _onVariableCreate;
private GA3 _onVariableCreate = null;
[FormerlySerializedAs("OnVariableCreateWithGO")]
[SerializeField]
private GA4 _onVariableCreateWithGO;
private GA4 _onVariableCreateWithGO = null;
private void Awake()
{

View File

@ -11,13 +11,13 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Event")]
[SerializeField]
private E _event;
private E _event = null;
public E GameEvent { get { return _event; } set { _event = value; } }
[FormerlySerializedAs("UnityEventResponse")]
[SerializeField]
private UER _unityEventResponse;
private UER _unityEventResponse = null;
[FormerlySerializedAs("GameActionResponses")]
[SerializeField]

View File

@ -18,6 +18,7 @@ namespace UnityAtoms
protected ScriptableObjectReference(T value) : this()
{
UseConstant = true;
ConstantValue = value;
}

View File

@ -11,11 +11,11 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Variable")]
[SerializeField]
private V _variable;
private V _variable = null;
[FormerlySerializedAs("Value")]
[SerializeField]
private R _value;
private R _value = null;
public override void Do()
{

View File

@ -12,7 +12,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Conditional")]
[SerializeField]
private ConditionalBoolGameActionHelper _conditional;
private ConditionalBoolGameActionHelper _conditional = null;
public override void Do(bool t1)
{

View File

@ -12,7 +12,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Conditional")]
[SerializeField]
private ConditionalColorGameActionHelper _conditional;
private ConditionalColorGameActionHelper _conditional = null;
public override void Do(Color t1)
{

View File

@ -5,17 +5,17 @@ namespace UnityAtoms
{
public abstract class ReferenceDrawer : PropertyDrawer
{
private static readonly string[] PopupOptions =
private static readonly string[] _popupOptions =
{ "Use Constant", "Use Variable" };
private static GUIStyle PopupStyle;
private static GUIStyle _popupStyle;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (PopupStyle == null)
if (_popupStyle == null)
{
PopupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions"));
PopupStyle.imagePosition = ImagePosition.ImageOnly;
_popupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions"));
_popupStyle.imagePosition = ImagePosition.ImageOnly;
}
label = EditorGUI.BeginProperty(position, label, property);
@ -30,15 +30,15 @@ namespace UnityAtoms
// Calculate rect for configuration button
Rect buttonRect = new Rect(position);
buttonRect.yMin += PopupStyle.margin.top;
buttonRect.width = PopupStyle.fixedWidth + PopupStyle.margin.right;
buttonRect.yMin += _popupStyle.margin.top;
buttonRect.width = _popupStyle.fixedWidth + _popupStyle.margin.right;
position.xMin = buttonRect.xMax;
// Store old indent level and set it to 0, the PrefixLabel takes care of it
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
int result = EditorGUI.Popup(buttonRect, useConstant.boolValue ? 0 : 1, PopupOptions, PopupStyle);
int result = EditorGUI.Popup(buttonRect, useConstant.boolValue ? 0 : 1, _popupOptions, _popupStyle);
useConstant.boolValue = result == 0;

View File

@ -15,15 +15,15 @@ namespace UnityAtoms
{
[FormerlySerializedAs("List")]
[SerializeField]
private GameObjectList _list;
private GameObjectList _list = null;
[FormerlySerializedAs("Prefab")]
[SerializeField]
private GameObject _prefab;
private GameObject _prefab = null;
[FormerlySerializedAs("IsNotUsed")]
[SerializeField]
private BoolGameObjectFunction _isNotUsed;
private BoolGameObjectFunction _isNotUsed = null;
public override GameObject Call(Vector3 position, Quaternion quaternion)
{

View File

@ -12,7 +12,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Conditional")]
[SerializeField]
private ConditionalIntGameActionHelper _conditional;
private ConditionalIntGameActionHelper _conditional = null;
public override void Do(int t1)
{

View File

@ -4,21 +4,21 @@ namespace UnityAtoms.Logger
{
public static class AtomsLogger
{
private const string LogPrefix = "Unity Atoms :: ";
private const string LOG_PREFIX = "Unity Atoms :: ";
public static void Log(string msg)
{
Debug.Log(LogPrefix + msg);
Debug.Log(LOG_PREFIX + msg);
}
public static void Warning(string msg)
{
Debug.LogWarning(LogPrefix + msg);
Debug.LogWarning(LOG_PREFIX + msg);
}
public static void Error(string msg)
{
Debug.LogError(LogPrefix + msg);
Debug.LogError(LOG_PREFIX + msg);
}
}
}

View File

@ -9,31 +9,31 @@ namespace UnityAtoms.Mobile
{
[FormerlySerializedAs("FirstTapTimer")]
[SerializeField]
private Timer _firstTapTimer;
private Timer _firstTapTimer = null;
[FormerlySerializedAs("SecondTapTimer")]
[SerializeField]
private Timer _secondTapTimer;
private Timer _secondTapTimer = null;
[FormerlySerializedAs("MaxTimeBetweenTaps")]
[SerializeField]
private FloatReference _maxTimeBetweenTaps;
private FloatReference _maxTimeBetweenTaps = null;
[FormerlySerializedAs("MaxDistanceBetweenTaps")]
[SerializeField]
private FloatReference _maxDistanceBetweenTaps;
private FloatReference _maxDistanceBetweenTaps = null;
[FormerlySerializedAs("MaxMovementToCountAsTap")]
[SerializeField]
private FloatReference _maxMovementToCountAsTap;
private FloatReference _maxMovementToCountAsTap = null;
[FormerlySerializedAs("OnTapDetectedEvent")]
[SerializeField]
private TouchUserInputGameEvent _onTapDetectedEvent;
private TouchUserInputGameEvent _onTapDetectedEvent = null;
[FormerlySerializedAs("OnDoubleTapDetectedEvent")]
[SerializeField]
private TouchUserInputGameEvent _onDoubleTapDetectedEvent;
private TouchUserInputGameEvent _onDoubleTapDetectedEvent = null;
private Vector2 _inputPosFirstTapDown;

View File

@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace UnityAtoms.Mobile
{
@ -8,28 +9,29 @@ namespace UnityAtoms.Mobile
TouchUserInputGameEvent,
TouchUserInputTouchUserInputGameEvent>
{
[FormerlySerializedAs("DetectTap")]
[SerializeField]
private DetectTap DetectTap;
private DetectTap _detectTap = null;
private void OnEnable()
{
if (DetectTap.InUse())
if (_detectTap.InUse())
{
Changed.RegisterListener(DetectTap);
Changed.RegisterListener(_detectTap);
}
}
private void OnDisable()
{
if (DetectTap.InUse())
if (_detectTap.InUse())
{
Changed.UnregisterListener(DetectTap);
Changed.UnregisterListener(_detectTap);
}
}
public bool IsPotentialDoubleTapInProgress()
{
return DetectTap != null && DetectTap.InUse() && DetectTap.IsPotentialDoubleTapInProgress();
return _detectTap != null && _detectTap.InUse() && _detectTap.IsPotentialDoubleTapInProgress();
}
protected override bool AreEqual(TouchUserInput first, TouchUserInput second)

View File

@ -8,7 +8,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Timer")]
[SerializeField]
private Timer _timer;
private Timer _timer = null;
public override void Do()
{

View File

@ -8,7 +8,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Timer")]
[SerializeField]
private Timer _timer;
private Timer _timer = null;
public override void Do()
{

View File

@ -11,7 +11,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Timer")]
[SerializeField]
private Timer _timer;
private Timer _timer = null;
public override void Do()
{

View File

@ -12,7 +12,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Conditional")]
[SerializeField]
private ConditionalVector2GameActionHelper _conditional;
private ConditionalVector2GameActionHelper _conditional = null;
public override void Do(Vector2 t1)
{

View File

@ -12,7 +12,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Conditional")]
[SerializeField]
private ConditionalVector3GameActionHelper _conditional;
private ConditionalVector3GameActionHelper _conditional = null;
public override void Do(Vector3 t1)
{

View File

@ -12,7 +12,7 @@ namespace UnityAtoms
{
[FormerlySerializedAs("Conditional")]
[SerializeField]
private ConditionalVoidGameActionHelper _conditional;
private ConditionalVoidGameActionHelper _conditional = null;
public override void Do()
{

View File

@ -9,7 +9,7 @@ namespace UnityAtoms.Examples
{
[FormerlySerializedAs("TagPlayer")]
[SerializeField]
private StringConstant _tagPlayer;
private StringConstant _tagPlayer = null;
public override void Do(Collider2D collider)
{

View File

@ -43,8 +43,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e564c43d8cd6f404fbf20034291d3354, type: 3}
m_Name:
m_EditorClassIdentifier:
Event: {fileID: 11400000, guid: fb1508338b66f42099fceb52aa22cf4c, type: 2}
UnityEventResponse:
_event: {fileID: 11400000, guid: fb1508338b66f42099fceb52aa22cf4c, type: 2}
_unityEventResponse:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
@ -60,5 +60,5 @@ MonoBehaviour:
m_CallState: 2
m_TypeName: UnityAtoms.UnityIntEvent, UnityAtoms, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
GameActionResponses:
_gameActionResponses:
- {fileID: 11400000, guid: 58f78c691d84e44cd84c884aadacf21a, type: 2}

View File

@ -8,7 +8,7 @@ namespace UnityAtoms.Examples
{
[FormerlySerializedAs("MaxHealth")]
[SerializeField]
private IntConstant _maxHealth;
private IntConstant _maxHealth = null;
public void HealthChanged(int health)
{