aliessmael / Unity-Contacts-List

Unity Contacts List is a unity3d plugin for Android and iOS devices that enable you to access to contacts. Retreive names, phone numbers, and even photos.
42 stars 20 forks source link

When Print Log in Mobile Console It print only 8 contacts from start and then repeat same process. #26

Open Nameless77 opened 4 years ago

Nameless77 commented 4 years ago

it works perfectly but i phase a issue and that is when i debug.log a text string which is contain all the contact details it prints only 8(from 0-7 index in array) contacts and then it repeat the same thing so what is the problem can you please tell me that what is the problem.if you can then please can you help me. and i am using mobile console(free on asset store) for android to see console massages.

here is the main portion of loop in ContactListGUI.cs

for (int i = startIndex; i < endIndex; i++) { if (i % 2 == 0) GUILayout.BeginHorizontal(evenContactStyle, GUILayout.Width(size.x), GUILayout.Height(size.y)); else GUILayout.BeginHorizontal(oddContactStyle, GUILayout.Width(size.x), GUILayout.Height(size.y)); GUILayout.Label(i.ToString(), style); Contact c = Contacts.ContactsList[i];

        if (c.PhotoTexture != null)
        {
            GUILayout.Box(new GUIContent(c.PhotoTexture), GUILayout.Width(size.y), GUILayout.Height(size.y));
        }
        else
        {
            GUILayout.Box(new GUIContent(contactFaceStyle.normal.background), GUILayout.Width(size.y), GUILayout.Height(size.y));
        }

        string text = "\n";
        text += "Name : " + c.Name + "\n";
        for (int p = 0; p < c.Phones.Count; p++)
        {
            text += "Number : " + c.Phones[p].Number + "\n" + " , Type " + c.Phones[p].Type + " \n";
        }
        for (int e = 0; e < c.Emails.Count; e++)
            text += "Email  : " + c.Emails[e].Address + "\n" + " : Type " + c.Emails[e].Type + "\n";
        for (int e = 0; e < c.Connections.Count; e++)
            text += "Connection : " + c.Connections[e] + "\n";
        text += "------------------";
        print(text);
        GUILayout.Label(text, style, GUILayout.Width(size.x - size.y - 40));
        GUILayout.Space(50);
        GUILayout.EndHorizontal();
    }
    int afterHeight = (int)((Contacts.ContactsList.Count - (startIndex + 6)) * size.y);
    if (afterHeight > 0)
    {
        //fill invisible gap after scroller to make proper scroller pos
        GUILayout.BeginHorizontal(GUILayout.Width(size.x * 2), GUILayout.Height(afterHeight));
        GUILayout.Box(" ", nonStyle2);
        GUILayout.EndHorizontal();
    }
    else
    {
        GUILayout.BeginHorizontal(GUILayout.Width(size.x * 2), GUILayout.Height(1f));
        GUILayout.Box(" ", nonStyle2);
        GUILayout.EndHorizontal();
    }
    GUILayout.EndScrollView();
}

basically after "text += "------------------";" this i simply print that text value which is a string.but it print 8 contacts with its detail and then again the loop starts from first contact.and this is happened only with debugging the message.it create GUI perfectly and print all my 286 contacts with details but when it comes to debugging in console it prints only 8 contact. so can you please help me.

aliessmael commented 4 years ago

there is 2 thing you have to realize

Nameless77 commented 4 years ago

so can you please suggest me some solution about it i mean where can i load it? bcz i tried everything but nothing works. so if you can then please help me.

aliessmael commented 4 years ago

ContactListGUI.cs is used to draw contacts only , you dont need it at all

you can make this script and put it in any game object your scene

`public class PrintContact : MonoBehaviour { void Start() { StartCorotine( print() ); } IEnumerator print() { yield return new WaitForSeconds( 5f ); for (int i = 0; i < Contacts.ContactsList.Count; i++) { var contact = Contacts.ContactsList[i]; //Log whatever here }

  }

}`

Note : i did not compile the code you may have compile error just fix it also you may need more time to wait till all contacts loaded