GA test. This should be instances as an asset and
Inheritance: UnityEngine.ScriptableObject
Ejemplo n.º 1
0
    void OnEnable()
    {
        GA_Settings ga = target as GA_Settings;

        if (ga.Logo == null)
        {
            ga.Logo = (Texture2D)Resources.LoadAssetAtPath("Assets/GameAnalytics/Plugins/Examples/gaLogo.png", typeof(Texture2D));
            //http://www.base64-image.de

            /*String d = "";
             * d += "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAA";
             * d += "CXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH3AcFDBE3zqglrQAACQdJREFUeNrtW2tIVGsXf";
             * d += "mY7jcp4m+yoTdqYKWqFQtnlR2lFJGVxpEwIoThIHPDX15+v/oQdoiCC/DoQQSUxENSh7PJDHM";
             * d += "wL6lEY00Og2dV7U15GHXHUue71/WjPsGf2zDR7nE7ZtGDjOPPenudda73vu961Jfh6IuEeBYC";
             * d += "dADYDyAKQBiCJ+z6CK2sCMANgDMAAgNcA/gHwN/c9cc93L2EAwjmwFwG84A0+0OcF19Zmru2w";
             * d += "7xG4DIAcQAWA524A2CWAd6/7nOtDzvX5zWUFgFgA/wUwHiTQ/pAxzvUZy43hm0g0gHIAg0Gcc";
             * d += "bEaMciNIfrfBC4FsB1Azb8I/EtE1HBjkn5t8BEAfuO89bcA7ouIMW5sEV8LfAyASgBGXuffEj";
             * d += "x5GIeRG2NMsMH/AuBPANbvYNa/pA1Wbqy/BBP8re9E5cWYxK1gkBDDsbkcwHsa459LMYcIzp6";
             * d += "sywi8J3OoDMQxSjmPalyG4N1JMHJYRC2R23lL3XIE707CGIfJ7x1ezQ8A3p2EGn92jCu4rSX9";
             * d += "gAQQh83n2SGWt7f/EcC7kzDIYXRxdvwj7e8AUnkBDdGiVCpx6NAh5OfnY+3atUhOTgYRQSKRY";
             * d += "HZ2Fl1dXdDpdKirq4NWq3Wpu2bNGlRUVGDr1q1QqVSQSqVgGAY9PT0wGAy4desW2traAg3OgM";
             * d += "P2O4D/AbC4F5LzjrSiZz8jI4PUajVNTk6S0Wgki8VCLMuSu5jNZlpcXKTZ2VkaGBigkpISZxt";
             * d += "Hjx6l4eFhQR2bzUZWq5WqqqqCoQXjHFZBJKci0MYvX75M09PTZLVaBYN3kOCJDCKiM2fOONu5";
             * d += "fv062Ww2l7r8eh8+fAiWSVS4R5bCeZEcUbN/9+5dMplMFIjMz8/TyZMnCQBFR0dTS0uLz/IWi";
             * d += "4X27t0bDC14zmEGwxGwEUAe96Pftq9Wq1FaWorw8HAQiY9Z9vf3o7+/HwBQWFiItLQ0n+UZhs";
             * d += "GePXuWGqglDutG/pcXxbJ57tw5MhqNAvXmq7zVaiWz2ezyWCwWstvtRERUXV1NERERBICqqqo";
             * d += "8tuPeZm9vb7DM4CIAiZQjoEgMjenp6SgpKYFcLnd6eADOz3a7HUNDQ3j48CFqa2uxsLDweZmR";
             * d += "ybBp0yYUFhYiPT0djY2NMJlMCA8PR0ZGBiQSibMNx2cAzvYlEgnWrVuHzMxMvHnzZqkHvSIA5";
             * d += "wAgXqztX7t2zcVZuXvsuro6v9oJCwsjALR7927q6+sTzPjo6KigH7PZTGfPng3WviAeAH4VUz";
             * d += "k9PZ06Ozu9qml9fb3oAZ0/f94joeXl5QIzs9vt1N7eHiwz+BUA/hBT6dSpU6TX673Ofmpqqqh";
             * d += "ByOVyevTokYDQ1tZWSkhIoImJCQHJMzMzlJycHAwC/mC46yq/ZePGjYiPj/f4W11dHYaGhkQZ";
             * d += "Yl5eHrKyspw27rB7jUaDiYkJ9Pb2gmVZF18gk8lw5MiRYES7shjurs6/CElEBFQqldPhuUttb";
             * d += "a1zkP7KypUrYbPZoNfrwbKss357ezsAoLGx0UkAfxxFRUXBICBNyl1U+iWrV69GXFycy2zw5d";
             * d += "WrVwJiJBIJFAoFEhMTBUCsVitYlsWTJ0+gUCiQnZ2NjIwMyGQyvH//HgDQ1NSEyspKZx0iAsM";
             * d += "wyMnJQXx8PKamppZCQJKUu6X1r3RSEhQK78UHBgaEl4YyGUpLS1FWVgaz2Swgx2q1wmKxgGVZ";
             * d += "6PV6rFq1Ct3d3VhcXAQAdHZ2Ym5uDgqFwrk8AkBkZCSKi4tRXV29FAIUAGDz12ns2rWLenp6v";
             * d += "G5V5XK5oE5UVBTduXNH1Ba5vLycpFKps436+nrBWcJqtdK9e/eW6gRtjBi6GIbxaePetsMWi0";
             * d += "XUtHR1dcFmszn/b2hoEAYtpVLk5OQgOnpp14IMl5zgl0xNTWFubs7r7ykpKZ434CIcY0dHh8C";
             * d += "uGxoaXFYIx9+EhAQcPHhwKfhNDJeB4ZfMzMz4JCAzM1MAlr9V9qUx/OVvenrapdyLFy8wMzPj";
             * d += "siUGgJiYGBQUFCyFgBmGi5j6JTqdDpOTk17VPS8vTwDWZDLh6tWrKC4uxuHDh1FUVITjx49Do";
             * d += "9G4lHV81mq1zrODQ1iWRUdHh0cHm5ubC4ZhAiVgDAD+EuM4Ll265DW48fLlS7/aWL9+PTU1NQ";
             * d += "nqv337lrKzsz3WOX36tMdAy+joKB04cCBQJ/gXg88JSX5LW1ubx+UOADZs2IBjx459sY3MzEz";
             * d += "k5+cLvtdqtQL1d8izZ89cNM+hMfHx8di5c2egGvCawedsLL+ltbUVIyMjXm345s2b2L9/v/e4";
             * d += "+4oV2LJlC8LCwgR1m5ubMT4+7rFeX18fBgcHBSYWGRmJvLy8QAn4h8HnVDTAzzS0+fl5PH36F";
             * d += "AaDQXBmJyLExcXh/v37uHDhApKShJvM3Nxc7Nu3TzCbCwsLzuiQJ2FZFs3NzR6daEpKCrZt2y";
             * d += "YGuAPr346lUFQ6W1RUFDU2Nnr0Aw7bNJvNNDs7S58+faIHDx6QRqOhjx8/ktFo9Bg87ejooKy";
             * d += "sLJ/9lpWVeexzYWGBKisrA0m/YwIOieXn59PIyIjPiK9D7Ha7MwzmLVp85coVio6O9tlnYmKi";
             * d += "1/5qamoCCok5VGJzIBHhgoIC0ul0HuN43gbqjSz+/YC3RyqVklar9dhed3c35eTkiIkGbeZHh";
             * d += "V8C6OJFTf2SlpYWlJWV4fXr1y5HWV8bIL7fcMi7d++g0+m+2B/LsmhqavK4kVKpVNixY4c/ti";
             * d += "/hsL4M2sVIZGQkqdVqMhgMZDabv2gS/KixIzqclJTkV1/bt2/3qkm3b98WfTEicbsaGwCQIPZ";
             * d += "+gH+3d+LECRQXFyMtLQ1hYWHOBwDsdjvsdjsAYHx8HFqtFmq1WuDdfYlMJsPjx4+hVCqhVCpB";
             * d += "RDCZTBgeHoZGo8GNGzdgMBh8zf4EFwSadydABuA/AC4HI9QSGxsLlUqF1NRUKJVK2Gw2jI2NY";
             * d += "WBgAHq9HhMTE/hGcsbb5WhIXo//TJD4mSLzM0nKo4R8mhwQ4omSDgnpVFmHhHSyNJ+EkE2X55";
             * d += "tDyL4wwXeMIfvKDH+JDNmXptx3jCH52pz72SFkX5yE21E6JF+ddZdl9/K05CuSsSxen/8/Sd3";
             * d += "GJdqpTWgAAAAASUVORK5CYII=";
             * ga.Logo = new Texture2D(1,1);
             * ga.Logo.LoadImage(System.Convert.FromBase64String(d));*/
        }
    }
Ejemplo n.º 2
0
    private static void InitAPI()
    {
        try
        {
            _settings = (GA_Settings)Resources.Load("GameAnalytics/GA_Settings", typeof(GA_Settings));

                        #if UNITY_EDITOR
            if (_settings == null)
            {
                //If the settings asset doesn't exist, then create it. We require a resources folder
                if (!Directory.Exists(Application.dataPath + "/Resources"))
                {
                    Directory.CreateDirectory(Application.dataPath + "/Resources");
                }
                if (!Directory.Exists(Application.dataPath + "/Resources/GameAnalytics"))
                {
                    Directory.CreateDirectory(Application.dataPath + "/Resources/GameAnalytics");
                    Debug.LogWarning("GameAnalytics: Resources/GameAnalytics folder is required to store settings. it was created ");
                }

                var asset = ScriptableObject.CreateInstance <GA_Settings>();
                //some hack to mave the asset around
                string path = AssetDatabase.GetAssetPath(Selection.activeObject);
                if (path == "")
                {
                    path = "Assets";
                }
                else if (Path.GetExtension(path) != "")
                {
                    path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
                }
                string uniquePath = AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/GameAnalytics/GA_Settings.asset");
                AssetDatabase.CreateAsset(asset, uniquePath);
                if (uniquePath != "Assets/Resources/GameAnalytics/GA_Settings.asset")
                {
                    GA.Log("GameAnalytics: The path Assets/Resources/GameAnalytics/GA_Settings.asset used to save the settings file is not available.");
                }
                AssetDatabase.SaveAssets();
                Debug.LogWarning("GameAnalytics: Settings file didn't exist and was created");
                Selection.activeObject = asset;

                //save reference
                _settings = asset;
            }
                        #endif
            GA.InitializeQueue();             //will also start a coroutine sending messages to the server if needed
        }
        catch (Exception e)
        {
            Debug.Log("Error getting GA_Settings in InitAPI: " + e.Message);
        }
    }
Ejemplo n.º 3
0
	private static void InitAPI ()
	{
		try
		{
			_settings = (GA_Settings)Resources.Load("GameAnalytics/GA_Settings", typeof(GA_Settings));
			
			#if UNITY_EDITOR
	 		if (_settings == null)
			{
				//If the settings asset doesn't exist, then create it. We require a resources folder
				if(!Directory.Exists(Application.dataPath+"/Resources"))
				{
					Directory.CreateDirectory(Application.dataPath+"/Resources");
				}
				if(!Directory.Exists(Application.dataPath+"/Resources/GameAnalytics"))
				{
					Directory.CreateDirectory(Application.dataPath+"/Resources/GameAnalytics");
					Debug.LogWarning("GameAnalytics: Resources/GameAnalytics folder is required to store settings. it was created ");
				}
				
				var asset = ScriptableObject.CreateInstance<GA_Settings>();
				//some hack to mave the asset around
				string path = AssetDatabase.GetAssetPath (Selection.activeObject);
				if (path == "") 
				{
					path = "Assets";
				}
				else if (Path.GetExtension (path) != "") 
				{
					path = path.Replace (Path.GetFileName (AssetDatabase.GetAssetPath (Selection.activeObject)), "");
				}
				string uniquePath = AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/GameAnalytics/GA_Settings.asset");
				AssetDatabase.CreateAsset(asset, uniquePath);
				if(uniquePath != "Assets/Resources/GameAnalytics/GA_Settings.asset")
				{
					Debug.LogWarning("GameAnalytics: The path Assets/Resources/GameAnalytics/GA_Settings.asset used to save the settings file is not available.");
				}
				AssetDatabase.SaveAssets ();
				Debug.LogWarning("GameAnalytics: Settings file didn't exist and was created");
				Selection.activeObject = asset;
				
				//save reference
				_settings =	asset;
			}
			#endif
			GA.InitializeQueue(); //will also start a coroutine sending messages to the server if needed
		}
		catch (Exception e)
		{
			Debug.LogWarning("Error getting GA_Settings in InitAPI: " + e.Message);
		}
	}
Ejemplo n.º 4
0
 private void CheckAdNetwork(GA_Settings ga, GA_AdSupport.GAAdNetwork AdNetwork)
 {
     if (AdNetwork == GA_AdSupport.GAAdNetwork.iAd && !ga.IAD_enabled ||
         AdNetwork == GA_AdSupport.GAAdNetwork.Chartboost && !ga.CB_enabled)
     {
         Rect  lastrect = GUILayoutUtility.GetLastRect();
         Color tmpColor = GUI.color;
         int   tmpSize  = GUI.skin.label.fontSize;
         GUI.color = Color.red;
         GUI.DrawTexture(new Rect(lastrect.x - 2, lastrect.y - 1, 5, 17), _triggerAdNotEnabledTexture);
         GUI.color = Color.white;
         GUI.skin.label.fontSize = 20;
         GUI.Label(new Rect(lastrect.x - 5, lastrect.y - 7, 20, 30), _triggerAdNotEnabled);
         GUI.skin.label.fontSize = tmpSize;
         GUI.color = tmpColor;
     }
 }
Ejemplo n.º 5
0
    private static void SignupUser(GA_Settings ga)
    {
        string info = "{\"unityToken\": \"" + _unityToken + "\", \"email\": \"" + ga.EmailGA + "\", \"password\": \"" + ga.PasswordGA + "\", \"passwordConfirm\": \"" + ga.PasswordConfirm + "\", \"firstName\": \"" + ga.FirstName + "\", \"lastName\": \"" + ga.LastName + "\", \"studioName\": \"" + ga.StudioName + "\", \"gameTitle\": \"" + ga.GameName + "\", \"emailOptOut\": " + Convert.ToInt32(ga.EmailOptIn) + "}";
        byte[] data = System.Text.Encoding.UTF8.GetBytes(info);

        WWW www = new WWW("https://go.gameanalytics.com/v1/public/signup/basic/unity_editor", data);
        GA_ContinuationManager.StartCoroutine(SignupUserFrontend(www, ga), () => www.isDone);
    }
Ejemplo n.º 6
0
 private static void SetLoginStatus(string status, GA_Settings ga)
 {
     ga.LoginStatus = status;
     EditorUtility.SetDirty(ga);
 }
Ejemplo n.º 7
0
 private static void SelectStudio(int index, GA_Settings ga)
 {
     ga.SelectedStudio = index;
     if (ga.Studios[index - 1].Games.Count == 1)
     {
         SelectGame (1, ga);
     }
     else
     {
         SetLoginStatus ("Please select game..", ga);
     }
 }
Ejemplo n.º 8
0
 private static void SelectGame(int index, GA_Settings ga)
 {
     ga.SelectedGame = index;
     SetLoginStatus ("Getting Game Key and Secret Key..", ga);
     GetGameInfo(ga);
 }
Ejemplo n.º 9
0
    override public void OnInspectorGUI()
    {
        GA_Settings ga = target as GA_Settings;


        EditorGUI.indentLevel = 1;
        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();


        GUILayout.Label(ga.Logo);

        GUILayout.BeginVertical();

        GUILayout.Label("GameAnalytics Unity SDK v." + GA_Settings.VERSION);

        GUILayout.BeginHorizontal();

        if (GUILayout.Button(_myPageLink, GUILayout.MaxWidth(65)))
        {
            Application.OpenURL("http://easy.gameanalytics.com/LoginGA");
        }
        if (GUILayout.Button(_documentationLink, GUILayout.MaxWidth(65)))
        {
            Application.OpenURL("http://easy.gameanalytics.com/SupportDocu");
        }
        if (GUILayout.Button(_checkForUpdates, GUILayout.MaxWidth(65)))
        {
            Application.OpenURL("http://easy.gameanalytics.com/DownloadSetup");             //http://u3d.as/content/game-analytics/game-analytics-unity-package
        }

        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

        GUILayout.EndHorizontal();


        //Hints

        /*ga.DisplayHints = EditorGUILayout.Foldout(ga.DisplayHints,"Show Hints");
         * if (ga.DisplayHints)
         * {
         *      ga.DisplayHintsScrollState = GUILayout.BeginScrollView(ga.DisplayHintsScrollState, GUILayout.Height (100));
         *
         *      List<GA_Settings.HelpInfo> helpInfos = ga.GetHelpMessageList();
         *      foreach(GA_Settings.HelpInfo info in helpInfos)
         *      {
         *              MessageType msgType = ConvertMessageType(info.MsgType);
         *              EditorGUILayout.HelpBox(info.Message, msgType);
         *      }
         *
         *      GUILayout.EndScrollView();
         * }*/

        //Tabs
        GUILayout.BeginHorizontal();

        GUIStyle activeTabStyle      = new GUIStyle(EditorStyles.miniButtonMid);
        GUIStyle activeTabStyleLeft  = new GUIStyle(EditorStyles.miniButtonLeft);
        GUIStyle activeTabStyleRight = new GUIStyle(EditorStyles.miniButtonRight);

        activeTabStyle.normal      = EditorStyles.miniButtonMid.active;
        activeTabStyleLeft.normal  = EditorStyles.miniButtonLeft.active;
        activeTabStyleRight.normal = EditorStyles.miniButtonRight.active;

        GUIStyle inactiveTabStyle      = new GUIStyle(EditorStyles.miniButtonMid);
        GUIStyle inactiveTabStyleLeft  = new GUIStyle(EditorStyles.miniButtonLeft);
        GUIStyle inactiveTabStyleRight = new GUIStyle(EditorStyles.miniButtonRight);

        if (GUILayout.Button(_basic, ga.CurrentInspectorState == GA_Settings.InspectorStates.Basic?activeTabStyleLeft:inactiveTabStyleLeft))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Basic;
        }

        if (GUILayout.Button(_debug, ga.CurrentInspectorState == GA_Settings.InspectorStates.Debugging?activeTabStyle:inactiveTabStyle))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Debugging;
        }
        if (GUILayout.Button(_preferences, ga.CurrentInspectorState == GA_Settings.InspectorStates.Pref?activeTabStyleRight:inactiveTabStyleRight))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Pref;
        }
        GUILayout.EndHorizontal();

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Basic)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_publicKeyLabel, GUILayout.Width(75));
            ga.GameKey = EditorGUILayout.TextField("", ga.GameKey);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_privateKeyLabel, GUILayout.Width(75));
            ga.SecretKey = EditorGUILayout.TextField("", ga.SecretKey);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_build, GUILayout.Width(75));
            ga.Build = EditorGUILayout.TextField("", ga.Build);
            GUILayout.EndHorizontal();
        }

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Debugging)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_debugMode, GUILayout.Width(150));
            ga.DebugMode = EditorGUILayout.Toggle("", ga.DebugMode);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_runInEditor, GUILayout.Width(150));
            ga.RunInEditorPlayMode = EditorGUILayout.Toggle("", ga.RunInEditorPlayMode);
            GUILayout.EndHorizontal();
        }

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Pref)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_apiKeyLabel, GUILayout.Width(75));
            ga.ApiKey = EditorGUILayout.TextField("", ga.ApiKey);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_heatmapSizeLabel, GUILayout.Width(150));
            GUILayout.EndHorizontal();
            GUILayout.Space(-15);
            ga.HeatmapGridSize = EditorGUILayout.Vector3Field("", ga.HeatmapGridSize);
            if (ga.HeatmapGridSize != Vector3.one)
            {
                EditorGUILayout.HelpBox("Editing the heatmap grid size must be done BEFORE data is submitted, and you must use the same grid size when setting up your heatmaps. Otherwise the heatmap data will be incorrectly displayed.", MessageType.Warning);
            }

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_interval, GUILayout.Width(150));

            int tmpTimer = 0;
            if (int.TryParse(EditorGUILayout.TextField(ga.SubmitInterval.ToString(), GUILayout.Width(38)), out tmpTimer))
            {
                ga.SubmitInterval = Mathf.Max(Mathf.Min(tmpTimer, 999), 1);
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_customUserID, GUILayout.Width(150));
            ga.CustomUserID = EditorGUILayout.Toggle("", ga.CustomUserID);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_archiveData, GUILayout.Width(150));
            ga.ArchiveData = EditorGUILayout.Toggle("", ga.ArchiveData, GUILayout.Width(36));
            GUI.enabled    = ga.ArchiveData;
            GUILayout.Label(_archiveMaxSize, GUILayout.Width(40));

            int tmpMaxArchiveSize = 0;
            if (int.TryParse(EditorGUILayout.TextField(ga.ArchiveMaxFileSize.ToString(), GUILayout.Width(48)), out tmpMaxArchiveSize))
            {
                ga.ArchiveMaxFileSize = Mathf.Max(Mathf.Min(tmpMaxArchiveSize, 2000), 0);
            }

            GUI.enabled = true;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_allowRoaming, GUILayout.Width(150));
            ga.AllowRoaming = EditorGUILayout.Toggle("", ga.AllowRoaming);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_newSessionOnResume, GUILayout.Width(150));
            ga.NewSessionOnResume = EditorGUILayout.Toggle("", ga.NewSessionOnResume);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(ga);
        }
    }
Ejemplo n.º 10
0
    private static void GetUserData(GA_Settings ga)
    {
        Hashtable headers = new Hashtable();
        headers.Add("X-Authorization", ga.TokenGA);

        WWW www = new WWW("https://go.gameanalytics.com/v1/user/data", null, headers);
        GA_ContinuationManager.StartCoroutine(GetUserDataFrontend(www, ga), () => www.isDone);
    }
Ejemplo n.º 11
0
    private static IEnumerator<WWW> GetKeysFrontend(WWW www, GA_Settings ga)
    {
        yield return www;

        try {
            if (string.IsNullOrEmpty(www.error))
            {
                Hashtable returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text);
                string error = "";
                if (returnParam.ContainsKey("errors"))
                {
                    ArrayList errorList = (ArrayList)returnParam["errors"];
                    if (errorList != null && errorList.Count > 0)
                    {
                        Hashtable errors = (Hashtable)errorList[0];
                        if (errors.ContainsKey("msg"))
                        {
                            error = errors["msg"].ToString();
                        }
                    }
                }

                if (!String.IsNullOrEmpty(error))
                {
                    Debug.LogError(error);
                }
                else
                {
                    ArrayList resultList = (ArrayList)returnParam["results"];
                    Hashtable results = (Hashtable)resultList[0];
                    ga.GameKey = results["key"].ToString();
                    ga.SecretKey = results["secret_key"].ToString();
                    ga.ApiKey = results["data_api_key"].ToString();

                    SetLoginStatus ("Received Game Key and Secret Key. Ready to send events!", ga);

                    GA_Tracking.SendEvent("KeysInput");
                }
            }
            else
            {
                Debug.LogError("Failed to get Game Key and Secret Key: " + www.error);
                SetLoginStatus ("Failed to get Game Key and Secret Key.", ga);
            }
        }
        catch {
            Debug.LogError("Failed to get Game Key and Secret Key");
            SetLoginStatus ("Failed to get Game Key and Secret Key.", ga);
        }
    }
Ejemplo n.º 12
0
    private static void GetGameInfo(GA_Settings ga)
    {
        Hashtable headers = new Hashtable();
        headers.Add("X-Authorization", ga.TokenGA);

        WWW www = new WWW("https://go.gameanalytics.com/v1/games/" + ga.Studios[ga.SelectedStudio-1].GameIDs[ga.SelectedGame-1], null, headers);
        GA_ContinuationManager.StartCoroutine(GetKeysFrontend(www, ga), () => www.isDone);
    }
Ejemplo n.º 13
0
	private static void GetUserData (GA_Settings ga)
	{
		#if UNITY_4_3 || UNITY_4_2 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0
		Hashtable headers = new Hashtable();
		#else
		Dictionary<string, string> headers = new Dictionary<string, string>();
		#endif
		headers.Add("X-Authorization", ga.TokenGA);
		
		WWW www = new WWW("https://go.gameanalytics.com/v1/user/data", null, headers);
		GA_ContinuationManager.StartCoroutine(GetUserDataFrontend(www, ga), () => www.isDone);
	}
Ejemplo n.º 14
0
	private static void GetGameInfo (GA_Settings ga)
	{
		#if UNITY_4_3 || UNITY_4_2 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0
		Hashtable headers = new Hashtable();
		#else
		Dictionary<string, string> headers = new Dictionary<string, string>();
		#endif
		headers.Add("X-Authorization", ga.TokenGA);

		WWW www = new WWW("https://go.gameanalytics.com/v1/games/" + ga.Studios[ga.SelectedStudio-1].GameIDs[ga.SelectedGame-1], null, headers);
		GA_ContinuationManager.StartCoroutine(GetKeysFrontend(www, ga), () => www.isDone);
	}
Ejemplo n.º 15
0
    private static IEnumerator<WWW> SignupUserFrontend(WWW www, GA_Settings ga)
    {
        yield return www;

        try {
            if (string.IsNullOrEmpty(www.error))
            {
                Hashtable returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text);
                string error = "";
                if (returnParam.ContainsKey("errors"))
                {
                    ArrayList errorList = (ArrayList)returnParam["errors"];
                    if (errorList != null && errorList.Count > 0)
                    {
                        Hashtable errors = (Hashtable)errorList[0];
                        if (errors.ContainsKey("msg"))
                        {
                            error = errors["msg"].ToString();
                        }
                    }
                }

                if (!String.IsNullOrEmpty(error))
                {
                    Debug.LogError(error);
                }
                else
                {
                    ArrayList resultList = (ArrayList)returnParam["results"];
                    Hashtable results = (Hashtable)resultList[0];
                    ga.TokenGA = results["token"].ToString();
                    ga.ExpireTime = results["exp"].ToString();

                    ga.JustSignedUp = true;

                    //ga.SignUpOpen = false;
                    ga.SelectedStudio = 0;
                    ga.SelectedGame = 0;
                    ga.Studios = null;
                    SetLoginStatus ("Signed up. Getting user data..", ga);

                    GetUserData(ga);
                }
            }
            else
            {
                Debug.LogError("Failed to sign up: " + www.error);
                SetLoginStatus ("Failed to sign up.", ga);
            }
        }
        catch {
            Debug.LogError("Failed to sign up");
            SetLoginStatus ("Failed to sign up.", ga);
        }
    }
Ejemplo n.º 16
0
 private void CheckAdNetwork(GA_Settings ga, GA_AdSupport.GAAdNetwork AdNetwork)
 {
     if (AdNetwork == GA_AdSupport.GAAdNetwork.iAd && !GA.SettingsGA.IAD_enabled ||
         AdNetwork == GA_AdSupport.GAAdNetwork.Chartboost && !GA.SettingsGA.CB_enabled)
     {
         Rect lastrect = GUILayoutUtility.GetLastRect();
         Color tmpColor = GUI.color;
         int tmpSize = GUI.skin.label.fontSize;
         GUI.color = Color.red;
         GUI.DrawTexture(new Rect(lastrect.x - 2, lastrect.y - 1, 5, 17), _triggerAdNotEnabledTexture);
         GUI.color = Color.white;
         GUI.skin.label.fontSize = 20;
         GUI.Label(new Rect(lastrect.x - 5, lastrect.y - 7, 20, 30), _triggerAdNotEnabled);
         GUI.skin.label.fontSize = tmpSize;
         GUI.color = tmpColor;
     }
 }
Ejemplo n.º 17
0
    private static IEnumerator<WWW> GetUserDataFrontend(WWW www, GA_Settings ga)
    {
        yield return www;

        try {
            if (string.IsNullOrEmpty(www.error))
            {
                Hashtable returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text);
                string error = "";
                if (returnParam.ContainsKey("errors"))
                {
                    ArrayList errorList = (ArrayList)returnParam["errors"];
                    if (errorList != null && errorList.Count > 0)
                    {
                        Hashtable errors = (Hashtable)errorList[0];
                        if (errors.ContainsKey("msg"))
                        {
                            error = errors["msg"].ToString();
                        }
                    }
                }

                if (!String.IsNullOrEmpty(error))
                {
                    Debug.LogError(error);
                    SetLoginStatus ("Failed to get user data.", ga);
                }
                else
                {
                    ArrayList resultList = (ArrayList)returnParam["results"];
                    Hashtable results = (Hashtable)resultList[0];
                    ArrayList studioList = (ArrayList)results["studiosGames"];

                    List<Studio> returnStudios = new List<Studio>();

                    for (int s = 0; s < studioList.Count; s++)
                    {
                        Hashtable studio = (Hashtable)studioList[s];
                        if (!studio.ContainsKey("demo") || !((bool)studio["demo"]))
                        {
                            List<string> returnGames = new List<string>();
                            List<string> returnTokens = new List<string>();
                            List<int> returnIDs = new List<int>();

                            ArrayList gamesList = (ArrayList)studio["games"];
                            for (int g = 0; g < gamesList.Count; g++)
                            {
                                Hashtable games = (Hashtable)gamesList[g];
                                returnGames.Add(games["title"].ToString());
                                returnIDs.Add(int.Parse(games["id"].ToString()));
                                Hashtable token = (Hashtable)games["dataApiToken"];
                                returnTokens.Add(token["token"].ToString());
                            }

                            returnStudios.Add(new Studio(studio["name"].ToString(), returnGames, returnTokens, returnIDs));
                        }
                    }
                    ga.Studios = returnStudios;

                    if (ga.Studios.Count == 1)
                    {
                        SelectStudio (1, ga);
                    }
                    else
                    {
                        SetLoginStatus ("Received user data. Please select studio..", ga);
                    }

                    ga.CurrentInspectorState = GA_Settings.InspectorStates.Basic;
                }
            }
            else
            {
                Debug.LogError("Failed to get user data: " + www.error);
                SetLoginStatus ("Failed to get user data.", ga);
            }
        }
        catch {
            Debug.LogError("Failed to get user data");
            SetLoginStatus ("Failed to get user data.", ga);
        }
    }
Ejemplo n.º 18
0
    private static void LoginUser(GA_Settings ga)
    {
        string info = "{\"email\": \"" + ga.EmailGA + "\", \"password\": \"" + ga.PasswordGA + "\", \"remember\": false}";

        byte[] data = System.Text.Encoding.UTF8.GetBytes(info);

        WWW www = new WWW("https://go.gameanalytics.com/v1/public/login/basic", data);
        GA_ContinuationManager.StartCoroutine(LoginUserFrontend(www, ga), () => www.isDone);
    }
Ejemplo n.º 19
0
    private static IEnumerator<WWW> LoginUserFrontend(WWW www, GA_Settings ga)
    {
        yield return www;

        try {
            if (string.IsNullOrEmpty(www.error))
            {
                Hashtable returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text);
                string error = "";
                if (returnParam.ContainsKey("errors"))
                {
                    ArrayList errorList = (ArrayList)returnParam["errors"];
                    if (errorList != null && errorList.Count > 0)
                    {
                        Hashtable errors = (Hashtable)errorList[0];
                        if (errors.ContainsKey("msg"))
                        {
                            error = errors["msg"].ToString();
                        }
                    }
                }

                if (!String.IsNullOrEmpty(error))
                {
                    Debug.LogError(error);
                    SetLoginStatus ("Failed to login.", ga);
                }
                else
                {
                    ArrayList resultList = (ArrayList)returnParam["results"];
                    Hashtable results = (Hashtable)resultList[0];
                    ga.TokenGA = results["token"].ToString();
                    ga.ExpireTime = results["exp"].ToString();

                    SetLoginStatus ("Logged in. Getting user data..", ga);

                    GetUserData(ga);
                }
            }
            else
            {
                Debug.LogError("Failed to login: "******"Failed to login.", ga);
            }
        }
        catch {
            Debug.LogError("Failed to login");
            SetLoginStatus ("Failed to login.", ga);
        }
    }
 private MessageType ConvertMessageType(GA_Settings.MessageTypes msgType)
 {
     switch (msgType)
     {
         case GA_Settings.MessageTypes.Error:
             return MessageType.Error;
         case GA_Settings.MessageTypes.Info:
             return MessageType.Info;
         case GA_Settings.MessageTypes.Warning:
             return MessageType.Warning;
         default:
             return MessageType.None;
     }
 }
Ejemplo n.º 21
0
    override public void OnInspectorGUI()
    {
        GA_Settings ga = target as GA_Settings;


        EditorGUI.indentLevel = 1;
        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();


        GUILayout.Label(ga.Logo);

        GUILayout.BeginVertical();

        GUILayout.Label("GameAnalytics Unity SDK v." + GA_Settings.VERSION);

        GUILayout.BeginHorizontal();

        if (GUILayout.Button(_myPageLink, GUILayout.MaxWidth(75)))
        {
            Application.OpenURL("http://easy.gameanalytics.com/LoginGA");
        }
        if (GUILayout.Button(_documentationLink, GUILayout.MaxWidth(75)))
        {
            Application.OpenURL("http://easy.gameanalytics.com/SupportDocu");
        }
        if (GUILayout.Button(_checkForUpdates, GUILayout.MaxWidth(75)))
        {
            Application.OpenURL("http://easy.gameanalytics.com/DownloadSetup");
        }

        GUILayout.EndHorizontal();

        string updateStatus = GA_UpdateWindow.UpdateStatus(GA_Settings.VERSION);

        GUILayout.Space(5);
        GUILayout.BeginHorizontal();

        if (!updateStatus.Equals(string.Empty))
        {
            if (_orangeUpdateLabelStyle == null)
            {
                _orangeUpdateLabelStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
                _orangeUpdateLabelStyle.normal.textColor = new Color(0.875f, 0.309f, 0.094f);
            }
            if (_orangeUpdateIconStyle == null)
            {
                _orangeUpdateIconStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
            }

            if (GUILayout.Button(ga.UpdateIcon, _orangeUpdateIconStyle, GUILayout.MaxWidth(17)))
            {
                OpenUpdateWindow();
            }

            GUILayout.Label(updateStatus, _orangeUpdateLabelStyle);
        }
        else
        {
            GUILayout.Label("");
        }

        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

        GUILayout.EndHorizontal();


        //Hints

        /*ga.DisplayHints = EditorGUILayout.Foldout(ga.DisplayHints,"Show Hints");
         * if (ga.DisplayHints)
         * {
         *      ga.DisplayHintsScrollState = GUILayout.BeginScrollView(ga.DisplayHintsScrollState, GUILayout.Height (100));
         *
         *      List<GA_Settings.HelpInfo> helpInfos = ga.GetHelpMessageList();
         *      foreach(GA_Settings.HelpInfo info in helpInfos)
         *      {
         *              MessageType msgType = ConvertMessageType(info.MsgType);
         *              EditorGUILayout.HelpBox(info.Message, msgType);
         *      }
         *
         *      GUILayout.EndScrollView();
         * }*/

        //Tabs
        GUILayout.BeginHorizontal();

        GUIStyle activeTabStyle      = new GUIStyle(EditorStyles.miniButtonMid);
        GUIStyle activeTabStyleLeft  = new GUIStyle(EditorStyles.miniButtonLeft);
        GUIStyle activeTabStyleRight = new GUIStyle(EditorStyles.miniButtonRight);

        activeTabStyle.normal      = EditorStyles.miniButtonMid.active;
        activeTabStyleLeft.normal  = EditorStyles.miniButtonLeft.active;
        activeTabStyleRight.normal = EditorStyles.miniButtonRight.active;

        GUIStyle inactiveTabStyle      = new GUIStyle(EditorStyles.miniButtonMid);
        GUIStyle inactiveTabStyleLeft  = new GUIStyle(EditorStyles.miniButtonLeft);
        GUIStyle inactiveTabStyleRight = new GUIStyle(EditorStyles.miniButtonRight);

        if (GUILayout.Button(_basic, ga.CurrentInspectorState == GA_Settings.InspectorStates.Basic?activeTabStyleLeft:inactiveTabStyleLeft))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Basic;
        }

        if (GUILayout.Button(_debug, ga.CurrentInspectorState == GA_Settings.InspectorStates.Debugging?activeTabStyle:inactiveTabStyle))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Debugging;
        }

        if (GUILayout.Button(_preferences, ga.CurrentInspectorState == GA_Settings.InspectorStates.Pref?activeTabStyle:inactiveTabStyle))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Pref;
        }

        if (GUILayout.Button(_ads, ga.CurrentInspectorState == GA_Settings.InspectorStates.Ads?activeTabStyleRight:inactiveTabStyleRight))
        {
            ga.CurrentInspectorState = GA_Settings.InspectorStates.Ads;
        }

        GUILayout.EndHorizontal();

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Basic)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_publicKeyLabel, GUILayout.Width(75));
            ga.GameKey = EditorGUILayout.TextField("", ga.GameKey);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_privateKeyLabel, GUILayout.Width(75));
            ga.SecretKey = EditorGUILayout.TextField("", ga.SecretKey);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_build, GUILayout.Width(75));
            ga.Build = EditorGUILayout.TextField("", ga.Build);
            GUILayout.EndHorizontal();

                        #if UNITY_ANDROID
            EditorGUILayout.Space();

            if (ga.CB_enabled)
            {
                EditorGUILayout.HelpBox("Ads are enabled (see the Ad Support tab).", MessageType.Info);
            }
                        #endif

                        #if UNITY_IPHONE
            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("Please refer to the iOS_Readme in the GameAnalytics/Plugins/iOS folder for information on how to setup the GA Unity SDK for iOS.", MessageType.Info);

            if (ga.IAD_enabled || ga.CB_enabled)
            {
                EditorGUILayout.HelpBox("Ads are enabled (see the Ad Support tab).", MessageType.Info);
            }
                        #endif

            /*GUILayout.BeginHorizontal();
             * GUILayout.Label("", GUILayout.Width(7));
             * GUILayout.Label(_useBundleVersion, GUILayout.Width(150));
             * ga.UseBundleVersion = EditorGUILayout.Toggle("", ga.UseBundleVersion);
             * GUILayout.EndHorizontal();*/
        }

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Debugging)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_debugMode, GUILayout.Width(150));
            ga.DebugMode = EditorGUILayout.Toggle("", ga.DebugMode);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_debugAddEvent, GUILayout.Width(150));
            ga.DebugAddEvent = EditorGUILayout.Toggle("", ga.DebugAddEvent);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_runInEditor, GUILayout.Width(150));
            ga.RunInEditorPlayMode = EditorGUILayout.Toggle("", ga.RunInEditorPlayMode);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_sendExampleToMyGame, GUILayout.Width(150));
            ga.SendExampleGameDataToMyGame = EditorGUILayout.Toggle("", ga.SendExampleGameDataToMyGame);
            GUILayout.EndHorizontal();
        }

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Pref)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_apiKeyLabel, GUILayout.Width(75));
            ga.ApiKey = EditorGUILayout.TextField("", ga.ApiKey);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_heatmapSizeLabel, GUILayout.Width(150));
            GUILayout.EndHorizontal();

                        #if UNITY_4_2 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0
            GUILayout.Space(-15);
                        #endif

            ga.HeatmapGridSize = EditorGUILayout.Vector3Field("", ga.HeatmapGridSize);
            if (ga.HeatmapGridSize != Vector3.one)
            {
                EditorGUILayout.HelpBox("Editing the heatmap grid size must be done BEFORE data is submitted, and you must use the same grid size when setting up your heatmaps. Otherwise the heatmap data will be incorrectly displayed.", MessageType.Warning);
            }

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_interval, GUILayout.Width(150));

            int tmpTimer = 0;
            if (int.TryParse(EditorGUILayout.TextField(ga.SubmitInterval.ToString(), GUILayout.Width(38)), out tmpTimer))
            {
                ga.SubmitInterval = Mathf.Max(Mathf.Min(tmpTimer, 999), 1);
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_customUserID, GUILayout.Width(150));
            ga.CustomUserID = EditorGUILayout.Toggle("", ga.CustomUserID);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_archiveData, GUILayout.Width(150));
            ga.ArchiveData = EditorGUILayout.Toggle("", ga.ArchiveData, GUILayout.Width(36));
            GUI.enabled    = ga.ArchiveData;
            GUILayout.Label(_archiveMaxSize, GUILayout.Width(40));

            int tmpMaxArchiveSize = 0;
            if (int.TryParse(EditorGUILayout.TextField(ga.ArchiveMaxFileSize.ToString(), GUILayout.Width(48)), out tmpMaxArchiveSize))
            {
                ga.ArchiveMaxFileSize = Mathf.Max(Mathf.Min(tmpMaxArchiveSize, 2000), 0);
            }

            GUI.enabled = true;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_allowRoaming, GUILayout.Width(150));
            ga.AllowRoaming = EditorGUILayout.Toggle("", ga.AllowRoaming);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_newSessionOnResume, GUILayout.Width(150));
            ga.NewSessionOnResume = EditorGUILayout.Toggle("", ga.NewSessionOnResume);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_autoSubmitUserInfo, GUILayout.Width(150));
            ga.AutoSubmitUserInfo = EditorGUILayout.Toggle("", ga.AutoSubmitUserInfo);
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }

        if (ga.CurrentInspectorState == GA_Settings.InspectorStates.Ads)
        {
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label("GameAnalytics Ad Support", EditorStyles.largeLabel);
            if (GUILayout.Button(_documentationLink, GUILayout.MaxWidth(60)))
            {
                Application.OpenURL("http://support.gameanalytics.com/hc/en-us/articles/200841376-The-GA-Settings-object#ad");
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("GameAnalytics Ad Support helps you show ads from different ad networks in your mobile games.", EditorStyles.miniLabel);

            EditorGUILayout.Space();
            Splitter(new Color(0.35f, 0.35f, 0.35f));

            //ga.IAD_foldout = EditorGUILayout.Foldout(ga.IAD_foldout, _iAd);

            GUILayout.BeginHorizontal();
            //GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label("", GUILayout.Width(-18));
            ga.IAD_enabled = EditorGUILayout.Toggle("", ga.IAD_enabled, GUILayout.Width(27));
            GUILayout.Label(_iAdenabled, GUILayout.Width(150));
            GUILayout.EndHorizontal();

            if (ga.IAD_enabled)
            {
                /*GUILayout.BeginHorizontal();
                 * GUILayout.Label("", GUILayout.Width(7));
                 * GUILayout.Label(_iAdenabled, GUILayout.Width(150));
                 * ga.IAD_enabled = EditorGUILayout.Toggle("", ga.IAD_enabled);
                 * GUILayout.EndHorizontal();
                 *
                 * GUI.enabled = ga.IAD_enabled;*/

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(7));
                GUILayout.Label(_iAdDuration, GUILayout.Width(150));
                ga.IAD_Duration = EditorGUILayout.FloatField(ga.IAD_Duration, GUILayout.Width(60));
                ga.IAD_Duration = Mathf.Max(0, ga.IAD_Duration);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(7));
                GUILayout.Label(_iAdtype, GUILayout.Width(150));
                ga.IAD_type = (ADBannerView.Type)EditorGUILayout.EnumPopup(ga.IAD_type, GUILayout.Width(125));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(7));
                GUILayout.Label(_iAdlayout, GUILayout.Width(150));
                ga.IAD_layout = (ADBannerView.Layout)EditorGUILayout.EnumPopup(ga.IAD_layout, GUILayout.Width(125));
                GUILayout.EndHorizontal();

                GUI.enabled = ga.IAD_enabled && ga.IAD_layout == ADBannerView.Layout.Manual;

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(7));
                GUILayout.Label(_iAdposition, GUILayout.Width(150));
                ga.IAD_position = EditorGUILayout.Vector2Field("", ga.IAD_position, GUILayout.Width(125));
                GUILayout.EndHorizontal();

                GUI.enabled = true;
            }

            Splitter(new Color(0.35f, 0.35f, 0.35f));

            //ga.CB_foldout = EditorGUILayout.Foldout(ga.CB_foldout, _CB);

            bool cb_status = ga.CB_enabled;

            GUILayout.BeginHorizontal();
            //GUILayout.Label("", GUILayout.Width(27));
            GUILayout.Label("", GUILayout.Width(-18));
            ga.CB_enabled = EditorGUILayout.Toggle("", ga.CB_enabled, GUILayout.Width(27));
            GUILayout.Label(_CBenabled, GUILayout.Width(150));
            GUILayout.EndHorizontal();

            if (cb_status != ga.CB_enabled)
            {
                if (ga.CB_enabled != ToggleCB())
                {
                    ga.CB_enabled = cb_status;
                }
            }

            if (ga.CB_enabled)
            {
                //GUI.enabled = ga.CB_enabled;

                                #if UNITY_ANDROID
                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(-5));
                EditorGUILayout.HelpBox("To setup Chartboost on Android please add your App ID and App Signature to the strings.xml file found in Plugins/Android/res/values/.", MessageType.Info);
                GUILayout.EndHorizontal();
                                #else
                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(7));
                GUILayout.Label(_CBappID, GUILayout.Width(150));
                ga.CB_appID = EditorGUILayout.TextField(ga.CB_appID);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(7));
                GUILayout.Label(_CBappSig, GUILayout.Width(150));
                ga.CB_appSig = EditorGUILayout.TextField(ga.CB_appSig);
                GUILayout.EndHorizontal();
                                #endif

                //GUI.enabled = true;
            }

            Splitter(new Color(0.35f, 0.35f, 0.35f));

            GUILayout.BeginHorizontal();
            GUILayout.Label(_startShowingAds, EditorStyles.largeLabel);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_startAlwaysShowAds, GUILayout.Width(150));
            ga.Start_AlwaysShowAds = EditorGUILayout.Toggle("", ga.Start_AlwaysShowAds);
            GUILayout.EndHorizontal();

            GUI.enabled = !ga.Start_AlwaysShowAds;

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_startTimePlayed, GUILayout.Width(150));
            ga.Start_TimePlayed = EditorGUILayout.Toggle("", ga.Start_TimePlayed, GUILayout.Width(27));
            GUILayout.Label("", GUILayout.Width(5));
            GUILayout.Label(_startTime, GUILayout.Width(55));
            ga.TimePlayed = EditorGUILayout.IntField(ga.TimePlayed, GUILayout.Width(60));
            ga.TimePlayed = Mathf.Max(0, ga.TimePlayed);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_startSessions, GUILayout.Width(150));
            ga.Start_Sessions = EditorGUILayout.Toggle("", ga.Start_Sessions, GUILayout.Width(27));
            GUILayout.Label("", GUILayout.Width(5));
            GUILayout.Label(_startSes, GUILayout.Width(55));
            ga.Sessions = EditorGUILayout.IntField(ga.Sessions, GUILayout.Width(60));
            ga.Sessions = Mathf.Max(0, ga.Sessions);
            GUILayout.EndHorizontal();

            GUI.enabled = true;

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label(_autoTriggers, EditorStyles.largeLabel);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_triggerAdsEnabled, GUILayout.Width(150));
            ga.Trigger_AdsEnabled = EditorGUILayout.Toggle("", ga.Trigger_AdsEnabled, GUILayout.Width(27));
            GUI.enabled           = ga.Trigger_AdsEnabled;
            GUILayout.Label("", GUILayout.Width(1));
            GUILayout.Label(_triggerAdNetwork, GUILayout.Width(55));
            if (ga.IAD_enabled && ga.CB_enabled)
            {
                ga.Trigger_AdsEnabled_network = (GA_AdSupport.GAAdNetwork)EditorGUILayout.EnumPopup(ga.Trigger_AdsEnabled_network, GUILayout.Width(80));
            }
            else
            {
                if (ga.IAD_enabled)
                {
                    ga.Trigger_AdsEnabled_network = GA_AdSupport.GAAdNetwork.iAd;
                }
                else if (ga.CB_enabled)
                {
                    ga.Trigger_AdsEnabled_network = GA_AdSupport.GAAdNetwork.Chartboost;
                }
                else
                {
                    ga.Trigger_AdsEnabled_network = GA_AdSupport.GAAdNetwork.Any;
                }

                GUILayout.Label("", GUILayout.Width(10));
                GUILayout.Label(ga.Trigger_AdsEnabled_network.ToString());
            }
            //GUILayout.Label("", GUILayout.Width(4));
            //CheckAdNetwork(ga, ga.Trigger_AdsEnabled_network);
            GUI.enabled = true;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            GUILayout.Label(_triggerSceneChange, GUILayout.Width(150));
            ga.Trigger_SceneChange = EditorGUILayout.Toggle("", ga.Trigger_SceneChange, GUILayout.Width(27));
            GUI.enabled            = ga.Trigger_SceneChange;
            GUILayout.Label("", GUILayout.Width(1));
            GUILayout.Label(_triggerAdNetwork, GUILayout.Width(55));
            if (ga.IAD_enabled && ga.CB_enabled)
            {
                ga.Trigger_SceneChange_network = (GA_AdSupport.GAAdNetwork)EditorGUILayout.EnumPopup(ga.Trigger_SceneChange_network, GUILayout.Width(80));
            }
            else
            {
                if (ga.IAD_enabled)
                {
                    ga.Trigger_SceneChange_network = GA_AdSupport.GAAdNetwork.iAd;
                }
                else if (ga.CB_enabled)
                {
                    ga.Trigger_SceneChange_network = GA_AdSupport.GAAdNetwork.Chartboost;
                }
                else
                {
                    ga.Trigger_SceneChange_network = GA_AdSupport.GAAdNetwork.Any;
                }

                GUILayout.Label("", GUILayout.Width(10));
                GUILayout.Label(ga.Trigger_SceneChange_network.ToString());
            }
            //GUILayout.Label("", GUILayout.Width(4));
            //CheckAdNetwork(ga, ga.Trigger_SceneChange_network);
            GUI.enabled = true;
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            GUILayout.Label(_customTriggers, EditorStyles.largeLabel);
            GUILayout.EndHorizontal();

            List <GA_CustomAdTrigger> triggersToRemove = new List <GA_CustomAdTrigger>();

            foreach (GA_CustomAdTrigger trigger in ga.CustomAdTriggers)
            {
                if (trigger != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("", GUILayout.Width(7));
                    if (GUILayout.Button("x", GUILayout.Width(19), GUILayout.Height(15)))
                    {
                        triggersToRemove.Add(trigger);
                    }
                    //GUILayout.Label("", GUILayout.Width(7));
                    GUILayout.Label(_triggerCustomID, GUILayout.Width(55));
                    trigger.eventID = EditorGUILayout.TextField(trigger.eventID);                    //, GUILayout.Width(125));
                    GUILayout.Label("", GUILayout.Width(1));
                    GUILayout.Label(_triggerCustomCat, GUILayout.Width(60));
                    trigger.eventCat = (GA_AdSupport.GAEventCat)EditorGUILayout.EnumPopup(trigger.eventCat, GUILayout.Width(80));
                    GUILayout.Label("", GUILayout.Width(1));
                    GUILayout.Label(_triggerAdNetwork, GUILayout.Width(55));
                    if (ga.IAD_enabled && ga.CB_enabled)
                    {
                        trigger.AdNetwork = (GA_AdSupport.GAAdNetwork)EditorGUILayout.EnumPopup(trigger.AdNetwork, GUILayout.Width(80));
                    }
                    else
                    {
                        if (ga.IAD_enabled)
                        {
                            trigger.AdNetwork = GA_AdSupport.GAAdNetwork.iAd;
                        }
                        else if (ga.CB_enabled)
                        {
                            trigger.AdNetwork = GA_AdSupport.GAAdNetwork.Chartboost;
                        }
                        else
                        {
                            trigger.AdNetwork = GA_AdSupport.GAAdNetwork.Any;
                        }

                        GUILayout.Label("", GUILayout.Width(10));
                        GUILayout.Label(trigger.AdNetwork.ToString());
                    }
                    //GUILayout.Label("", GUILayout.Width(4));
                    //CheckAdNetwork(ga, trigger.AdNetwork);
                    GUILayout.EndHorizontal();
                }
            }

            foreach (GA_CustomAdTrigger trigger in triggersToRemove)
            {
                ga.CustomAdTriggers.Remove(trigger);
                //ScriptableObject.DestroyImmediate(trigger);
            }

            GUILayout.Space(2);

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(7));
            if (GUILayout.Button("Add Trigger", GUILayout.Width(85)))
            {
                ga.CustomAdTriggers.Add(new GA_CustomAdTrigger());
                //ga.CustomAdTriggers.Add(ScriptableObject.CreateInstance<GA_CustomAdTrigger>());
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(ga);
        }
    }