style: naming conventions

This commit is contained in:
Paul Pacheco 2019-04-06 07:50:58 -05:00
parent aa75387d60
commit cadb0cc51c

View File

@ -60,11 +60,11 @@ public Styles()
}
}
List<NetworkIdentityInfo> m_Info;
List<NetworkIdentityInfo> info;
List<NetworkBehaviourInfo> m_Behaviours;
NetworkIdentity m_Identity;
GUIContent m_Title;
Styles m_Styles = new Styles();
NetworkIdentity identity;
GUIContent title;
Styles styles = new Styles();
public override void Initialize(UnityObject[] targets)
{
@ -74,16 +74,16 @@ public override void Initialize(UnityObject[] targets)
public override GUIContent GetPreviewTitle()
{
if (m_Title == null)
if (title == null)
{
m_Title = new GUIContent("Network Information");
title = new GUIContent("Network Information");
}
return m_Title;
return title;
}
public override bool HasPreviewGUI()
{
return m_Info != null && m_Info.Count > 0;
return info != null && info.Count > 0;
}
public override void OnPreviewGUI(Rect r, GUIStyle background)
@ -91,11 +91,11 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
if (Event.current.type != EventType.Repaint)
return;
if (m_Info == null || m_Info.Count == 0)
if (info == null || info.Count == 0)
return;
if (m_Styles == null)
m_Styles = new Styles();
if (styles == null)
styles = new Styles();
// Get required label size for the names of the information values we're going to show
// There are two columns, one with label for the name of the info and the next for the value
@ -113,10 +113,10 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
Rect labelRect = new Rect(initialX, initialY, maxNameLabelSize.x, maxNameLabelSize.y);
Rect idLabelRect = new Rect(maxNameLabelSize.x, initialY, maxValueLabelSize.x, maxValueLabelSize.y);
foreach (NetworkIdentityInfo info in m_Info)
foreach (NetworkIdentityInfo info in info)
{
GUI.Label(labelRect, info.name, m_Styles.labelStyle);
GUI.Label(idLabelRect, info.value, m_Styles.componentName);
GUI.Label(labelRect, info.name, styles.labelStyle);
GUI.Label(idLabelRect, info.value, styles.componentName);
labelRect.y += labelRect.height;
labelRect.x = initialX;
idLabelRect.y += idLabelRect.height;
@ -129,7 +129,7 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
Vector2 maxBehaviourLabelSize = GetMaxBehaviourLabelSize();
Rect behaviourRect = new Rect(initialX, labelRect.y + 10, maxBehaviourLabelSize.x, maxBehaviourLabelSize.y);
GUI.Label(behaviourRect, new GUIContent("Network Behaviours"), m_Styles.labelStyle);
GUI.Label(behaviourRect, new GUIContent("Network Behaviours"), styles.labelStyle);
behaviourRect.x += 20; // indent names
behaviourRect.y += behaviourRect.height;
@ -141,31 +141,31 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
continue;
}
GUI.Label(behaviourRect, info.name, info.behaviour.enabled ? m_Styles.componentName : m_Styles.disabledName);
GUI.Label(behaviourRect, info.name, info.behaviour.enabled ? styles.componentName : styles.disabledName);
behaviourRect.y += behaviourRect.height;
lastY = behaviourRect.y;
}
if (m_Identity.observers != null && m_Identity.observers.Count > 0)
if (identity.observers != null && identity.observers.Count > 0)
{
Rect observerRect = new Rect(initialX, lastY + 10, 200, 20);
GUI.Label(observerRect, new GUIContent("Network observers"), m_Styles.labelStyle);
GUI.Label(observerRect, new GUIContent("Network observers"), styles.labelStyle);
observerRect.x += 20; // indent names
observerRect.y += observerRect.height;
foreach (KeyValuePair<int, NetworkConnection> kvp in m_Identity.observers)
foreach (KeyValuePair<int, NetworkConnection> kvp in identity.observers)
{
GUI.Label(observerRect, kvp.Value.address + ":" + kvp.Value.connectionId, m_Styles.componentName);
GUI.Label(observerRect, kvp.Value.address + ":" + kvp.Value.connectionId, styles.componentName);
observerRect.y += observerRect.height;
lastY = observerRect.y;
}
}
if (m_Identity.clientAuthorityOwner != null)
if (identity.clientAuthorityOwner != null)
{
Rect ownerRect = new Rect(initialX, lastY + 10, 400, 20);
GUI.Label(ownerRect, new GUIContent("Client Authority: " + m_Identity.clientAuthorityOwner), m_Styles.labelStyle);
GUI.Label(ownerRect, new GUIContent("Client Authority: " + identity.clientAuthorityOwner), styles.labelStyle);
}
}
}
@ -174,9 +174,9 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
Vector2 GetMaxNameLabelSize()
{
Vector2 maxLabelSize = Vector2.zero;
foreach (NetworkIdentityInfo info in m_Info)
foreach (NetworkIdentityInfo info in info)
{
Vector2 labelSize = m_Styles.labelStyle.CalcSize(info.value);
Vector2 labelSize = styles.labelStyle.CalcSize(info.value);
if (maxLabelSize.x < labelSize.x)
{
maxLabelSize.x = labelSize.x;
@ -194,7 +194,7 @@ Vector2 GetMaxBehaviourLabelSize()
Vector2 maxLabelSize = Vector2.zero;
foreach (NetworkBehaviourInfo behaviour in m_Behaviours)
{
Vector2 labelSize = m_Styles.labelStyle.CalcSize(behaviour.name);
Vector2 labelSize = styles.labelStyle.CalcSize(behaviour.name);
if (maxLabelSize.x < labelSize.x)
{
maxLabelSize.x = labelSize.x;
@ -209,13 +209,13 @@ Vector2 GetMaxBehaviourLabelSize()
void GetNetworkInformation(GameObject gameObject)
{
m_Identity = gameObject.GetComponent<NetworkIdentity>();
if (m_Identity != null)
identity = gameObject.GetComponent<NetworkIdentity>();
if (identity != null)
{
m_Info = new List<NetworkIdentityInfo>
info = new List<NetworkIdentityInfo>
{
GetAssetId(),
GetString("Scene ID", m_Identity.sceneId.ToString("X"))
GetString("Scene ID", identity.sceneId.ToString("X"))
};
if (!Application.isPlaying)
@ -223,12 +223,12 @@ void GetNetworkInformation(GameObject gameObject)
return;
}
m_Info.Add(GetString("Network ID", m_Identity.netId.ToString()));
info.Add(GetString("Network ID", identity.netId.ToString()));
m_Info.Add(GetBoolean("Is Client", m_Identity.isClient));
m_Info.Add(GetBoolean("Is Server", m_Identity.isServer));
m_Info.Add(GetBoolean("Has Authority", m_Identity.hasAuthority));
m_Info.Add(GetBoolean("Is Local Player", m_Identity.isLocalPlayer));
info.Add(GetBoolean("Is Client", identity.isClient));
info.Add(GetBoolean("Is Server", identity.isServer));
info.Add(GetBoolean("Has Authority", identity.hasAuthority));
info.Add(GetBoolean("Is Local Player", identity.isLocalPlayer));
NetworkBehaviour[] behaviours = gameObject.GetComponents<NetworkBehaviour>();
if (behaviours.Length > 0)
@ -249,7 +249,7 @@ void GetNetworkInformation(GameObject gameObject)
NetworkIdentityInfo GetAssetId()
{
string assetId = m_Identity.assetId.ToString();
string assetId = identity.assetId.ToString();
if (string.IsNullOrEmpty(assetId))
{
assetId = "<object has no prefab>";