Browse Source

change some setting
update StaticsManager
add oneway ads && VungleAds

gsgundam 8 years ago
parent
commit
c247e0ccb2

+ 14 - 14
Assets/Resource/Mobile/ICON2.png.meta

@@ -51,41 +51,41 @@ TextureImporter:
   textureFormatSet: 0
   platformSettings:
   - buildTarget: DefaultTexturePlatform
-    maxTextureSize: 2048
+    maxTextureSize: 1024
     textureFormat: -1
-    textureCompression: 1
+    textureCompression: 2
     compressionQuality: 50
     crunchedCompression: 0
     allowsAlphaSplitting: 0
     overridden: 0
   - buildTarget: Standalone
-    maxTextureSize: 2048
+    maxTextureSize: 1024
     textureFormat: -1
-    textureCompression: 1
+    textureCompression: 2
     compressionQuality: 50
     crunchedCompression: 0
     allowsAlphaSplitting: 0
     overridden: 0
   - buildTarget: iPhone
-    maxTextureSize: 2048
-    textureFormat: -1
-    textureCompression: 1
+    maxTextureSize: 512
+    textureFormat: 4
+    textureCompression: 2
     compressionQuality: 50
     crunchedCompression: 0
     allowsAlphaSplitting: 0
-    overridden: 0
+    overridden: 1
   - buildTarget: Android
-    maxTextureSize: 2048
-    textureFormat: -1
-    textureCompression: 1
+    maxTextureSize: 512
+    textureFormat: 4
+    textureCompression: 2
     compressionQuality: 50
     crunchedCompression: 0
     allowsAlphaSplitting: 0
-    overridden: 0
+    overridden: 1
   - buildTarget: WebGL
-    maxTextureSize: 2048
+    maxTextureSize: 1024
     textureFormat: -1
-    textureCompression: 1
+    textureCompression: 2
     compressionQuality: 50
     crunchedCompression: 0
     allowsAlphaSplitting: 0

+ 17 - 0
Assets/Script/Editor/EditorPlayerBuilder.cs

@@ -68,6 +68,7 @@ public class BuildForAllPlatforms : EditorWindow
 		);
 
 		UpdateInfo();
+		OpenFolder(path + "/win32");
 	}
 
 	public static void BuildOSX64()
@@ -93,6 +94,7 @@ public class BuildForAllPlatforms : EditorWindow
 		);
 
 		UpdateInfo();
+		OpenFolder(path + "/osx64");
 	}
 
 	public static void BuildiOS()
@@ -124,6 +126,7 @@ public class BuildForAllPlatforms : EditorWindow
 		);
 
 		UpdateInfo();
+		OpenFolder(path + "/ios");
 	}
 
 	public static void BuildiOSDebug()
@@ -155,6 +158,7 @@ public class BuildForAllPlatforms : EditorWindow
 		);
 
 		UpdateInfo();
+		OpenFolder(path + "/ios");
 	}
 
 	public static void BuildAndroid()
@@ -191,6 +195,8 @@ public class BuildForAllPlatforms : EditorWindow
 		);
 
 		UpdateInfo();
+
+		OpenFolder(path + "/android");	
 	}
 
 	private static string[] GetLevelPaths()
@@ -212,4 +218,15 @@ public class BuildForAllPlatforms : EditorWindow
 		PlayerSettings.Android.bundleVersionCode = versionCode;
 		PlayerSettings.bundleVersion = version;
 	}
+
+	private static void OpenFolder(string dir){
+		Application.OpenURL(dir);
+	}
+
+	void OnInspectorUpdate()
+	{
+		versionCode = PlayerSettings.Android.bundleVersionCode;
+		version = PlayerSettings.bundleVersion;
+	    this.Repaint();
+	}
 }

+ 20 - 1
Assets/Script/Manage/ManaIAP.cs

@@ -70,6 +70,20 @@ public class ManaIAP : MonoBehaviour, IStoreListener
         {
             Advertisement.Initialize("1408493", false);
         }
+
+        //初始化vungle
+        VungleAdsManager.Instance.Init(()=>{
+            AdAction.Invoke();
+
+            ManaCenter.AdAmt++;
+        });
+
+        //初始化OneWay
+        OneWayAdsManager.Instance.Init(()=>{
+            AdAction.Invoke();
+
+            ManaCenter.AdAmt++;
+        });
     }
 
     public static void InitializeIAP()
@@ -111,7 +125,12 @@ public class ManaIAP : MonoBehaviour, IStoreListener
         }
         else
         {
-            Bubble.Show(null, Language.GetStr("IAP", "LoadAd"));
+            // Bubble.Show(null, Language.GetStr("IAP", "LoadAd"));
+            //Unity广告加载失败,自动加载vungle广告,并且再次初始化unity广告
+            if(VungleAdsManager.Instance.CheckAd())
+                VungleAdsManager.Instance.PlayAd();
+            else
+                OneWayAdsManager.Instance.PlayAd();
 
             if (!Advertisement.isInitialized)
             {

+ 9 - 0
Assets/Script/ThirdParty.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 768c0afdf325567409f18f8a72ab19b3
+folderAsset: yes
+timeCreated: 1501174929
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 42 - 0
Assets/Script/ThirdParty/DataEyeStatics/DataEyeGA.cs

@@ -150,6 +150,9 @@ public class DataEyeGA
 
     public static void SetAccount(string accountId, AccountType accountType, bool sendOnline = false)
     {
+        if(!CheckIsInited())
+            return;
+
         DataEyeGA.accountId = accountId;
         DataEyeGA.accountType = accountType.GetHashCode();
         if(sendOnline)
@@ -160,6 +163,9 @@ public class DataEyeGA
 
     public static void ActOrReg()
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("actTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
         paramList.Add(new KeyValuePair<string, string>("regTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
@@ -168,6 +174,9 @@ public class DataEyeGA
 
     public static void Online(int level = 0)
     {
+        if(!CheckIsInited())
+            return;
+
         if (DateUtil.GetRealTimeSinceStart() <= 60)
             return;
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
@@ -184,6 +193,9 @@ public class DataEyeGA
     /// <param name="orderId">订单ID</param>
     public static void Pay(int currencyAmount, string currencyType, string iapid, string orderId)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("currencyAmount", currencyAmount.ToString()));
         paramList.Add(new KeyValuePair<string, string>("currencyType", currencyType));
@@ -200,6 +212,9 @@ public class DataEyeGA
     /// <param name="totalCoin">该玩家手里最终持有的货币数量</param>
     public static void VirtualCurrency(int coinNum, string coinType, string type, bool isGain, int totalCoin)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("coinNum", coinNum.ToString()));
         paramList.Add(new KeyValuePair<string, string>("coinType", coinType));
@@ -217,6 +232,9 @@ public class DataEyeGA
     /// <param name="coinType">虚拟币种类</param>
     public static void BuyItem(string itemId, string itemType, string itemCnt, int coinNum, string coinType)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("itemId", itemId));
         paramList.Add(new KeyValuePair<string, string>("itemType", itemType));
@@ -233,6 +251,9 @@ public class DataEyeGA
     /// <param name="reason">道具消耗的途径</param>
     public static void UseItem(string itemId, string itemType, string itemCnt, string reason)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("itemId", itemId));
         paramList.Add(new KeyValuePair<string, string>("itemType", itemType));
@@ -248,6 +269,9 @@ public class DataEyeGA
     /// <param name="reason">道具获得的途径</param>
     public static void GetItem(string itemId, string itemType, int itemCnt, string reason)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("itemId", itemId));
         paramList.Add(new KeyValuePair<string, string>("itemType", itemType));
@@ -264,6 +288,9 @@ public class DataEyeGA
     /// <param name="reason">任务失败原因</param>
     public static void Task(string taskId, TaskType taskType, int duration, bool isSucc, string reason)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("taskId", taskId));
         paramList.Add(new KeyValuePair<string, string>("taskType", taskType.GetHashCode().ToString()));
@@ -279,6 +306,9 @@ public class DataEyeGA
     /// <param name="interval">升级时长(秒)</param>
     public static void LevelUp(int startLevel, int endLevel, int interval)
     {
+        if(!CheckIsInited())
+            return;
+
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("startLevel", startLevel.ToString()));
         paramList.Add(new KeyValuePair<string, string>("endLevel", endLevel.ToString()));
@@ -295,6 +325,9 @@ public class DataEyeGA
     /// <param name="keyValueList">参数列表</param>
     public static void CustomEvent(string eventId, int duration, List<KeyValuePair<string, string>> labelMapList)
     {
+        if(!CheckIsInited())
+            return;
+            
         List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
         paramList.Add(new KeyValuePair<string, string>("eventId", eventId));
         paramList.Add(new KeyValuePair<string, string>("duration", duration.ToString()));
@@ -306,6 +339,15 @@ public class DataEyeGA
         SendUrl(RequestType.CustomEvent, paramList);
     }
 
+    private static bool CheckIsInited(){
+        if(isInited)
+            return true;
+        else{
+            Debug.Log("<color=#ff6600>DataEyeGA is not Inited!</color>");
+            return false;
+        }
+    }
+
     private static string SendUrl(RequestType requestType, List<KeyValuePair<string, string>> specialParamList = null)
     {
         string url = urlPrefix + requestDict[requestType];

+ 8 - 0
Assets/Script/ThirdParty/DataEyeStatics/StaticsManager.cs

@@ -350,6 +350,14 @@ public class StaticsManager
         DataEyeGA.CustomEvent("点击广告", 0, new List<KeyValuePair<string, string>>());
     }
 
+    /// <summary>
+    /// 成功播放的广告来源
+    /// </summary>
+    /// <param name="id">类型id:0为UnityAds,1为Vungle,2为OneWay</param>
+    public void AdChannel(int id){
+        DataEyeGA.CustomEvent("播放广告-"+id, 0, new List<KeyValuePair<string, string>>());
+    }
+
     public void AdFinished(){
         DataEyeGA.CustomEvent("广告播放完毕", 0, new List<KeyValuePair<string, string>>());
     }

+ 9 - 0
Assets/Script/ThirdParty/OneWayAds.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 9c598444bc01ef94788d24c0ccfa547a
+folderAsset: yes
+timeCreated: 1501180966
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 40 - 0
Assets/Script/ThirdParty/OneWayAds/OneWayAdsManager.cs

@@ -0,0 +1,40 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class OneWayAdsManager : UnitySingleton<OneWayAdsManager> {
+
+	public void Init(System.Action finishCallback)
+	{
+		OneWaySDK.init ("jczhy6gxwak795kp", "90lvj6k3ev5zhdrg", true);
+		Debug.Log("OneWay Inited");
+
+		InitializeEventHandlers();
+	}
+
+	public void PlayAd(){
+		Debug.Log("OneWay play ad");
+		OneWaySDK.show();
+	}
+
+	private void InitializeEventHandlers() {
+
+        OneWaySDK.onOneWaySDKReadyEvent += ( placement ) =>{
+			Debug.Log ("OneWaySDK is Ready for placement: " + placement);
+		};
+
+
+		OneWaySDK.onOneWaySDKDidStartEvent += ( placement ) =>{
+			Debug.Log ("OneWaySDK start to show placement: " + placement);
+		};
+
+		OneWaySDK.onOneWaySDKDidFinishEvent += ( placement ,state) =>{
+			Debug.Log ("OneWaySDK Finished placement " + placement +"finish state is :" + state);
+		};
+
+		OneWaySDK.onOneWaySDKDidErrorEvent += ( err, msg) =>{
+			Debug.Log ("OneWaySDK is err: " + err + ",message:" + msg);
+		};
+    }
+
+}

+ 12 - 0
Assets/Script/ThirdParty/OneWayAds/OneWayAdsManager.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 166394882bfdd30408020fb032766446
+timeCreated: 1501174954
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Assets/Script/ThirdParty/VungleAds.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 4b1e2bbc9116c56449e336c48141d5cc
+folderAsset: yes
+timeCreated: 1501174940
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 97 - 0
Assets/Script/ThirdParty/VungleAds/VungleAdsManager.cs

@@ -0,0 +1,97 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class VungleAdsManager : UnitySingleton<VungleAdsManager> {
+
+	private string appID = "";
+	private string placementID = "";
+	private bool adInited = false;
+	private System.Action finishCallback = null;
+
+	Dictionary<string, bool> placements = new Dictionary<string, bool>();
+
+	public void Init(System.Action finishCallback)
+	{
+#if UNITY_IPHONE
+		appID = "597a18ac6f7cda15620033e1";
+		placementID = "DEFAULT19439";
+		placements = new Dictionary<string, bool>
+		{
+			{ placementID, false }
+		};
+#elif UNITY_ANDROID
+		appID = "597a181605724327620031ed";
+		placementID = "DEFAULT72579";
+		placements = new Dictionary<string, bool>
+		{
+			{ placementID, false }
+		};
+#endif
+		string[] array = new string[placements.Keys.Count];
+		placements.Keys.CopyTo(array, 0);
+		Vungle.init(appID, array);
+		Debug.Log("Vungle Inited. appID is "+appID);
+
+		this.finishCallback = finishCallback;
+		InitializeEventHandlers();
+	}
+
+	public void LoadAd(){
+  		Vungle.loadAd(placementID);
+		Debug.Log("Vungle load ad ");
+	}
+
+	public bool CheckAd(){
+		Debug.Log("Vungle isAdvertAvailable is "+Vungle.isAdvertAvailable(placementID));
+		return Vungle.isAdvertAvailable(placementID);
+	}
+
+	public void PlayAd(){
+		Vungle.playAd(placementID);
+		Debug.Log("Vungle play ad");
+	}
+
+	private void InitializeEventHandlers() {
+
+        Vungle.onAdStartedEvent += (placementID) => {
+            Debug.Log ("Ad " + placementID + " is starting!  Pause your game  animation or sound here.");
+        };
+
+        Vungle.onAdFinishedEvent += (placementID, args) => {
+            Debug.Log ("Ad finished - placementID " + placementID + ", was call to action clicked:" + args.WasCallToActionClicked +  ", is completed view:"
+                      + args.IsCompletedView);
+			if(args.IsCompletedView && finishCallback != null)
+				finishCallback();
+        };
+
+        Vungle.adPlayableEvent += (placementID, adPlayable) => {
+            Debug.Log ("Ad's playable state has been changed! placementID " + placementID + ". Now: " + adPlayable);
+        };
+
+        Vungle.onLogEvent += (log) => {
+            Debug.Log ("Log: " + log);
+        };
+
+        Vungle.onInitializeEvent += () => {
+            adInited = true;
+            Debug.Log ("SDK initialized");
+			//自动加载广告
+			LoadAd();
+        };
+    }
+
+	public bool IsAdInited(){
+		return adInited;
+	}
+
+	void OnApplicationPause(bool pauseStatus) {
+		if (pauseStatus) {
+			Vungle.onPause();
+		}
+		else {
+			Vungle.onResume();
+		}
+	}
+
+}

+ 12 - 0
Assets/Script/ThirdParty/VungleAds/VungleAdsManager.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 8de080a07754cb044a074ea9188442f8
+timeCreated: 1501174954
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: