Topic: Multiple 3D Marker Lat/Long Set
Hello,
I am attempting to set the lat and long for each marker created though the code based on the variables saved. Currently it seems to work for the most part except I can only grab the first lat/long and not the 2nd, so when it creates the markers, it only grabs the first long/lat values and not the second pair (out of 2) from the float lists upon creating the new Vector2 values (what i see is the list count is returning 1 less than the actual list count when i go for (int i; i = 0, etc.))
The system is grabbing values from a user on a database based on user requests received, then saves the values to floats which then creates new Vector2 values in a list, in turn those Vector2 values are used to set the lat/long of the markers new Vector2 lat/long on marker creation.
I've tried various ways to get it all to work properly but haven't come to a good conclusion, i tried in the update function, separate functions or IEnumerators with small gaps in between list addition/variable grabs.
Any thoughts on how to get this to work would be great, thanks! (if not, perhaps a way of setting each markers long/lat after creation?)
Here's the code:
[FoldoutGroup("Bools")]
public bool markerPosLock;
[FoldoutGroup("Bools")]
public bool markerLock;
[FoldoutGroup("Floats")]
public List<float> latFloats;
[FoldoutGroup("Floats")]
public List<float> longFloats;
[FoldoutGroup("Vector2")]
public List<Vector2> markerPosition;
[FoldoutGroup("Marker")]
public List<OnlineMapsMarker3D> locationMarker;
[FoldoutGroup("Marker")]
public GameObject markerPrefab;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Load user friend requests sent
///
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void UserFriendRequestsSentLoad() {
if(!friendRequestsSentLoaded) {
//contactError.text = "Loading...";
CombuManager.localUser.LoadFriends(eContactType.PendingRequest, (bool success) => {
if (success) {
Debug.Log(success);
if (CombuManager.localUser.pendingRequests.Length == 0) {
friendRequestsSentLoaded = true;
UserFriends();
Debug.Log("No Sent Friend Requests");
} else {
OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;
locationMarker = new List<OnlineMapsMarker3D>();
for (int i = 0; i < CombuManager.localUser.pendingRequests.Length; ++i) {
User userReSe = (User)CombuManager.localUser.pendingRequests[i];
latFloats.Add(float.Parse(userReSe.customData["latitude"].ToString()));
longFloats.Add(float.Parse(userReSe.customData["longitude"].ToString()));
Debug.Log("Friend Requests Sent = " + CombuManager.localUser.pendingRequests[i].userName);
}
Debug.Log("Friend Requests Sent = " + CombuManager.localUser.pendingRequests.Length);
for (int f = 0; f < longFloats.Count; ++f) {
for (int f2 = 0; f2 < latFloats.Count; ++f2) {
if(!markerPosLock){
foreach (var PendingRequests in CombuManager.localUser.pendingRequests){
markerPosition.Add(new Vector2(longFloats[f], latFloats[f2]));
}
markerPosLock = true;
}
}
}
for (int m = 0; m < markerPosition.Count; ++m) {
if(!markerLock){
foreach (var PendingRequests in CombuManager.localUser.pendingRequests){
locationMarker.Add(control.AddMarker3D(markerPosition[m].x, markerPosition[m].y, markerPrefab));
}
markerLock = true;
}
}
friendRequestsSentLoaded = true;
UserFriends();
}
} else {
Debug.Log("Failed to load sent friend requests");
}
});
//end friendRequestsGalLoaded
} else {
Debug.Log("Friend Requests Already Loaded");
}
}