提交 497243a7 编写于 作者: J Jakob Hunsballe

Coding style fixes

mostly whitespace inconsistencies
上级 e19cfb89
......@@ -15,21 +15,21 @@ public static void AreaPopup(string labelName, SerializedProperty areaProperty)
if (areaValue == areaProperty.intValue)
areaIndex = i;
}
ArrayUtility.Add (ref areaNames, "");
ArrayUtility.Add (ref areaNames, "Open Area Settings...");
ArrayUtility.Add(ref areaNames, "");
ArrayUtility.Add(ref areaNames, "Open Area Settings...");
var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
EditorGUI.BeginProperty(rect, GUIContent.none, areaProperty);
EditorGUI.BeginChangeCheck();
areaIndex = EditorGUI.Popup (rect, labelName, areaIndex, areaNames);
areaIndex = EditorGUI.Popup(rect, labelName, areaIndex, areaNames);
if (EditorGUI.EndChangeCheck())
{
if (areaIndex >= 0 && areaIndex < areaNames.Length - 2)
areaProperty.intValue = GameObjectUtility.GetNavMeshAreaFromName(areaNames[areaIndex]);
else if (areaIndex == areaNames.Length-1)
NavMeshEditorHelpers.OpenAreaSettings ();
else if (areaIndex == areaNames.Length - 1)
NavMeshEditorHelpers.OpenAreaSettings();
}
EditorGUI.EndProperty();
......@@ -42,34 +42,34 @@ public static void AgentTypePopup(string labelName, SerializedProperty agentType
var agentTypeNames = new string[count + 2];
for (var i = 0; i < count; i++)
{
var id = NavMesh.GetSettingsByIndex (i).agentTypeID;
var name = NavMesh.GetSettingsNameFromID (id);
var id = NavMesh.GetSettingsByIndex(i).agentTypeID;
var name = NavMesh.GetSettingsNameFromID(id);
agentTypeNames[i] = name;
if (id == agentTypeID.intValue)
index = i;
}
agentTypeNames[count] = "";
agentTypeNames[count+1] = "Open Agent Settings...";
agentTypeNames[count + 1] = "Open Agent Settings...";
bool validAgentType = index != -1;
if (!validAgentType)
{
EditorGUILayout.HelpBox ("Agent Type invalid.", MessageType.Warning);
EditorGUILayout.HelpBox("Agent Type invalid.", MessageType.Warning);
}
var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
EditorGUI.BeginProperty(rect, GUIContent.none, agentTypeID);
EditorGUI.BeginChangeCheck();
index = EditorGUI.Popup (rect, labelName, index, agentTypeNames);
index = EditorGUI.Popup(rect, labelName, index, agentTypeNames);
if (EditorGUI.EndChangeCheck())
{
if (index >= 0 && index < count)
{
var id = NavMesh.GetSettingsByIndex (index).agentTypeID;
var id = NavMesh.GetSettingsByIndex(index).agentTypeID;
agentTypeID.intValue = id;
}
else if (index == count+1)
else if (index == count + 1)
{
NavMeshEditorHelpers.OpenAgentSettings(-1);
}
......@@ -87,16 +87,16 @@ public static void AgentMaskPopup(string labelName, SerializedProperty agentMask
// Contents of the dropdown box.
string popupContent = "";
if(agentMask.hasMultipleDifferentValues)
if (agentMask.hasMultipleDifferentValues)
popupContent = "\u2014";
else
popupContent = GetAgentMaskLabelName(agentMask);
var content = new GUIContent (popupContent);
var popupRect = GUILayoutUtility.GetRect (content, EditorStyles.popup);
var content = new GUIContent(popupContent);
var popupRect = GUILayoutUtility.GetRect(content, EditorStyles.popup);
EditorGUI.BeginProperty(popupRect, GUIContent.none, agentMask);
popupRect = EditorGUI.PrefixLabel (popupRect, 0, new GUIContent (labelName));
popupRect = EditorGUI.PrefixLabel(popupRect, 0, new GUIContent(labelName));
bool pressed = GUI.Button(popupRect, content, EditorStyles.popup);
if (pressed)
......@@ -106,36 +106,36 @@ public static void AgentMaskPopup(string labelName, SerializedProperty agentMask
var showAll = show && IsAll(agentMask);
var menu = new GenericMenu();
menu.AddItem (new GUIContent ("None"), showNone, SetAgentMaskNone, agentMask);
menu.AddItem (new GUIContent ("All"), showAll, SetAgentMaskAll, agentMask);
menu.AddSeparator ("");
menu.AddItem(new GUIContent("None"), showNone, SetAgentMaskNone, agentMask);
menu.AddItem(new GUIContent("All"), showAll, SetAgentMaskAll, agentMask);
menu.AddSeparator("");
var count = NavMesh.GetSettingsCount ();
var count = NavMesh.GetSettingsCount();
for (var i = 0; i < count; i++)
{
var id = NavMesh.GetSettingsByIndex (i).agentTypeID;
var id = NavMesh.GetSettingsByIndex(i).agentTypeID;
var sname = NavMesh.GetSettingsNameFromID(id);
var showSelected = show && AgentMaskHasSelectedAgentTypeID(agentMask, id);
var showSelected = show && AgentMaskHasSelectedAgentTypeID(agentMask, id);
var userData = new object[] { agentMask, id, !showSelected };
menu.AddItem (new GUIContent (sname), showSelected, ToggleAgentMaskItem, userData);
menu.AddItem(new GUIContent(sname), showSelected, ToggleAgentMaskItem, userData);
}
menu.DropDown (popupRect);
menu.DropDown(popupRect);
}
EditorGUI.EndProperty();
}
public static GameObject CreateAndSelectGameObject (string suggestedName, GameObject parent)
public static GameObject CreateAndSelectGameObject(string suggestedName, GameObject parent)
{
var parentTransform = parent != null ? parent.transform : null;
var uniqueName = GameObjectUtility.GetUniqueNameForSibling (parentTransform, suggestedName);
var child = new GameObject (uniqueName);
var uniqueName = GameObjectUtility.GetUniqueNameForSibling(parentTransform, suggestedName);
var child = new GameObject(uniqueName);
Undo.RegisterCreatedObjectUndo (child, "Create " + uniqueName);
Undo.RegisterCreatedObjectUndo(child, "Create " + uniqueName);
if (parentTransform != null)
Undo.SetTransformParent (child.transform, parentTransform, "Parent " + uniqueName);
Undo.SetTransformParent(child.transform, parentTransform, "Parent " + uniqueName);
Selection.activeGameObject = child;
......@@ -256,4 +256,3 @@ static bool AgentMaskHasSelectedAgentTypeID(SerializedProperty agentMask, int ag
}
}
}
......@@ -46,7 +46,7 @@ struct AsyncBakeOperation
public AsyncOperation bakeOperation;
}
static List<AsyncBakeOperation> s_BakeOperations = new List<AsyncBakeOperation> ();
static List<AsyncBakeOperation> s_BakeOperations = new List<AsyncBakeOperation>();
static Styles s_Styles;
......@@ -313,7 +313,7 @@ public override void OnInspectorGUI()
// Show progress for the selected targets
for (int i = s_BakeOperations.Count - 1; i >= 0; --i)
{
if (!targets.Contains(s_BakeOperations [i].surface))
if (!targets.Contains(s_BakeOperations[i].surface))
continue;
var oper = s_BakeOperations[i].bakeOperation;
......@@ -331,7 +331,7 @@ public override void OnInspectorGUI()
if (GUILayout.Button("Cancel", EditorStyles.miniButton))
{
var bakeData = s_BakeOperations [i].bakeData;
var bakeData = s_BakeOperations[i].bakeData;
UnityEngine.AI.NavMeshBuilder.Cancel(bakeData);
s_BakeOperations.RemoveAt(i);
}
......@@ -349,7 +349,7 @@ static NavMeshData InitializeBakeData(NavMeshSurface surface)
var emptySources = new List<NavMeshBuildSource>();
var emptyBounds = new Bounds();
return UnityEngine.AI.NavMeshBuilder.BuildNavMeshData(surface.GetBuildSettings(), emptySources, emptyBounds
, surface.transform.position, surface.transform.rotation);
, surface.transform.position, surface.transform.rotation);
}
static void UpdateAsyncBuildOperations()
......
......@@ -22,34 +22,33 @@ public class NavMeshModifier : MonoBehaviour
// List of agent types the modifier is applied for.
// Special values: empty == None, m_AffectedAgents[0] =-1 == All.
[SerializeField]
List<int> m_AffectedAgents = new List<int> (new int[] { -1 }); // Default value is All
List<int> m_AffectedAgents = new List<int>(new int[] { -1 }); // Default value is All
static readonly List<NavMeshModifier> s_NavMeshModifiers = new List<NavMeshModifier> ();
static readonly List<NavMeshModifier> s_NavMeshModifiers = new List<NavMeshModifier>();
public static List<NavMeshModifier> activeModifiers
{
get { return s_NavMeshModifiers; }
}
void OnEnable ()
void OnEnable()
{
if (!s_NavMeshModifiers.Contains (this))
s_NavMeshModifiers.Add (this);
if (!s_NavMeshModifiers.Contains(this))
s_NavMeshModifiers.Add(this);
}
void OnDisable ()
void OnDisable()
{
s_NavMeshModifiers.Remove (this);
s_NavMeshModifiers.Remove(this);
}
public bool AffectsAgentType (int agentTypeID)
public bool AffectsAgentType(int agentTypeID)
{
if (m_AffectedAgents.Count == 0)
return false;
if (m_AffectedAgents[0] == -1)
return true;
return m_AffectedAgents.IndexOf (agentTypeID) != -1;
return m_AffectedAgents.IndexOf(agentTypeID) != -1;
}
}
}
......@@ -8,11 +8,11 @@ namespace UnityEngine.AI
public class NavMeshModifierVolume : MonoBehaviour
{
[SerializeField]
Vector3 m_Size = new Vector3 (4.0f, 3.0f, 4.0f);
Vector3 m_Size = new Vector3(4.0f, 3.0f, 4.0f);
public Vector3 size { get { return m_Size; } set { m_Size = value; } }
[SerializeField]
Vector3 m_Center = new Vector3 (0, 1.0f, 0);
Vector3 m_Center = new Vector3(0, 1.0f, 0);
public Vector3 center { get { return m_Center; } set { m_Center = value; } }
[SerializeField]
......@@ -22,33 +22,33 @@ public class NavMeshModifierVolume : MonoBehaviour
// List of agent types the modifier is applied for.
// Special values: empty == None, m_AffectedAgents[0] =-1 == All.
[SerializeField]
List<int> m_AffectedAgents = new List<int> (new int[] { -1 }); // Default value is All
List<int> m_AffectedAgents = new List<int>(new int[] { -1 }); // Default value is All
static readonly List<NavMeshModifierVolume> s_NavMeshModifiers = new List<NavMeshModifierVolume> ();
static readonly List<NavMeshModifierVolume> s_NavMeshModifiers = new List<NavMeshModifierVolume>();
public static List<NavMeshModifierVolume> activeModifiers
{
get { return s_NavMeshModifiers; }
}
void OnEnable ()
void OnEnable()
{
if (!s_NavMeshModifiers.Contains (this))
s_NavMeshModifiers.Add (this);
if (!s_NavMeshModifiers.Contains(this))
s_NavMeshModifiers.Add(this);
}
void OnDisable ()
void OnDisable()
{
s_NavMeshModifiers.Remove (this);
s_NavMeshModifiers.Remove(this);
}
public bool AffectsAgentType (int agentTypeID)
public bool AffectsAgentType(int agentTypeID)
{
if (m_AffectedAgents.Count == 0)
return false;
if (m_AffectedAgents[0] == -1)
return true;
return m_AffectedAgents.IndexOf (agentTypeID) != -1;
return m_AffectedAgents.IndexOf(agentTypeID) != -1;
}
}
}
......@@ -149,7 +149,7 @@ public void Bake()
}
var data = NavMeshBuilder.BuildNavMeshData(GetBuildSettings(),
sources, sourcesBounds, transform.position, transform.rotation);
sources, sourcesBounds, transform.position, transform.rotation);
if (data != null)
{
......@@ -313,18 +313,18 @@ Bounds CalculateWorldBounds(List<NavMeshBuildSource> sources)
switch (src.shape)
{
case NavMeshBuildSourceShape.Mesh:
{
var m = src.sourceObject as Mesh;
result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, m.bounds));
break;
}
{
var m = src.sourceObject as Mesh;
result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, m.bounds));
break;
}
case NavMeshBuildSourceShape.Terrain:
{
// Terrain pivot is lower/left corner - shift bounds accordingly
var t = src.sourceObject as TerrainData;
result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, new Bounds(0.5f * t.size, t.size)));
break;
}
{
// Terrain pivot is lower/left corner - shift bounds accordingly
var t = src.sourceObject as TerrainData;
result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, new Bounds(0.5f * t.size, t.size)));
break;
}
case NavMeshBuildSourceShape.Box:
case NavMeshBuildSourceShape.Sphere:
case NavMeshBuildSourceShape.Capsule:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册