Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Ios script help.

Discussion in 'Scripting' started by Nabil_fx, Oct 15, 2015.

  1. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    i have this script, ifor login a registration. In unity works fiine, but publish on Iphone does not work, what could be wrong!

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class LoginSystem : MonoBehaviour {
    6.  
    7.     public enum lMode{login,register};
    8.     public lMode LoginMode;
    9.  
    10.     public GUISkin skin;
    11.     //login
    12.     private string user = "";
    13.     private string pass = "";
    14.     private int    boolstatus;
    15.     //register
    16.     private string name = "";
    17.     private string password = "";
    18.     private string email = "";
    19.  
    20.     private string Log;
    21.     public Texture LogTexture;
    22.  
    23.     public string sceneMap;
    24.     [System.Serializable]
    25.     public class LoginParameters{
    26.         public Text LoginString;
    27.         public Text PassString;
    28.         public Toggle Remember;
    29.     }
    30.     [System.Serializable]
    31.     public class RegisterParameters{
    32.         public Text UserString;
    33.         public Text PassString;
    34.         public Text EmailString;
    35.     }
    36.  
    37.     public LoginParameters LP;
    38.     public RegisterParameters RP;
    39.  
    40.     public static int score;
    41.     public static string userName;
    42.  
    43.     private string[] ListStrings;
    44.  
    45.     public GameObject LoginM;  
    46.     public GameObject RegisM;
    47.  
    48.     public Text logText;
    49.  
    50.     void Start () {
    51.         boolstatus = PlayerPrefs.GetInt("bs");
    52.         if (boolstatus == 1) {
    53.             LP.Remember.isOn = true;
    54.         }else{
    55.             LP.Remember.isOn = false;
    56.         }
    57.         if (LP.Remember.isOn == true) user = PlayerPrefs.GetString ("login");
    58.     }
    59.  
    60.     void Update () {
    61.         logText.text = Log;
    62.         if (LoginMode == lMode.login) {
    63.             LoginM.SetActive(true);
    64.             RegisM.SetActive(false);
    65.         }else if(LoginMode == lMode.register){
    66.             LoginM.SetActive(false);
    67.             RegisM.SetActive(true);
    68.         }
    69.         if (LP.Remember.isOn == true) {
    70.             PlayerPrefs.SetString("login",user);
    71.             boolstatus = 1;
    72.             PlayerPrefs.SetInt("bs",boolstatus);
    73.         }else{
    74.             boolstatus = 0;
    75.             PlayerPrefs.SetInt("bs",boolstatus);
    76.         }
    77.    
    78.     }
    79.     void OnGUI(){
    80.         GUI.skin = skin;
    81.     }
    82.     void RequestRegister(){
    83.         name  = RP.UserString.text;
    84.         email = RP.EmailString.text;
    85.         password = RP.PassString.text;
    86.         if (name.Length < 1) {
    87.             Log = "Preencha o campo do Usuário.";
    88.         }else{
    89.             if(email.Length < 1){
    90.                 Log = "Preencha o campo do E-Mail.";
    91.             }else{
    92.                 if(password.Length < 1){
    93.                     Log = "Preencha o campo da Senha.";
    94.                 }else{
    95.                     WWWForm register = new WWWForm();
    96.                     register.AddField("user",name);
    97.                     register.AddField("pass",password);
    98.                     register.AddField("email",email);
    99.                     WWW w = new WWW("http://nfx.comuv.com/register.php",register);
    100.                     StartCoroutine(RequestRegisterInformations(w));
    101.                 }
    102.             }
    103.         }
    104.     }
    105.     void RequestLogin(){
    106.         user = LP.LoginString.text;
    107.         pass = LP.PassString.text;
    108.         Log = "";
    109.         if (user.Length < 1) {
    110.             Log = "Preencha o campo do usuario";
    111.         }else{
    112.             if(pass.Length < 1){
    113.                 Log = "Preencha o campo da senha";
    114.             }else{
    115.                 WWWForm login = new WWWForm();
    116.                 login.AddField("user",user);
    117.                 login.AddField("pass",pass);
    118.                 WWW w = new WWW("http://nfx.comuv.com/Login.php",login);
    119.                 StartCoroutine(RequestLoginInformations(w));
    120.             }
    121.         }
    122.     }
    123.     IEnumerator RequestLoginInformations(WWW w){
    124.         yield return w;
    125.         if (w.error == null) {
    126.             Log = w.text;
    127.             ListStrings = w.text.Split(';');
    128.             if(ListStrings[0] == "Bem vindo"){
    129.                 Log = "Seja " + ListStrings[0] + " " + ListStrings[1] +" ";
    130.                 userName = ListStrings[1];
    131.             }
    132.             if(ListStrings[0] == "Bem vindo"){
    133.                 Application.LoadLevel(sceneMap);
    134.             }
    135.         }
    136.     }
    137.     IEnumerator RequestRegisterInformations(WWW w){
    138.         yield return w;
    139.         if (w.error == null) {
    140.             Log = w.text;
    141.             if(Log == "Conta criada com sucesso!"){
    142.                 LP.LoginString.text = RP.UserString.text;
    143.                 LP.PassString.text = RP.PassString.text;
    144.                 RP.UserString.text = "";
    145.                 RP.EmailString.text = "";
    146.                 RP.PassString.text = "";
    147.                 LoginMode = lMode.login;
    148.             }
    149.         }
    150.     }
    151.     void RegisterMode(){
    152.         LoginMode = lMode.register;
    153.     }
    154.     void LoginMod(){
    155.         LoginMode = lMode.login;
    156.     }
    157. }
    158.  
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Does it print out any error in the XCode console log?

    You might want to put in more Debug.Log() calls at each stage to narrow down where it is failing.
     
  3. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    Please, im not a programer, im using playmaker, can you fix this problem for me.

    here is the the Xcode console log

    2015-10-15 21:59:13.715 RankingSystem[5482:2167277] -> registered mono modules 0x100e55b00

    -> applicationDidFinishLaunching()

    objc[5482]: pthread_rwlock_rdlock failed (11)

    -> applicationDidBecomeActive()

    Requesting Resolution: 1080x1920

    Init: screen size 1080x1920

    Initializing Metal device caps

    Initialize engine version: 5.2.0f3 (e7947df39b5c)

    Setting up 1 worker threads for Enlighten.

    Thread -> id: 16e8a7000 -> priority: 1
     
  4. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Sorry to say but using scripts from someone else and don't know what it means. Pretty hard to fix errors. I think you should take some time to learn how to program. It might help you make things in a more creative way.
    This is the whole C# language,
     
  5. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
  6. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    i pay a freelancer to create this login and registration for me, but now after finish the job, he never answers the questions that i do to him about fix this problem of programming, That why i came here to ask for help.
     
  7. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Still, if you learn to code many you don't have to pay the freelancer that doesn't make correct code. Also, do you have any errors in Unity? Fix every error you have. That fixes it 90% of the time
     
    Last edited: Oct 16, 2015
  8. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    im going to learn but for now, i need to fix this script.
     
  9. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Also, do you have any errors in Unity? Fix every error you have. That fixes it 90% of the time
     
  10. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    here the xcode console message.
    This script work on Unity and android, bui on IOs just the press button work, but does not make the function.

    2015-10-16 10:10:35.340 RankingSystem[5640:2228623] -> registered mono modules 0x100ea5b00

    -> applicationDidFinishLaunching()

    -> applicationDidBecomeActive()

    Requesting Resolution: 1080x1920

    Init: screen size 1080x1920

    Initializing Metal device caps

    Initialize engine version: 5.2.0f3 (e7947df39b5c)

    Setting up 1 worker threads for Enlighten.

    Thread -> id: 16e8a7000 -> priority: 1
     
  11. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    I mean, Go to Unity,
    look at the bottom and press play game
    dose any thing show up in the log
    Yellow?
    Red?
    or other
    none
     
  12. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    no messages in unity
     
  13. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Do you have different scenes?
     
  14. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    3 scene, Login, Game, Ranking
     
  15. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    There is a guy how say that to me.
    You might want to put in more Debug.Log() calls at each stage to narrow down where it is failing.
     
  16. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Ok,
    Do the same for each scene
    check if theirs unused scripts in your inspector

    And, its almost impossible to fix in Xcode

    And yes, he's very correct

    Code (csharp):
    1.  
    2. //basically you enter on specific areas
    3.  
    4. void Start () {
    5.        boolstatus = PlayerPrefs.GetInt("bs");
    6.     if (boolstatus == 1) {
    7.  
    8.  
    9.                                               //Enter on this between the if statements
    10.                                                 Debug.Log("BoolStatus = 1");
    11.  
    12.  
    13.  
    14.           LP.Remember.isOn = true;
    15.       }else{
    16.             LP.Remember.isOn = false;
    17.      }
    18.       if (LP.Remember.isOn == true) user = PlayerPrefs.GetString ("login");   }
    19.  
    20.  
    21.  
    22.  
    23.  
    24.  
    25.  
    26.  
     
    Last edited: Oct 16, 2015
  17. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    i put between in all unused script, here the result. But still not work on iphone

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class LoginSystem : MonoBehaviour {
    6.  
    7.     public enum lMode{login,register};
    8.     public lMode LoginMode;
    9.  
    10.     public GUISkin skin;
    11.     //login
    12.     private string user = "";
    13.     private string pass = "";
    14.     private int    boolstatus;
    15.     //register
    16.     private string name = "";
    17.     private string password = "";
    18.     private string email = "";
    19.  
    20.     private string Log;
    21.     public Texture LogTexture;
    22.  
    23.     public string sceneMap;
    24.     [System.Serializable]
    25.     public class LoginParameters{
    26.         public Text LoginString;
    27.         public Text PassString;
    28.         public Toggle Remember;
    29.     }
    30.     [System.Serializable]
    31.     public class RegisterParameters{
    32.         public Text UserString;
    33.         public Text PassString;
    34.         public Text EmailString;
    35.     }
    36.  
    37.     public LoginParameters LP;
    38.     public RegisterParameters RP;
    39.  
    40.     public static int score;
    41.     public static string userName;
    42.  
    43.     private string[] ListStrings;
    44.  
    45.     public GameObject LoginM;  
    46.     public GameObject RegisM;
    47.  
    48.     public Text logText;
    49.  
    50.     void Start () {
    51.         boolstatus = PlayerPrefs.GetInt("bs");
    52.         if (boolstatus == 1) {
    53.             Debug.Log("BoolStatus = 1");
    54.             LP.Remember.isOn = true;
    55.         }else{
    56.             LP.Remember.isOn = false;
    57.         }
    58.         if (LP.Remember.isOn == true) user = PlayerPrefs.GetString ("login");
    59.         Debug.Log ("LP.Remember.isOn == true");
    60.     }
    61.  
    62.     void Update () {
    63.         logText.text = Log;
    64.         if (LoginMode == lMode.login) {
    65.             Debug.Log("LoginMode == lMode.login");
    66.             LoginM.SetActive(true);
    67.             RegisM.SetActive(false);
    68.         }else if(LoginMode == lMode.register){
    69.             LoginM.SetActive(false);
    70.             RegisM.SetActive(true);
    71.         }
    72.         if (LP.Remember.isOn == true) {
    73.             Debug.Log("LP.Remember.isOn == true");
    74.             PlayerPrefs.SetString("login",user);
    75.             boolstatus = 1;
    76.             PlayerPrefs.SetInt("bs",boolstatus);
    77.         }else{
    78.             boolstatus = 0;
    79.             PlayerPrefs.SetInt("bs",boolstatus);
    80.         }
    81.    
    82.     }
    83.     void OnGUI(){
    84.         GUI.skin = skin;
    85.     }
    86.     void RequestRegister(){
    87.         name  = RP.UserString.text;
    88.         email = RP.EmailString.text;
    89.         password = RP.PassString.text;
    90.         if (name.Length < 1) {
    91.             Debug.Log("name.Length < 1");
    92.             Log = "Preencha o campo do Usuário.";
    93.         }else{
    94.             if(email.Length < 1){
    95.                 Debug.Log("email.Length < 1");
    96.                 Log = "Preencha o campo do E-Mail.";
    97.             }else{
    98.                 if(password.Length < 1){
    99.                     Debug.Log("password.Length < 1");
    100.                     Log = "Preencha o campo da Senha.";
    101.                 }else{
    102.                     WWWForm register = new WWWForm();
    103.                     register.AddField("user",name);
    104.                     register.AddField("pass",password);
    105.                     register.AddField("email",email);
    106.                     WWW w = new WWW("http://nfx.comuv.com/register.php",register);
    107.                     StartCoroutine(RequestRegisterInformations(w));
    108.                 }
    109.             }
    110.         }
    111.     }
    112.     void RequestLogin(){
    113.         user = LP.LoginString.text;
    114.         pass = LP.PassString.text;
    115.         Log = "";
    116.         if (user.Length < 1) {
    117.             Debug.Log("user.Length < 1");
    118.             Log = "Preencha o campo do usuario";
    119.         }else{
    120.             if(pass.Length < 1){
    121.                 Debug.Log("pass.Length < 1");
    122.                 Log = "Preencha o campo da senha";
    123.             }else{
    124.                 WWWForm login = new WWWForm();
    125.                 login.AddField("user",user);
    126.                 login.AddField("pass",pass);
    127.                 WWW w = new WWW("http://nfx.comuv.com/Login.php",login);
    128.                 StartCoroutine(RequestLoginInformations(w));
    129.             }
    130.         }
    131.     }
    132.      IEnumerator RequestLoginInformations(WWW w){
    133.         yield return w;
    134.         if (w.error == null) {
    135.             Debug.Log("w.error == null");
    136.             Log = w.text;
    137.             ListStrings = w.text.Split(';');
    138.             if(ListStrings[0] == "Bem vindo"){
    139.                 Debug.Log("ListStrings[0] == Bem vindo");
    140.                 Log = "Seja " + ListStrings[0] + " " + ListStrings[1] +" ";
    141.                 userName = ListStrings[1];
    142.             }
    143.             if(ListStrings[0] == "Bem vindo"){
    144.                 Debug.Log("Bem vindo");
    145.                 Application.LoadLevel(sceneMap);
    146.             }
    147.         }
    148.     }
    149.      IEnumerator RequestRegisterInformations(WWW w){
    150.         yield return w;
    151.         if (w.error == null) {
    152.             Debug.Log("w.error == null");
    153.             Log = w.text;
    154.             if(Log == "Conta criada com sucesso!"){
    155.                 Debug.Log("Log == Conta criada com sucesso");
    156.                 LP.LoginString.text = RP.UserString.text;
    157.                 LP.PassString.text = RP.PassString.text;
    158.                 RP.UserString.text = "";
    159.                 RP.EmailString.text = "";
    160.                 RP.PassString.text = "";
    161.                 LoginMode = lMode.login;
    162.             }
    163.         }
    164.     }
    165.     void RegisterMode(){
    166.         LoginMode = lMode.register;
    167.     }
    168.     void LoginMod(){
    169.         LoginMode = lMode.login;
    170.     }
    171. }
    172.  
     
  18. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Debug dose nothing to the script but tell you what has run in the script. In Unity, play the game and see do all the things you do in the script , make the account , login, register, do everything. Then on the bottom see if everything has been used. I wouldn't be focusing on Xcode right now and trying to figure out how things are working.
     
  19. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    everything is working, i already teste, in android, and in unity editor, just for iphone does o work. Im getting crazy. In the Iphone i press the button and does not login, still in the same screen. Very strange
     
  20. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Thats the problem!!!
     
  21. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
  22. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Code (csharp):
    1.  
    2. public void LoginTapped(){
    3. Application.LoadLevel("");    //your login level
    4. }
    5.  
    then drag the button to the LoginTapped script in Unity
     
  23. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    {} are open and close brackets
    void is a class that can be make so like this
    Logintapped = lead this level.
    in another void you can do
    Logintapped();
    it runs the whole load level script in just one line.
    I can't help much more because I don't code in his way with the person you hired did. Sorry , Gl
     
  24. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    i add this to the script or create a new c# script with this inside?
    Code (CSharp):
    1.  
    2. public void LoginTapped(){
    3. Application.LoadLevel("");    //your login level
    4. }
    5.  
     
  25. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    Use it as a new void enter it here, or separate ether one
    Code (csharp):
    1.  
    2. [LIST=1]
    3. [*] void RegisterMode(){
    4. [*]        LoginMode = lMode.register;
    5. [*]   }
    6. [*]   void LoginMod(){
    7. [*]        LoginMode = lMode.login;
    8. [*]  }
    9. public void LoginTapped()
    10. Application.LoadLevel("");    //your login level goes between parentheses
    11. }
    12. [*]}
    13. [/LIST]
    14. // drag the login thing button, make it onclick, LoginTapped, script on the button.
    15.  
     
  26. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    this way you did the button works, it jumps to the other scene,

    But the unity console says,
    (ArgumentNullException: Argument cannot be null.
    Parameter name: s)

    we we can link the way you did, to work when the script make the real login, and the real registration, its possible?
     
    Last edited: Oct 16, 2015
  27. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    my friend you are the best, god bless you, i got it,,, yessss thank very much!!! hugs..
    works great!!!
     
  28. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    I'm not a good explainer also but, if you explained the page wouldn't change when clicked we wouldn't of had to say 80 msgs. Though your welcome! Learn to program so you don't have to rely on others! Good Luck - Goof