Exemple #1
0
    void OnGUI()
    {
        GUIStyle style = "box";

        style.fontSize  = 35;
        style.alignment = TextAnchor.UpperLeft;
        style.wordWrap  = true;
        if (GUILayout.Button("Get IPGeolocation", GUILayout.Height(75), GUILayout.Width(Screen.width)))
        {
            showDetail = "Start Get IP。。。。";
            IPGeolocationManager.GetIPGeolocation((detail) =>
            {
                if (detail == null)
                {
                    showDetail = "Get IP failed!";
                }
                else
                {
                    showDetail = JsonUtils.ToJson(detail);
                }
                // Debug.Log(showDetail);
            });
        }
        if (GUILayout.Button("Clear", GUILayout.Height(75), GUILayout.Width(Screen.width)))
        {
            showDetail = "";
            logStr     = "";
        }


        pos = GUILayout.BeginScrollView(pos);
        GUILayout.Box(showDetail, style);
        GUILayout.Label(logStr, style);
        GUILayout.EndScrollView();
    }
    public static void GetIPGeolocation(Action <IPGeolocationDetail> OnIPGeolocationCallBack)
    {
        GameObject obj = new GameObject("[IPGeolocationManager]");

        GameObject.DontDestroyOnLoad(obj);
        IPGeolocationManager manager = obj.AddComponent <IPGeolocationManager>();

        manager.OnIPGeolocationCallBack = OnIPGeolocationCallBack;
        manager.Run();
    }
 //  Action<string, GameServerAreaDataGenerate> OnGetServerAreaCompleted;
 protected override void OnFlowStart(params object[] paras)
 {
     index = 0;
     IPGeolocationManager.GetIPGeolocation(ReciveIPDetail);
 }