Skip to content

Commit

Permalink
#479 Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Falko <10247603+falko17@users.noreply.github.com>
  • Loading branch information
Yvo02 and falko17 authored Oct 26, 2022
1 parent dafcd09 commit 9a0cc01
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Assets/SEE/Game/GameNodeMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public static class GameNodeMarker
/// <param name="position">the position in world space for the center point of the new marker </param>
/// <param name="worldSpaceScale">the scale in world space of the new marker</param>
/// <returns>new marker game object or null if none could be created or a marker already exists</returns>
/// <exception cref="Exception"></exception>
/// <exception cref="ArgumentNullException">If <paramref name="parent"/> is <c>null</c>.</exception>
public static GameObject addSphere(GameObject parent, Vector3 position, Vector3 worldSpaceScale)
{
GameObject sphere;

if(parent == null)
{
throw new Exception("GameObject must not be null.");
throw new ArgumentNullException(nameof(parent));
}
else if (deleteExistingSphere(parent))
{
Expand All @@ -48,21 +48,20 @@ public static GameObject addSphere(GameObject parent, Vector3 position, Vector3
}

/// <summary>
/// This function searches all children of <param name="parent"></param> for existing childs with the name
/// This function searches all children of <paramref name="parent"/> for existing children with the name
/// "Sphere". If a sphere marker is already present it will be destroyed.
/// </summary>
/// <param name="parent">the game object to be checked for existing sphere marker</param>
/// <returns>true if marker exists</returns>
private static bool deleteExistingSphere(GameObject parent)
{
for (int i = 0; i <= parent.transform.childCount - 1; i++)
foreach (Transform child in parent.transform)
{
if (parent.transform.GetChild(i).transform.name == "Sphere" && parent.transform.childCount > 0)
if (child.name == "Sphere")
{
GameObject sphere = parent.transform.GetChild(i).gameObject;
//FIXME: network operation for deleting an existing marker not working properly
//new DeleteNetAction(sphere.name).Execute();
Destroyer.DestroyGameObject(parent.transform.GetChild(i).gameObject);
Destroyer.DestroyGameObject(child.gameObject);
return true;
}
}
Expand Down

0 comments on commit 9a0cc01

Please sign in to comment.