增加一个SDK
This commit is contained in:
parent
399374dc6c
commit
b6bf5df071
@ -33,8 +33,10 @@ namespace BF
|
||||
BFLog.Log("unity-script: IronSource.Agent.init");
|
||||
IronSource.Agent.init(appKey);
|
||||
IronSource.Agent.setManualLoadRewardedVideo(true);
|
||||
IronSourceAdQuality.Initialize(appKey);
|
||||
#elif UNITY_IPHONE
|
||||
// string appKey = "8545d445";
|
||||
// IronSourceAdQuality.Initialize(appKey);
|
||||
#else
|
||||
// string appKey = "unexpected_platform";
|
||||
#endif
|
||||
|
||||
8
Assets/ThirdParty/IronSourceAdQuality.meta
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd642f9c5d7126f47898e5dc9520a8ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/ThirdParty/IronSourceAdQuality/Editor.meta
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality/Editor.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ee27eb8be2558e4482bcaa12bbd4781
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/ThirdParty/IronSourceAdQuality/Editor/IronSourceAdQualityDependencies.xml
vendored
Normal file
36
Assets/ThirdParty/IronSourceAdQuality/Editor/IronSourceAdQualityDependencies.xml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
<dependencies>
|
||||
<unityversion>7.13.0</unityversion>
|
||||
|
||||
<androidPackages>
|
||||
<androidPackage spec="com.ironsource:adqualitysdk:7.13.0">
|
||||
<repositories>
|
||||
<repository>https://android-sdk.is.com/</repository>
|
||||
</repositories>
|
||||
</androidPackage>
|
||||
</androidPackages>
|
||||
|
||||
<androidPackages>
|
||||
<androidPackage spec="com.ironsource.unity:adqualitysdk:7.13.0">
|
||||
<repositories>
|
||||
<repository>https://android-sdk.is.com/</repository>
|
||||
</repositories>
|
||||
</androidPackage>
|
||||
</androidPackages>
|
||||
|
||||
<!-- <iosPods>
|
||||
<iosPod name="IronSourceAdQualitySDK" version="7.13.0">
|
||||
<sources>
|
||||
<source>https://github.com/CocoaPods/Specs</source>
|
||||
</sources>
|
||||
</iosPod>
|
||||
</iosPods>
|
||||
|
||||
<iosPods>
|
||||
<iosPod name="IronSourceAdQualityUnityBridge" version="7.13.0">
|
||||
<sources>
|
||||
<source>https://github.com/CocoaPods/Specs</source>
|
||||
</sources>
|
||||
</iosPod>
|
||||
</iosPods> -->
|
||||
|
||||
</dependencies>
|
||||
7
Assets/ThirdParty/IronSourceAdQuality/Editor/IronSourceAdQualityDependencies.xml.meta
vendored
Normal file
7
Assets/ThirdParty/IronSourceAdQuality/Editor/IronSourceAdQualityDependencies.xml.meta
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0caf106b327a046c5b374834523d4477
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/ThirdParty/IronSourceAdQuality/Scripts.meta
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality/Scripts.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c104a6ee5617fb048acdd3b2f1cbc512
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality.meta
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae460004d99634df8a86e07e1a01faa5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
6
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISADQualityDeviceIdType.cs
vendored
Normal file
6
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISADQualityDeviceIdType.cs
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
using System;
|
||||
public enum ISAdQualityDeviceIdType {
|
||||
NONE = 0,
|
||||
GAID = 1,
|
||||
IDFA = 2
|
||||
};
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISADQualityDeviceIdType.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISADQualityDeviceIdType.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92d1c3826af024ff1a77c6c7d7983c7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAdType.cs
vendored
Normal file
16
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAdType.cs
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
public enum ISAdQualityAdType {
|
||||
UNKNOWN = -1,
|
||||
RICH_MEDIA = 0,
|
||||
INTERSTITIAL = 1,
|
||||
APP_WALL = 2,
|
||||
VIDEO = 3,
|
||||
REWARDED_VIDEO = 4,
|
||||
NATIVE = 5,
|
||||
BANNER = 6,
|
||||
OFFER_WALL = 7,
|
||||
NATIVE_HTML = 8,
|
||||
EXTERNAL = 9,
|
||||
REWARDED = 10,
|
||||
INTERACTIVE = 11
|
||||
};
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAdType.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAdType.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08e1a7bef35354a1883fab85829a4273
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAndroidInitHandler.cs
vendored
Normal file
53
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAndroidInitHandler.cs
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
#if UNITY_ANDROID
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class ISAdQualityAndroidInitHandler : AndroidJavaProxy
|
||||
{
|
||||
private const string IRON_SOURCE_AD_QUALITY_CLASS = "com.ironsource.adqualitysdk.sdk.unity.IronSourceAdQuality";
|
||||
private const string UNITY_IS_AD_QUALITY_INIT_LISTENER = "com.ironsource.adqualitysdk.sdk.unity.UnityISAdQualityInitListener";
|
||||
|
||||
public event Action OnAdQualitySdkInitSuccess = delegate { };
|
||||
public event Action<ISAdQualityInitError, string> OnAdQualitySdkInitFailed = delegate { };
|
||||
|
||||
//implements UnityISAdQualityInitListener java interface
|
||||
public ISAdQualityAndroidInitHandler(): base(UNITY_IS_AD_QUALITY_INIT_LISTENER)
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
try
|
||||
{
|
||||
using (var jniAdQualityClass = new AndroidJavaClass(IRON_SOURCE_AD_QUALITY_CLASS))
|
||||
{
|
||||
jniAdQualityClass.CallStatic("setUnityISAdQualityInitListener", this);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Debug.LogError("setUnityISAdQualityInitListener method doesn't exist, error: " + e.Message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
[Preserve]
|
||||
public void adQualitySdkInitSuccess()
|
||||
{
|
||||
if (this.OnAdQualitySdkInitSuccess != null)
|
||||
{
|
||||
this.OnAdQualitySdkInitSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Preserve]
|
||||
public void adQualitySdkInitFailed(int adQualitySdkInitError, string errorMessage)
|
||||
{
|
||||
if (this.OnAdQualitySdkInitFailed != null)
|
||||
{
|
||||
this.OnAdQualitySdkInitFailed((ISAdQualityInitError)adQualitySdkInitError, errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAndroidInitHandler.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityAndroidInitHandler.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c70eb41427c4848d391fa9e66f60daf3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
118
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityConfig.cs
vendored
Normal file
118
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityConfig.cs
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ISAdQualityConfig
|
||||
{
|
||||
private String userId;
|
||||
private bool userIdSet;
|
||||
private bool testMode;
|
||||
private ISAdQualityInitCallback adQualityInitCallback;
|
||||
private ISAdQualityLogLevel logLevel;
|
||||
private String initializationSource;
|
||||
private bool coppa;
|
||||
private ISAdQualityDeviceIdType deviceIdType;
|
||||
|
||||
public ISAdQualityConfig()
|
||||
{
|
||||
userId = null;
|
||||
testMode = false;
|
||||
userIdSet = false;
|
||||
logLevel = ISAdQualityLogLevel.INFO;
|
||||
coppa = false;
|
||||
deviceIdType = ISAdQualityDeviceIdType.NONE;
|
||||
initializationSource = null;
|
||||
}
|
||||
|
||||
public String UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
set
|
||||
{
|
||||
userIdSet = true;
|
||||
userId = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool UserIdSet
|
||||
{
|
||||
get
|
||||
{
|
||||
return userIdSet;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TestMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return testMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
testMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ISAdQualityLogLevel LogLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return logLevel;
|
||||
}
|
||||
set
|
||||
{
|
||||
logLevel = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ISAdQualityInitCallback AdQualityInitCallback
|
||||
{
|
||||
get
|
||||
{
|
||||
return adQualityInitCallback;
|
||||
}
|
||||
set
|
||||
{
|
||||
adQualityInitCallback = value;
|
||||
}
|
||||
}
|
||||
|
||||
public String InitializationSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return initializationSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
initializationSource = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Coppa
|
||||
{
|
||||
get
|
||||
{
|
||||
return coppa;
|
||||
}
|
||||
set
|
||||
{
|
||||
coppa = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ISAdQualityDeviceIdType DeviceIdType
|
||||
{
|
||||
get
|
||||
{
|
||||
return deviceIdType;
|
||||
}
|
||||
set
|
||||
{
|
||||
deviceIdType = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityConfig.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityConfig.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ee3acefb6d46481191afc81fb1e4865
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
66
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityCustomMediationRevenue.cs
vendored
Normal file
66
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityCustomMediationRevenue.cs
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ISAdQualityCustomMediationRevenue
|
||||
{
|
||||
private ISAdQualityMediationNetwork mediationNetwork;
|
||||
private ISAdQualityAdType adType;
|
||||
private double revenue;
|
||||
private String placement;
|
||||
|
||||
public ISAdQualityCustomMediationRevenue()
|
||||
{
|
||||
mediationNetwork = ISAdQualityMediationNetwork.UNKNOWN;
|
||||
adType = ISAdQualityAdType.UNKNOWN;
|
||||
revenue = 0;
|
||||
placement = null;
|
||||
}
|
||||
|
||||
public ISAdQualityMediationNetwork MediationNetwork
|
||||
{
|
||||
get
|
||||
{
|
||||
return mediationNetwork;
|
||||
}
|
||||
set
|
||||
{
|
||||
mediationNetwork = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ISAdQualityAdType AdType
|
||||
{
|
||||
get
|
||||
{
|
||||
return adType;
|
||||
}
|
||||
set
|
||||
{
|
||||
adType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double Revenue
|
||||
{
|
||||
get
|
||||
{
|
||||
return revenue;
|
||||
}
|
||||
set
|
||||
{
|
||||
revenue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public String Placement
|
||||
{
|
||||
get
|
||||
{
|
||||
return placement;
|
||||
}
|
||||
set
|
||||
{
|
||||
placement = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bb7937cdf9c640cf8ee92ed1fa34227
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallback.cs
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallback.cs
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public interface ISAdQualityInitCallback
|
||||
{
|
||||
void adQualitySdkInitSuccess();
|
||||
void adQualitySdkInitFailed(ISAdQualityInitError adQualityInitError, string errorMessage);
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallback.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallback.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 894fc956cbe6c43e385333baa4651e56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallbackWrapper.cs
vendored
Normal file
88
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallbackWrapper.cs
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class ISAdQualityInitCallbackWrapper : MonoBehaviour
|
||||
{
|
||||
private ISAdQualityInitCallback mCallback;
|
||||
|
||||
#if UNITY_ANDROID
|
||||
private ISAdQualityAndroidInitHandler adQualityAndroidInitHandler;
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE || UNITY_IOS
|
||||
private ISAdQualityiOSInitHandler adQualityiOSInitHandler;
|
||||
#endif
|
||||
|
||||
public ISAdQualityInitCallback AdQualityInitCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
mCallback = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return mCallback;
|
||||
}
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
adQualityAndroidInitHandler = new ISAdQualityAndroidInitHandler(); //sets this.adQualityAndroidInitHandler as listener for init events on the bridge
|
||||
registerAdQualityAndroidInitEvents();
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE || UNITY_IOS
|
||||
registerAdQualityiOSInitEvents();
|
||||
adQualityiOSInitHandler = new ISAdQualityiOSInitHandler(); //sets this.adQualityiOSInit as listener for init events on the bridge
|
||||
#endif
|
||||
DontDestroyOnLoad(gameObject); //Makes the object not be destroyed automatically when loading a new scene.
|
||||
}
|
||||
|
||||
private void adQualitySdkInitSuccess()
|
||||
{
|
||||
if (mCallback != null)
|
||||
{
|
||||
mCallback.adQualitySdkInitSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
private void onAdQualitySdkInitFailed(ISAdQualityInitError sdkInitError, string errorMsg)
|
||||
{
|
||||
if (mCallback != null)
|
||||
{
|
||||
mCallback.adQualitySdkInitFailed(sdkInitError, errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//subscribe to ISAdQualityAndroidInitHandler events
|
||||
private void registerAdQualityAndroidInitEvents() {
|
||||
adQualityAndroidInitHandler.OnAdQualitySdkInitSuccess += () =>
|
||||
{
|
||||
adQualitySdkInitSuccess();
|
||||
};
|
||||
|
||||
adQualityAndroidInitHandler.OnAdQualitySdkInitFailed += (sdkInitError, errorMsg) =>
|
||||
{
|
||||
onAdQualitySdkInitFailed(sdkInitError, errorMsg);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE || UNITY_IOS
|
||||
//subscribe to ISAdQualityiOSInitHandler events
|
||||
private void registerAdQualityiOSInitEvents() {
|
||||
ISAdQualityiOSInitHandler.OnAdQualitySdkInitSuccess += () =>
|
||||
{
|
||||
adQualitySdkInitSuccess();
|
||||
};
|
||||
|
||||
ISAdQualityiOSInitHandler.OnAdQualitySdkInitFailed += (sdkInitError, errorMsg) =>
|
||||
{
|
||||
onAdQualitySdkInitFailed(sdkInitError, errorMsg);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallbackWrapper.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitCallbackWrapper.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f5c838c5a8ff40529569d29728deec4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitError.cs
vendored
Normal file
14
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitError.cs
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
public enum ISAdQualityInitError {
|
||||
AD_QUALITY_SDK_WAS_SHUTDOWN = 0,
|
||||
ILLEGAL_USER_ID = 1,
|
||||
ILLEGAL_APP_KEY = 2,
|
||||
EXCEPTION_ON_INIT = 3,
|
||||
NO_NETWORK_CONNECTION = 4,
|
||||
CONFIG_LOAD_TIMEOUT = 5,
|
||||
CONNECTOR_LOAD_TIMEOUT = 6,
|
||||
AD_NETWORK_VERSION_NOT_SUPPORTED_YET = 7,
|
||||
AD_NETWORK_SDK_REQUIRES_NEWER_AD_QUALITY_SDK = 8,
|
||||
AD_QUALITY_ALREADY_INITIALIZED = 9
|
||||
};
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitError.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityInitError.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6da8d8e07e45042f197fc5f6304a9d62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
495
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityJSON.cs
vendored
Normal file
495
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityJSON.cs
vendored
Normal file
@ -0,0 +1,495 @@
|
||||
/*
|
||||
* Based on the miniJSON by Calvin Rien
|
||||
*/
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ISAdQualityJSON
|
||||
{
|
||||
public static class Json
|
||||
{
|
||||
public static object Deserialize (string json)
|
||||
{
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
return Parser.Parse (json);
|
||||
}
|
||||
|
||||
sealed class Parser : IDisposable
|
||||
{
|
||||
const string WHITE_SPACE = " \t\n\r";
|
||||
const string WORD_BREAK = " \t\n\r{}[],:\"";
|
||||
|
||||
enum TOKEN
|
||||
{
|
||||
NONE,
|
||||
CURLY_OPEN,
|
||||
CURLY_CLOSE,
|
||||
SQUARED_OPEN,
|
||||
SQUARED_CLOSE,
|
||||
COLON,
|
||||
COMMA,
|
||||
STRING,
|
||||
NUMBER,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL
|
||||
}
|
||||
;
|
||||
|
||||
StringReader json;
|
||||
|
||||
Parser (string jsonString)
|
||||
{
|
||||
json = new StringReader (jsonString);
|
||||
}
|
||||
|
||||
public static object Parse (string jsonString)
|
||||
{
|
||||
using (var instance = new Parser(jsonString)) {
|
||||
return instance.ParseValue ();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
json.Dispose ();
|
||||
json = null;
|
||||
}
|
||||
|
||||
Dictionary<string, object> ParseObject ()
|
||||
{
|
||||
Dictionary<string, object> table = new Dictionary<string, object> ();
|
||||
|
||||
// ditch opening brace
|
||||
json.Read ();
|
||||
|
||||
// {
|
||||
while (true) {
|
||||
switch (NextToken) {
|
||||
case TOKEN.NONE:
|
||||
return null;
|
||||
case TOKEN.COMMA:
|
||||
continue;
|
||||
case TOKEN.CURLY_CLOSE:
|
||||
return table;
|
||||
default:
|
||||
// name
|
||||
string name = ParseString ();
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// :
|
||||
if (NextToken != TOKEN.COLON) {
|
||||
return null;
|
||||
}
|
||||
// ditch the colon
|
||||
json.Read ();
|
||||
|
||||
// value
|
||||
table [name] = ParseValue ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<object> ParseArray ()
|
||||
{
|
||||
List<object> array = new List<object> ();
|
||||
|
||||
// ditch opening bracket
|
||||
json.Read ();
|
||||
|
||||
// [
|
||||
var parsing = true;
|
||||
while (parsing) {
|
||||
TOKEN nextToken = NextToken;
|
||||
|
||||
switch (nextToken) {
|
||||
case TOKEN.NONE:
|
||||
return null;
|
||||
case TOKEN.COMMA:
|
||||
continue;
|
||||
case TOKEN.SQUARED_CLOSE:
|
||||
parsing = false;
|
||||
break;
|
||||
default:
|
||||
object value = ParseByToken (nextToken);
|
||||
|
||||
array.Add (value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
object ParseValue ()
|
||||
{
|
||||
TOKEN nextToken = NextToken;
|
||||
return ParseByToken (nextToken);
|
||||
}
|
||||
|
||||
object ParseByToken (TOKEN token)
|
||||
{
|
||||
switch (token) {
|
||||
case TOKEN.STRING:
|
||||
return ParseString ();
|
||||
case TOKEN.NUMBER:
|
||||
return ParseNumber ();
|
||||
case TOKEN.CURLY_OPEN:
|
||||
return ParseObject ();
|
||||
case TOKEN.SQUARED_OPEN:
|
||||
return ParseArray ();
|
||||
case TOKEN.TRUE:
|
||||
return true;
|
||||
case TOKEN.FALSE:
|
||||
return false;
|
||||
case TOKEN.NULL:
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string ParseString ()
|
||||
{
|
||||
StringBuilder s = new StringBuilder ();
|
||||
char c;
|
||||
|
||||
// ditch opening quote
|
||||
json.Read ();
|
||||
|
||||
bool parsing = true;
|
||||
while (parsing) {
|
||||
|
||||
if (json.Peek () == -1) {
|
||||
parsing = false;
|
||||
break;
|
||||
}
|
||||
|
||||
c = NextChar;
|
||||
switch (c) {
|
||||
case '"':
|
||||
parsing = false;
|
||||
break;
|
||||
case '\\':
|
||||
if (json.Peek () == -1) {
|
||||
parsing = false;
|
||||
break;
|
||||
}
|
||||
|
||||
c = NextChar;
|
||||
switch (c) {
|
||||
case '"':
|
||||
case '\\':
|
||||
case '/':
|
||||
s.Append (c);
|
||||
break;
|
||||
case 'b':
|
||||
s.Append ('\b');
|
||||
break;
|
||||
case 'f':
|
||||
s.Append ('\f');
|
||||
break;
|
||||
case 'n':
|
||||
s.Append ('\n');
|
||||
break;
|
||||
case 'r':
|
||||
s.Append ('\r');
|
||||
break;
|
||||
case 't':
|
||||
s.Append ('\t');
|
||||
break;
|
||||
case 'u':
|
||||
var hex = new StringBuilder ();
|
||||
|
||||
for (int i=0; i< 4; i++) {
|
||||
hex.Append (NextChar);
|
||||
}
|
||||
|
||||
s.Append ((char)Convert.ToInt32 (hex.ToString (), 16));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
s.Append (c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return s.ToString ();
|
||||
}
|
||||
|
||||
object ParseNumber ()
|
||||
{
|
||||
string number = NextWord;
|
||||
|
||||
if (number.IndexOf ('.') == -1) {
|
||||
long parsedInt;
|
||||
Int64.TryParse (number, NumberStyles.Any, CultureInfo.InvariantCulture, out parsedInt);
|
||||
return parsedInt;
|
||||
}
|
||||
|
||||
double parsedDouble;
|
||||
Double.TryParse (number, NumberStyles.Any, CultureInfo.InvariantCulture, out parsedDouble);
|
||||
return parsedDouble;
|
||||
}
|
||||
|
||||
void EatWhitespace ()
|
||||
{
|
||||
while (WHITE_SPACE.IndexOf(PeekChar) != -1) {
|
||||
json.Read ();
|
||||
|
||||
if (json.Peek () == -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char PeekChar {
|
||||
get {
|
||||
return Convert.ToChar (json.Peek ());
|
||||
}
|
||||
}
|
||||
|
||||
char NextChar {
|
||||
get {
|
||||
return Convert.ToChar (json.Read ());
|
||||
}
|
||||
}
|
||||
|
||||
string NextWord {
|
||||
get {
|
||||
StringBuilder word = new StringBuilder ();
|
||||
|
||||
while (WORD_BREAK.IndexOf(PeekChar) == -1) {
|
||||
word.Append (NextChar);
|
||||
|
||||
if (json.Peek () == -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return word.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
TOKEN NextToken {
|
||||
get {
|
||||
EatWhitespace ();
|
||||
|
||||
if (json.Peek () == -1) {
|
||||
return TOKEN.NONE;
|
||||
}
|
||||
|
||||
char c = PeekChar;
|
||||
switch (c) {
|
||||
case '{':
|
||||
return TOKEN.CURLY_OPEN;
|
||||
case '}':
|
||||
json.Read ();
|
||||
return TOKEN.CURLY_CLOSE;
|
||||
case '[':
|
||||
return TOKEN.SQUARED_OPEN;
|
||||
case ']':
|
||||
json.Read ();
|
||||
return TOKEN.SQUARED_CLOSE;
|
||||
case ',':
|
||||
json.Read ();
|
||||
return TOKEN.COMMA;
|
||||
case '"':
|
||||
return TOKEN.STRING;
|
||||
case ':':
|
||||
return TOKEN.COLON;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '-':
|
||||
return TOKEN.NUMBER;
|
||||
}
|
||||
|
||||
string word = NextWord;
|
||||
|
||||
switch (word) {
|
||||
case "false":
|
||||
return TOKEN.FALSE;
|
||||
case "true":
|
||||
return TOKEN.TRUE;
|
||||
case "null":
|
||||
return TOKEN.NULL;
|
||||
}
|
||||
|
||||
return TOKEN.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string
|
||||
/// </summary>
|
||||
/// <param name="json">A Dictionary<string, object> / List<object></param>
|
||||
/// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns>
|
||||
public static string Serialize (object obj)
|
||||
{
|
||||
return Serializer.Serialize (obj);
|
||||
}
|
||||
|
||||
sealed class Serializer
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
Serializer ()
|
||||
{
|
||||
builder = new StringBuilder ();
|
||||
}
|
||||
|
||||
public static string Serialize (object obj)
|
||||
{
|
||||
var instance = new Serializer ();
|
||||
|
||||
instance.SerializeValue (obj);
|
||||
|
||||
return instance.builder.ToString ();
|
||||
}
|
||||
|
||||
void SerializeValue (object value)
|
||||
{
|
||||
IList asList;
|
||||
IDictionary asDict;
|
||||
string asStr;
|
||||
|
||||
if (value == null) {
|
||||
builder.Append ("null");
|
||||
} else if ((asStr = value as string) != null) {
|
||||
SerializeString (asStr);
|
||||
} else if (value is bool) {
|
||||
builder.Append (value.ToString ().ToLower ());
|
||||
} else if ((asList = value as IList) != null) {
|
||||
SerializeArray (asList);
|
||||
} else if ((asDict = value as IDictionary) != null) {
|
||||
SerializeObject (asDict);
|
||||
} else if (value is char) {
|
||||
SerializeString (value.ToString ());
|
||||
} else {
|
||||
SerializeOther (value);
|
||||
}
|
||||
}
|
||||
|
||||
void SerializeObject (IDictionary obj)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
builder.Append ('{');
|
||||
|
||||
foreach (object e in obj.Keys) {
|
||||
if (!first) {
|
||||
builder.Append (',');
|
||||
}
|
||||
|
||||
SerializeString (e.ToString ());
|
||||
builder.Append (':');
|
||||
|
||||
SerializeValue (obj [e]);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
builder.Append ('}');
|
||||
}
|
||||
|
||||
void SerializeArray (IList anArray)
|
||||
{
|
||||
builder.Append ('[');
|
||||
|
||||
bool first = true;
|
||||
|
||||
foreach (object obj in anArray) {
|
||||
if (!first) {
|
||||
builder.Append (',');
|
||||
}
|
||||
|
||||
SerializeValue (obj);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
builder.Append (']');
|
||||
}
|
||||
|
||||
void SerializeString (string str)
|
||||
{
|
||||
builder.Append ('\"');
|
||||
|
||||
char[] charArray = str.ToCharArray ();
|
||||
foreach (var c in charArray) {
|
||||
switch (c) {
|
||||
case '"':
|
||||
builder.Append ("\\\"");
|
||||
break;
|
||||
case '\\':
|
||||
builder.Append ("\\\\");
|
||||
break;
|
||||
case '\b':
|
||||
builder.Append ("\\b");
|
||||
break;
|
||||
case '\f':
|
||||
builder.Append ("\\f");
|
||||
break;
|
||||
case '\n':
|
||||
builder.Append ("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.Append ("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
builder.Append ("\\t");
|
||||
break;
|
||||
default:
|
||||
int codepoint = Convert.ToInt32 (c);
|
||||
if ((codepoint >= 32) && (codepoint <= 126)) {
|
||||
builder.Append (c);
|
||||
} else {
|
||||
builder.Append ("\\u" + Convert.ToString (codepoint, 16).PadLeft (4, '0'));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append ('\"');
|
||||
}
|
||||
|
||||
void SerializeOther (object value)
|
||||
{
|
||||
if (value is float
|
||||
|| value is int
|
||||
|| value is uint
|
||||
|| value is long
|
||||
|| value is double
|
||||
|| value is sbyte
|
||||
|| value is byte
|
||||
|| value is short
|
||||
|| value is ushort
|
||||
|| value is ulong
|
||||
|| value is decimal) {
|
||||
builder.Append (value.ToString ());
|
||||
} else {
|
||||
SerializeString (value.ToString ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityJSON.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityJSON.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a80f212ad97ca4136b919689ba6ad522
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityLogLevel.cs
vendored
Normal file
9
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityLogLevel.cs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
using System;
|
||||
public enum ISAdQualityLogLevel {
|
||||
NONE = 0,
|
||||
ERROR = 1,
|
||||
WARNING = 2,
|
||||
INFO = 3,
|
||||
DEBUG = 4,
|
||||
VERBOSE = 5
|
||||
};
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityLogLevel.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityLogLevel.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c958a1a9721494cefb50a4fad4b6bb8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityMediationNetwork.cs
vendored
Normal file
12
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityMediationNetwork.cs
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
public enum ISAdQualityMediationNetwork {
|
||||
UNKNOWN = -1,
|
||||
ADMOB = 0,
|
||||
DT_FAIR_BID = 1,
|
||||
HELIUM = 2,
|
||||
LEVEL_PLAY = 3,
|
||||
MAX = 4,
|
||||
UNITY = 5,
|
||||
SELF_MEDIATED = 6,
|
||||
OTHER = 7
|
||||
};
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityMediationNetwork.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityMediationNetwork.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1c44dbefc86f46d7a84660f64b9ba47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
66
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualitySegment.cs
vendored
Normal file
66
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualitySegment.cs
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
public class ISAdQualitySegment
|
||||
{
|
||||
public string name = null;
|
||||
public int age;
|
||||
public string gender = null;
|
||||
public int level;
|
||||
public int isPaying;
|
||||
public double inAppPurchasesTotal;
|
||||
public long userCreationDate;
|
||||
public Dictionary<string,string> customs;
|
||||
|
||||
public ISAdQualitySegment ()
|
||||
{
|
||||
age = -1;
|
||||
level = -1;
|
||||
isPaying = -1;
|
||||
inAppPurchasesTotal = -1;
|
||||
userCreationDate = -1;
|
||||
customs = new Dictionary<string,string> ();
|
||||
}
|
||||
|
||||
public void setCustom(string key, string value){
|
||||
customs.Add (key, value);
|
||||
}
|
||||
|
||||
public Dictionary<string,string> getSegmentAsDict ()
|
||||
{
|
||||
Dictionary<string,string> dict = new Dictionary<string,string> ();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
dict.Add ("name", name);
|
||||
}
|
||||
if (age != -1)
|
||||
{
|
||||
dict.Add ("age", age + "");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(gender))
|
||||
{
|
||||
dict.Add ("gender", gender);
|
||||
}
|
||||
if (level != -1)
|
||||
{
|
||||
dict.Add ("level", level + "");
|
||||
}
|
||||
if (isPaying > -1 && isPaying < 2)
|
||||
{
|
||||
dict.Add ("isPaying", isPaying + "");
|
||||
}
|
||||
if (inAppPurchasesTotal > -1)
|
||||
{
|
||||
dict.Add ("iapt", inAppPurchasesTotal + "");
|
||||
}
|
||||
if (userCreationDate != -1)
|
||||
{
|
||||
dict.Add ("userCreationDate", userCreationDate + "");
|
||||
}
|
||||
Dictionary<string,string> result = dict.Concat(customs).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualitySegment.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualitySegment.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbf07b143b428454a85a0dccbb3bd7b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
57
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityUtils.cs
vendored
Normal file
57
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityUtils.cs
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
public static class ISAdQualityUtils {
|
||||
|
||||
private static bool isDebugBuild = false;
|
||||
private static bool isDebugBuildSet = false;
|
||||
/// <summary>
|
||||
/// Creates Log Debug message according to given tag and message.
|
||||
/// </summary>
|
||||
/// <param name="tag">The name of the class whose instance called this function.</param>
|
||||
/// <param name="message">Debug message to output to log.</param>
|
||||
public static void LogDebug(string tag, string message)
|
||||
{
|
||||
if (!isDebugBuildSet)
|
||||
{
|
||||
try //Debug.isDebugBuild can fail on WP8 if it is not called from the Main Thread
|
||||
{
|
||||
isDebugBuild = Debug.isDebugBuild;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
isDebugBuild = true;
|
||||
Debug.Log(string.Format("{0} {1}", tag, e.Message));
|
||||
}
|
||||
isDebugBuildSet = true;
|
||||
}
|
||||
if (isDebugBuild)
|
||||
{
|
||||
Debug.Log(string.Format("{0} {1}", tag, message));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates Log Error message according to given tag and message.
|
||||
/// </summary>
|
||||
/// <param name="tag">The name of the class whose instance called this function..</param>
|
||||
/// <param name="message">Error message to output to log.</param>
|
||||
public static void LogError(string tag, string message) {
|
||||
Debug.LogError(string.Format("{0} {1}", tag, message));
|
||||
}
|
||||
|
||||
public static void LogWarning(string tag, string message) {
|
||||
Debug.LogWarning(string.Format("{0} {1}", tag, message));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the class name to be used in serialization/deserialization process
|
||||
/// </summary>
|
||||
/// <param name="target">The target to get class name for</param>
|
||||
/// <returns>The class name of the provided instance</returns>
|
||||
public static string GetClassName(object target) {
|
||||
return target.GetType().Name;
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityUtils.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityUtils.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae84ef4134f7e4290bd18d994cd71a5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityiOSInitHandler.cs
vendored
Normal file
67
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityiOSInitHandler.cs
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
#if UNITY_IPHONE || UNITY_IOS
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
public class ISAdQualityiOSInitHandler : MonoBehaviour
|
||||
{
|
||||
public static event Action OnAdQualitySdkInitSuccess = delegate { };
|
||||
public static event Action<ISAdQualityInitError, string> OnAdQualitySdkInitFailed = delegate { };
|
||||
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
delegate void ISAdQualityUnityInitSuccessCallback(string args);
|
||||
[DllImport("__Internal")]
|
||||
private static extern int ironSourceAdQuality_registerInitSuccessCallback(ISAdQualityUnityInitSuccessCallback func);
|
||||
|
||||
delegate void ISAdQualityUnityInitFailedCallback(string args);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void ironSourceAdQuality_registerInitFailedCallback(ISAdQualityUnityInitFailedCallback func);
|
||||
|
||||
public ISAdQualityiOSInitHandler()
|
||||
{
|
||||
ironSourceAdQuality_registerInitSuccessCallback(fireInitSuccessCallback);
|
||||
ironSourceAdQuality_registerInitFailedCallback(fireInitFailedCallback);
|
||||
}
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(ISAdQualityUnityInitSuccessCallback))]
|
||||
public static void fireInitSuccessCallback(string message)
|
||||
{
|
||||
if (OnAdQualitySdkInitSuccess != null)
|
||||
{
|
||||
OnAdQualitySdkInitSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(ISAdQualityUnityInitFailedCallback))]
|
||||
public static void fireInitFailedCallback(string message)
|
||||
{
|
||||
if (OnAdQualitySdkInitFailed != null)
|
||||
{
|
||||
ISAdQualityInitError sdkInitError = ISAdQualityInitError.EXCEPTION_ON_INIT;
|
||||
string errorMsg = String.Empty;
|
||||
try
|
||||
{
|
||||
if (!String.IsNullOrEmpty(message))
|
||||
{
|
||||
string[] separators = { "Unity:" };
|
||||
string[] splitArray = message.Split(separators, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
if (splitArray.Length > 1)
|
||||
{
|
||||
sdkInitError = (ISAdQualityInitError)Enum.Parse(typeof(ISAdQualityInitError), splitArray[0]);
|
||||
errorMsg = splitArray[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMsg = e.Message;
|
||||
}
|
||||
OnAdQualitySdkInitFailed(sdkInitError, errorMsg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityiOSInitHandler.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/ISAdQualityiOSInitHandler.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a21b72b3702244ccaa9227784e3fc6f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
157
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/IronSourceAdQuality.cs
vendored
Normal file
157
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/IronSourceAdQuality.cs
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using ISAdQualityJSON;
|
||||
|
||||
public class IronSourceAdQuality : CodeGeneratedSingleton
|
||||
{
|
||||
private static GameObject adQualityGameObject = new GameObject("IronSourceAdQuality");
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
|
||||
[DllImport ("__Internal")]
|
||||
private static extern int ironSourceAdQuality_initialize(string appKey, string userId, bool userIdSet, bool testMode,
|
||||
bool debug, int logLevel, string initializationSource, bool coppa,
|
||||
int deviceIdType, bool isInitCallbackSet);
|
||||
[DllImport ("__Internal")]
|
||||
private static extern int ironSourceAdQuality_changeUserId(string userId);
|
||||
[DllImport ("__Internal")]
|
||||
private static extern int ironSourceAdQuality_setUserConsent(bool userConsent);
|
||||
[DllImport ("__Internal")]
|
||||
private static extern int ironSourceAdQuality_sendCustomMediationRevenue(int mediationNetwork, int adType, string placement, double revenue);
|
||||
[DllImport ("__Internal")]
|
||||
private static extern int ironSourceAdQuality_setSegment(string jsonString);
|
||||
|
||||
#endif
|
||||
|
||||
protected override bool DontDestroySingleton { get { return true; } }
|
||||
|
||||
protected override void InitAfterRegisteringAsSingleInstance() {
|
||||
base.InitAfterRegisteringAsSingleInstance();
|
||||
}
|
||||
|
||||
public static void Initialize(string appKey) {
|
||||
Initialize(appKey, new ISAdQualityConfig());
|
||||
}
|
||||
|
||||
public static void Initialize(string appKey, ISAdQualityConfig adQualityConfig) {
|
||||
if (adQualityConfig == null) {
|
||||
adQualityConfig = new ISAdQualityConfig();
|
||||
}
|
||||
Initialize(appKey,
|
||||
adQualityConfig.UserId,
|
||||
adQualityConfig.UserIdSet,
|
||||
adQualityConfig.TestMode,
|
||||
adQualityConfig.LogLevel,
|
||||
adQualityConfig.InitializationSource,
|
||||
adQualityConfig.Coppa,
|
||||
adQualityConfig.DeviceIdType,
|
||||
adQualityConfig.AdQualityInitCallback);
|
||||
}
|
||||
|
||||
private static void Initialize(string appKey,
|
||||
string userId,
|
||||
bool userIdSet,
|
||||
bool testMode,
|
||||
ISAdQualityLogLevel logLevel,
|
||||
string initializationSource,
|
||||
bool coppa,
|
||||
ISAdQualityDeviceIdType deviceIdType,
|
||||
ISAdQualityInitCallback adQualityInitCallback) {
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
GetSynchronousCodeGeneratedInstance<IronSourceAdQuality>();
|
||||
ISAdQualityInitCallbackWrapper initCallbackWrapper = adQualityGameObject.GetComponent<ISAdQualityInitCallbackWrapper>();
|
||||
if (initCallbackWrapper == null) {
|
||||
initCallbackWrapper = adQualityGameObject.AddComponent<ISAdQualityInitCallbackWrapper>();
|
||||
}
|
||||
initCallbackWrapper.AdQualityInitCallback = adQualityInitCallback;
|
||||
bool isInitCallbackSet = (adQualityInitCallback != null);
|
||||
|
||||
#if UNITY_ANDROID
|
||||
AndroidJNI.PushLocalFrame(100);
|
||||
|
||||
AndroidJNI.PopLocalFrame(IntPtr.Zero);
|
||||
#endif
|
||||
|
||||
#if UNITY_ANDROID
|
||||
AndroidJNI.PushLocalFrame(100);
|
||||
using(AndroidJavaClass jniAdQualityClass = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.unity.IronSourceAdQuality")) {
|
||||
AndroidJavaClass jLogLevelEnum = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.ISAdQualityLogLevel");
|
||||
AndroidJavaObject jLogLevel = jLogLevelEnum.CallStatic<AndroidJavaObject>("fromInt", (int)logLevel);
|
||||
AndroidJavaClass jDeviceIdTypeEnum = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.ISAdQualityDeviceIdType");
|
||||
AndroidJavaObject jDeviceIdType = jDeviceIdTypeEnum.CallStatic<AndroidJavaObject>("fromInt", (int)deviceIdType);
|
||||
jniAdQualityClass.CallStatic("initialize", appKey, userId, userIdSet, testMode, jLogLevel, initializationSource, coppa, jDeviceIdType, isInitCallbackSet);
|
||||
}
|
||||
AndroidJNI.PopLocalFrame(IntPtr.Zero);
|
||||
#elif UNITY_IOS
|
||||
ironSourceAdQuality_initialize(appKey, userId, userIdSet ,testMode, DEBUG, (int)logLevel, initializationSource, coppa, (int)deviceIdType, isInitCallbackSet);
|
||||
#endif
|
||||
#else
|
||||
ISAdQualityUtils.LogWarning(TAG, "Ad Quality SDK works only on Android or iOS devices.");
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void ChangeUserId(String userId) {
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
AndroidJNI.PushLocalFrame(100);
|
||||
using(AndroidJavaClass jniAdQualityClass = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.unity.IronSourceAdQuality")) {
|
||||
jniAdQualityClass.CallStatic("changeUserId", userId);
|
||||
}
|
||||
AndroidJNI.PopLocalFrame(IntPtr.Zero);
|
||||
#elif UNITY_IOS && !UNITY_EDITOR
|
||||
ironSourceAdQuality_changeUserId(userId);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Obsolete("This method has been deprecated and will be removed soon")]
|
||||
public static void SetUserConsent(bool userConsent) {
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
AndroidJNI.PushLocalFrame(100);
|
||||
using(AndroidJavaClass jniAdQualityClass = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.unity.IronSourceAdQuality")) {
|
||||
jniAdQualityClass.CallStatic("setUserConsent", userConsent);
|
||||
}
|
||||
AndroidJNI.PopLocalFrame(IntPtr.Zero);
|
||||
#elif UNITY_IOS && !UNITY_EDITOR
|
||||
ironSourceAdQuality_setUserConsent(userConsent);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void SendCustomMediationRevenue(ISAdQualityCustomMediationRevenue customMediationRevenue) {
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
AndroidJNI.PushLocalFrame(100);
|
||||
using(AndroidJavaClass jniAdQualityClass = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.unity.IronSourceAdQuality")) {
|
||||
jniAdQualityClass.CallStatic("sendCustomMediationRevenue",
|
||||
(int) customMediationRevenue.MediationNetwork,
|
||||
(int) customMediationRevenue.AdType,
|
||||
customMediationRevenue.Placement,
|
||||
customMediationRevenue.Revenue);
|
||||
}
|
||||
AndroidJNI.PopLocalFrame(IntPtr.Zero);
|
||||
#elif UNITY_IOS && !UNITY_EDITOR
|
||||
ironSourceAdQuality_sendCustomMediationRevenue((int) customMediationRevenue.MediationNetwork,
|
||||
(int) customMediationRevenue.AdType,
|
||||
customMediationRevenue.Placement,
|
||||
customMediationRevenue.Revenue);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setSegment(ISAdQualitySegment segment) {
|
||||
Dictionary <string,string> dict = segment.getSegmentAsDict();
|
||||
string jsonString = ISAdQualityJSON.Json.Serialize(dict);
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
AndroidJNI.PushLocalFrame(100);
|
||||
using(AndroidJavaClass jniAdQualityClass = new AndroidJavaClass("com.ironsource.adqualitysdk.sdk.unity.IronSourceAdQuality")) {
|
||||
jniAdQualityClass.CallStatic("setSegment", jsonString);
|
||||
}
|
||||
AndroidJNI.PopLocalFrame(IntPtr.Zero);
|
||||
#elif UNITY_IOS && !UNITY_EDITOR
|
||||
ironSourceAdQuality_setSegment(jsonString);
|
||||
#endif
|
||||
}
|
||||
|
||||
private const string TAG = "IronSource AdQuality";
|
||||
private const bool DEBUG = false;
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/IronSourceAdQuality.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/AdQuality/IronSourceAdQuality.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9316531db81604347bb41857c8e7ea43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config.meta
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4338140da312a4c6fb1614cd4725933a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ISAdQualityEditorScript.cs
vendored
Normal file
22
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ISAdQualityEditorScript.cs
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This class holds the store's configurations.
|
||||
/// </summary>
|
||||
public class ISAdQualityEditorScript : ScriptableObject
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
static string currentModuleVersion = "7.13.0";
|
||||
|
||||
#endif
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ISAdQualityEditorScript.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ISAdQualityEditorScript.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e0d3ac0c6a1f4767826e6a49833d7c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
208
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/IronSourceAdQualityManifestTools.cs
vendored
Normal file
208
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/IronSourceAdQualityManifestTools.cs
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class IronSourceAdQualityManifestTools
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
static string outputFile = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml");
|
||||
public static void GenerateManifest()
|
||||
{
|
||||
// only copy over a fresh copy of the AndroidManifest if one does not exist
|
||||
if (!File.Exists(outputFile))
|
||||
{
|
||||
#if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1
|
||||
var inputFile = Path.Combine(EditorApplication.applicationContentsPath, "PlaybackEngines/androidplayer/AndroidManifest.xml");
|
||||
#elif UNITY_5_2
|
||||
var inputFile = Path.Combine(EditorApplication.applicationContentsPath, "PlaybackEngines/androidplayer/Apk/AndroidManifest.xml");
|
||||
#else
|
||||
var inputFile = Path.Combine(EditorApplication.applicationPath, "../PlaybackEngines/androidplayer/Apk/AndroidManifest.xml");
|
||||
#endif
|
||||
File.Copy(inputFile, outputFile);
|
||||
}
|
||||
UpdateManifest();
|
||||
}
|
||||
|
||||
private static string _namespace = "";
|
||||
private static XmlDocument _document = null;
|
||||
private static XmlNode _manifestNode = null;
|
||||
private static XmlNode _applicationNode = null;
|
||||
|
||||
private static void LoadManifest(){
|
||||
_document = new XmlDocument();
|
||||
_document.Load(outputFile);
|
||||
|
||||
if (_document == null)
|
||||
{
|
||||
Debug.LogError("Couldn't load " + outputFile);
|
||||
return;
|
||||
}
|
||||
|
||||
_manifestNode = FindChildNode(_document, "manifest");
|
||||
_namespace = _manifestNode.GetNamespaceOfPrefix("android");
|
||||
_applicationNode = FindChildNode(_manifestNode, "application");
|
||||
|
||||
if (_applicationNode == null) {
|
||||
Debug.LogError("Error parsing " + outputFile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveManifest(){
|
||||
_document.Save(outputFile);
|
||||
}
|
||||
|
||||
public static void UpdateManifest() {
|
||||
LoadManifest ();
|
||||
|
||||
SetPermission("android.permission.INTERNET");
|
||||
SetPermission("android.permission.ACCESS_NETWORK_STATE");
|
||||
|
||||
SaveManifest ();
|
||||
}
|
||||
|
||||
public static void AddActivity(string activityName, Dictionary<string, string> attributes) {
|
||||
AppendApplicationElement("activity", activityName, attributes);
|
||||
}
|
||||
|
||||
public static void RemoveActivity(string activityName) {
|
||||
RemoveApplicationElement("activity", activityName);
|
||||
}
|
||||
|
||||
public static void SetPermission(string permissionName) {
|
||||
PrependManifestElement("uses-permission", permissionName);
|
||||
}
|
||||
|
||||
public static void RemovePermission(string permissionName) {
|
||||
RemoveManifestElement("uses-permission", permissionName);
|
||||
}
|
||||
|
||||
public static XmlElement AppendApplicationElement(string tagName, string name, Dictionary<string, string> attributes) {
|
||||
return AppendElementIfMissing(tagName, name, attributes, _applicationNode);
|
||||
}
|
||||
|
||||
public static void RemoveApplicationElement(string tagName, string name) {
|
||||
RemoveElement(tagName, name, _applicationNode);
|
||||
}
|
||||
|
||||
public static XmlElement PrependManifestElement(string tagName, string name) {
|
||||
return PrependElementIfMissing(tagName, name, null, _manifestNode);
|
||||
}
|
||||
|
||||
public static void RemoveManifestElement(string tagName, string name) {
|
||||
RemoveElement(tagName, name, _manifestNode);
|
||||
}
|
||||
|
||||
public static XmlElement AddMetaDataTag(string mdName, string mdValue) {
|
||||
return AppendApplicationElement("meta-data", mdName, new Dictionary<string, string>() {
|
||||
{ "value", mdValue }
|
||||
});
|
||||
}
|
||||
|
||||
public static XmlElement AppendElementIfMissing(string tagName, string name, Dictionary<string, string> otherAttributes, XmlNode parent) {
|
||||
XmlElement e = null;
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
e = FindElementWithTagAndName(tagName, name, parent);
|
||||
}
|
||||
|
||||
if (e == null)
|
||||
{
|
||||
e = _document.CreateElement(tagName);
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
e.SetAttribute("name", _namespace, name);
|
||||
}
|
||||
|
||||
parent.AppendChild(e);
|
||||
}
|
||||
|
||||
if (otherAttributes != null) {
|
||||
foreach(string key in otherAttributes.Keys) {
|
||||
e.SetAttribute(key, _namespace, otherAttributes[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
public static XmlElement PrependElementIfMissing(string tagName, string name, Dictionary<string, string> otherAttributes, XmlNode parent) {
|
||||
XmlElement e = null;
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
e = FindElementWithTagAndName(tagName, name, parent);
|
||||
}
|
||||
|
||||
if (e == null)
|
||||
{
|
||||
e = _document.CreateElement(tagName);
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
e.SetAttribute("name", _namespace, name);
|
||||
}
|
||||
|
||||
parent.PrependChild(e);
|
||||
}
|
||||
|
||||
if (otherAttributes != null) {
|
||||
foreach(string key in otherAttributes.Keys) {
|
||||
e.SetAttribute(key, _namespace, otherAttributes[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
public static void RemoveElement(string tagName, string name, XmlNode parent) {
|
||||
XmlElement e = FindElementWithTagAndName(tagName, name, parent);
|
||||
if (e != null)
|
||||
{
|
||||
parent.RemoveChild(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static XmlNode FindChildNode(XmlNode parent, string tagName)
|
||||
{
|
||||
XmlNode curr = parent.FirstChild;
|
||||
while (curr != null)
|
||||
{
|
||||
if (curr.Name.Equals(tagName))
|
||||
{
|
||||
return curr;
|
||||
}
|
||||
curr = curr.NextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static XmlElement FindChildElement(XmlNode parent, string tagName)
|
||||
{
|
||||
XmlNode curr = parent.FirstChild;
|
||||
while (curr != null)
|
||||
{
|
||||
if (curr.Name.Equals(tagName))
|
||||
{
|
||||
return curr as XmlElement;
|
||||
}
|
||||
curr = curr.NextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static XmlElement FindElementWithTagAndName(string tagName, string name, XmlNode parent)
|
||||
{
|
||||
var curr = parent.FirstChild;
|
||||
while (curr != null)
|
||||
{
|
||||
if (curr.Name.Equals(tagName) && curr is XmlElement && ((XmlElement)curr).GetAttribute("name", _namespace) == name)
|
||||
{
|
||||
return curr as XmlElement;
|
||||
}
|
||||
curr = curr.NextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/IronSourceAdQualityManifestTools.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/IronSourceAdQualityManifestTools.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62494cb2550224675873046db8776006
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ObjectDictionary.cs
vendored
Normal file
95
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ObjectDictionary.cs
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
// Copyright (c) 2012 Calvin Rien
|
||||
// http://the.darktable.com
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty. In
|
||||
// no event will the authors be held liable for any damages arising from the use
|
||||
// of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not claim
|
||||
// that you wrote the original software. If you use this software in a product,
|
||||
// an acknowledgment in the product documentation would be appreciated but is not
|
||||
// required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
[System.Serializable]
|
||||
public sealed class ObjectKvp : UnityNameValuePair<string> {
|
||||
public string value = null;
|
||||
|
||||
override public string Value {
|
||||
get { return this.value; }
|
||||
set { this.value = value; }
|
||||
}
|
||||
|
||||
public ObjectKvp(string key, string value) : base(key, value) {
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ObjectDictionary : UnityDictionary<string> {
|
||||
public List<ObjectKvp> values;
|
||||
|
||||
override protected List<UnityKeyValuePair<string, string>> KeyValuePairs {
|
||||
get {
|
||||
if (values == null) {
|
||||
values = new List<ObjectKvp>();
|
||||
}
|
||||
|
||||
List<UnityKeyValuePair<string, string>> valuesConverted = new List<UnityKeyValuePair<string, string>>();
|
||||
foreach (ObjectKvp okvp in values)
|
||||
{
|
||||
valuesConverted.Add(ConvertOkvp(okvp));
|
||||
}
|
||||
|
||||
return valuesConverted;
|
||||
}
|
||||
set {
|
||||
if (value == null) {
|
||||
values = new List<ObjectKvp>();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(UnityKeyValuePair<string,string> ukvp in value)
|
||||
{
|
||||
values.Add(ConvertUkvp(ukvp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new ObjectKvp ConvertUkvp(UnityKeyValuePair<string,string> ukvp)
|
||||
{
|
||||
return new ObjectKvp(ukvp.Key, ukvp.Value);
|
||||
|
||||
}
|
||||
public UnityKeyValuePair<string, string> ConvertOkvp(ObjectKvp okvp)
|
||||
{
|
||||
return new UnityKeyValuePair<string, string>(okvp.Key,okvp.Value);
|
||||
}
|
||||
override protected void SetKeyValuePair(string k, string v) {
|
||||
var index = values.FindIndex(x => {
|
||||
return x.Key == k;});
|
||||
|
||||
if (index != -1) {
|
||||
if (v == null) {
|
||||
values.RemoveAt(index);
|
||||
return;
|
||||
}
|
||||
|
||||
values[index] = new ObjectKvp(k, v);
|
||||
return;
|
||||
}
|
||||
|
||||
values.Add(new ObjectKvp(k, v));
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ObjectDictionary.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/ObjectDictionary.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d242fa04ee9a4fc79ae19ff5a74303d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
317
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/UnityDictionary.cs
vendored
Normal file
317
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/UnityDictionary.cs
vendored
Normal file
@ -0,0 +1,317 @@
|
||||
// Copyright (c) 2012 Calvin Rien
|
||||
// http://the.darktable.com
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty. In
|
||||
// no event will the authors be held liable for any damages arising from the use
|
||||
// of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not claim
|
||||
// that you wrote the original software. If you use this software in a product,
|
||||
// an acknowledgment in the product documentation would be appreciated but is not
|
||||
// required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class UnityNameValuePair<V> : UnityKeyValuePair<string, V> {
|
||||
public string name = null;
|
||||
|
||||
override public string Key {
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public UnityNameValuePair() : base() {
|
||||
}
|
||||
|
||||
public UnityNameValuePair(string key, V value) : base(key, value) {
|
||||
}
|
||||
}
|
||||
|
||||
public class UnityKeyValuePair<K, V> {
|
||||
virtual public K Key {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
virtual public V Value {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public UnityKeyValuePair() {
|
||||
Key = default(K);
|
||||
Value = default(V);
|
||||
}
|
||||
|
||||
public UnityKeyValuePair(K key, V value) {
|
||||
Key = key;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class UnityDictionary<K,V> : IDictionary<K,V> {
|
||||
abstract protected List<UnityKeyValuePair<K,V>> KeyValuePairs {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
protected abstract void SetKeyValuePair(K k, V v); /* {
|
||||
var index = Collection.FindIndex(x => {return x.Key == k;});
|
||||
|
||||
if (index != -1) {
|
||||
if (v == null) {
|
||||
Collection.RemoveAt(index);
|
||||
return;
|
||||
}
|
||||
|
||||
values[index] = new UnityKeyValuePair(key, value);
|
||||
return;
|
||||
}
|
||||
|
||||
values.Add(new UnityKeyValuePair(key, value));
|
||||
} */
|
||||
|
||||
virtual public V this[K key] {
|
||||
get {
|
||||
var result = KeyValuePairs.Find(x => {
|
||||
return x.Key.Equals(key);});
|
||||
|
||||
if (result == null) {
|
||||
return default(V);
|
||||
}
|
||||
|
||||
return result.Value;
|
||||
}
|
||||
set {
|
||||
if (key == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetKeyValuePair(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
#region IDictionary interface
|
||||
|
||||
public void Add(K key, V value) {
|
||||
this[key] = value;
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<K, V> kvp) {
|
||||
this[kvp.Key] = kvp.Value;
|
||||
}
|
||||
|
||||
public bool TryGetValue(K key, out V value) {
|
||||
if (!this.ContainsKey(key)) {
|
||||
value = default(V);
|
||||
return false;
|
||||
}
|
||||
|
||||
value = this[key];
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<K, V> item) {
|
||||
return Remove(item.Key);
|
||||
}
|
||||
|
||||
public bool Remove(K key) {
|
||||
var list = KeyValuePairs;
|
||||
|
||||
var index = list.FindIndex(x => {
|
||||
return x.Key.Equals(key);});
|
||||
|
||||
if (index == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list.RemoveAt(index);
|
||||
|
||||
KeyValuePairs = list;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
var list = KeyValuePairs;
|
||||
|
||||
list.Clear();
|
||||
|
||||
KeyValuePairs = list;
|
||||
}
|
||||
|
||||
public bool ContainsKey(K key) {
|
||||
return KeyValuePairs.FindIndex(x => {
|
||||
return x.Key.Equals(key);}) != -1;
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<K, V> kvp) {
|
||||
return this[kvp.Key].Equals(kvp.Value);
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return KeyValuePairs.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<K, V>[] array, int index) {
|
||||
List<KeyValuePair<K, V>> copy = new List<KeyValuePair<K, V>>();
|
||||
for (int i = 0; i < KeyValuePairs.Count;i++)
|
||||
{
|
||||
copy[i] = ConvertUkvp(KeyValuePairs[i]);
|
||||
}
|
||||
copy.CopyTo(array, index);
|
||||
}
|
||||
|
||||
public KeyValuePair<K,V> ConvertUkvp(UnityKeyValuePair<K, V> ukvp)
|
||||
{
|
||||
return new KeyValuePair<K,V>(ukvp.Key,(V)ukvp.Value);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() {
|
||||
return GetEnumerator() as IEnumerator;
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<K, V>> GetEnumerator() {
|
||||
return new UnityDictionaryEnumerator(this);
|
||||
}
|
||||
|
||||
public ICollection<K> Keys {
|
||||
get {
|
||||
ICollection<K> keys = new List<K>();
|
||||
foreach(UnityKeyValuePair<K,V> ukvp in KeyValuePairs)
|
||||
{
|
||||
keys.Add(ukvp.Key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<V> Values {
|
||||
get {
|
||||
ICollection<V> values = new List<V>();
|
||||
foreach (UnityKeyValuePair<K, V> ukvp in KeyValuePairs)
|
||||
{
|
||||
values.Add(ukvp.Value);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<KeyValuePair<K, V>> Items {
|
||||
get {
|
||||
List<KeyValuePair<K,V>> items = new List<KeyValuePair<K,V>>();
|
||||
foreach(UnityKeyValuePair<K,V> value in KeyValuePairs)
|
||||
{
|
||||
items.Add(new KeyValuePair<K, V>(value.Key, value.Value));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
public V SyncRoot {
|
||||
get { return default(V); }
|
||||
}
|
||||
|
||||
public bool IsFixedSize {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool IsSynchronized {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
internal sealed class UnityDictionaryEnumerator : IEnumerator<KeyValuePair<K, V>> {
|
||||
// A copy of the SimpleDictionary T's key/value pairs.
|
||||
KeyValuePair<K, V>[] items;
|
||||
int index = -1;
|
||||
|
||||
internal UnityDictionaryEnumerator() {
|
||||
}
|
||||
|
||||
internal UnityDictionaryEnumerator(UnityDictionary<K,V> ud) {
|
||||
// Make a copy of the dictionary entries currently in the SimpleDictionary T.
|
||||
items = new KeyValuePair<K, V>[ud.Count];
|
||||
|
||||
ud.CopyTo(items, 0);
|
||||
}
|
||||
|
||||
object IEnumerator.Current {
|
||||
get { return Current; }
|
||||
}
|
||||
|
||||
public KeyValuePair<K, V> Current {
|
||||
get {
|
||||
ValidateIndex();
|
||||
return items[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Return the current dictionary entry.
|
||||
public KeyValuePair<K, V> Entry {
|
||||
get { return (KeyValuePair<K, V>) Current; }
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
index = -1;
|
||||
items = null;
|
||||
}
|
||||
|
||||
// Return the key of the current item.
|
||||
public K Key {
|
||||
get {
|
||||
ValidateIndex();
|
||||
return items[index].Key;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the value of the current item.
|
||||
public V Value {
|
||||
get {
|
||||
ValidateIndex();
|
||||
return items[index].Value;
|
||||
}
|
||||
}
|
||||
|
||||
// Advance to the next item.
|
||||
public bool MoveNext() {
|
||||
if (index < items.Length - 1) {
|
||||
index++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate the enumeration index and throw an exception if the index is out of range.
|
||||
private void ValidateIndex() {
|
||||
if (index < 0 || index >= items.Length) {
|
||||
throw new System.InvalidOperationException("Enumerator is before or after the collection.");
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the index to restart the enumeration.
|
||||
public void Reset() {
|
||||
index = -1;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class UnityDictionary<V> : UnityDictionary<string, V> {
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/UnityDictionary.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Config/UnityDictionary.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b3aeeb1755c04e6f80ffb1e982537f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons.meta
vendored
Normal file
8
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 221bee1d14f6b4afaa10e6a0915411ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/BaseBehaviour.cs
vendored
Normal file
16
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/BaseBehaviour.cs
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class BaseBehaviour : MonoBehaviour
|
||||
{
|
||||
private Transform cashedTransform;
|
||||
public Transform CachedTransform
|
||||
{
|
||||
get { return cashedTransform ?? (cashedTransform = transform); }
|
||||
}
|
||||
|
||||
protected virtual void Awake() { }
|
||||
|
||||
protected virtual void Start() { }
|
||||
|
||||
protected virtual void OnDestroy() { }
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/BaseBehaviour.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/BaseBehaviour.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80937c3c4170b4ff59501e589794ddca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/CodeGeneratedSingleton.cs
vendored
Normal file
17
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/CodeGeneratedSingleton.cs
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma warning disable 618
|
||||
/// <summary>
|
||||
/// A Singleton for use when your component needs to be accessed at any given (run)time and can be automagically created on demand.
|
||||
/// To use, override <see cref="UnitySingleton.InitAfterRegisteringAsSingleInstance"/> and write your initialization logic.
|
||||
/// If your singleton shouldn't be destroyed when moving between scenes (<see cref="UnityEngine.Object.DontDestroyOnLoad"/>),
|
||||
/// Override <see cref="UnitySingleton.DontDestroySingleton"/> and return true.
|
||||
/// Like this:
|
||||
///
|
||||
/// protected override bool DontDestroySingleton
|
||||
/// {
|
||||
/// get { return true; }
|
||||
/// }
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class CodeGeneratedSingleton : UnitySingleton
|
||||
{
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/CodeGeneratedSingleton.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/CodeGeneratedSingleton.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a0aa54a1a93447f6a59f4a1534ecbe7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/SceneSingleton.cs
vendored
Normal file
17
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/SceneSingleton.cs
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma warning disable 618
|
||||
/// <summary>
|
||||
/// A Singleton for use when your component needs to be blaced in a scene on design time.
|
||||
/// To use, override <see cref="UnitySingleton.InitAfterRegisteringAsSingleInstance"/> and write your initialization logic.
|
||||
/// If your singleton shouldn't be destroyed when moving between scenes (<see cref="UnityEngine.Object.DontDestroyOnLoad"/>),
|
||||
/// Override <see cref="UnitySingleton.DontDestroySingleton"/> and return true.
|
||||
/// Like this:
|
||||
///
|
||||
/// protected override bool DontDestroySingleton
|
||||
/// {
|
||||
/// get { return true; }
|
||||
/// }
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class SceneSingleton : UnitySingleton
|
||||
{
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/SceneSingleton.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/SceneSingleton.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b330e7d866904612b12283dfae41b84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
271
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/UnitySingleton.cs
vendored
Normal file
271
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/UnitySingleton.cs
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class UnitySingleton : BaseBehaviour
|
||||
{
|
||||
#region Private Variables
|
||||
private static readonly Dictionary<Type, UnitySingleton> instances = new Dictionary<Type, UnitySingleton>();
|
||||
private static readonly Dictionary<Type, Dictionary<MonoBehaviour, Action<UnitySingleton>>> instanceListeners =
|
||||
new Dictionary<Type, Dictionary<MonoBehaviour, Action<UnitySingleton>>>();
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
protected bool IsInstanceReady { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
private void RegisterAsSingleInstanceAndInit()
|
||||
{
|
||||
instances.Add(GetType(), this);
|
||||
InnerInit();
|
||||
}
|
||||
|
||||
private void InnerInit()
|
||||
{
|
||||
InitAfterRegisteringAsSingleInstance();
|
||||
|
||||
if (DontDestroySingleton)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private static S GetOrCreateInstanceOnGameObject<S>(Type type) where S : CodeGeneratedSingleton
|
||||
{
|
||||
S instance = null;
|
||||
|
||||
var prefab = Resources.Load<GameObject>(type.Name);
|
||||
|
||||
if (prefab)
|
||||
{
|
||||
var instantiatedObject = Instantiate(prefab)
|
||||
#if !UNITY_5
|
||||
as GameObject
|
||||
#endif
|
||||
;
|
||||
|
||||
if (!instantiatedObject)
|
||||
{
|
||||
throw new Exception("Failed to instantiate prefab: " + type.Name);
|
||||
}
|
||||
|
||||
instance = instantiatedObject.GetComponent<S>();
|
||||
|
||||
if (!instance)
|
||||
{
|
||||
instance = instantiatedObject.AddComponent<S>();
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance)
|
||||
{
|
||||
instance = new GameObject(type.Name).AddComponent<S>();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void NotifyInstanceListeners()
|
||||
{
|
||||
var type = GetType();
|
||||
|
||||
// Checks if there are any registered listeners for this type of singleton
|
||||
if (instanceListeners.ContainsKey(type))
|
||||
{
|
||||
foreach (var actionWithSender in instanceListeners[type].ToArray())
|
||||
{
|
||||
// If the sender is alive and has listeners - run its actions
|
||||
if (actionWithSender.Key && actionWithSender.Value != null)
|
||||
{
|
||||
actionWithSender.Value(this);
|
||||
}
|
||||
|
||||
// Either way - remove the sender + action from the collection
|
||||
instanceListeners[type].Remove(actionWithSender.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void DeclareAsReady()
|
||||
{
|
||||
IsInstanceReady = true;
|
||||
|
||||
NotifyInstanceListeners();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
protected static S GetSynchronousCodeGeneratedInstance<S>() where S : CodeGeneratedSingleton
|
||||
{
|
||||
var type = typeof(S);
|
||||
|
||||
S instance;
|
||||
|
||||
// An instance of this type does not exist
|
||||
if (!instances.ContainsKey(type))
|
||||
{
|
||||
// Try to find an existing one in the scene
|
||||
instance = FindObjectOfType<S>();
|
||||
|
||||
if (!instance)
|
||||
{
|
||||
// Creating a new one
|
||||
instance = GetOrCreateInstanceOnGameObject<S>(type);
|
||||
}
|
||||
|
||||
instance.RegisterAsSingleInstanceAndInit();
|
||||
}
|
||||
// An instance of this type already exists
|
||||
else
|
||||
{
|
||||
instance = instances[type] as S;
|
||||
}
|
||||
|
||||
if (!instance)
|
||||
{
|
||||
throw new Exception("No instance was created: " + type.Name);
|
||||
}
|
||||
|
||||
instance.IsInstanceReady = true;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void DoWithCodeGeneratedInstance<C>(MonoBehaviour sender, Action<C> whatToDoWithInstanceWhenItsReady) where C : CodeGeneratedSingleton
|
||||
{
|
||||
// Make sure an instance exists (creating it if it doesn't)
|
||||
GetSynchronousCodeGeneratedInstance<C>();
|
||||
|
||||
// Do the action with the existing instance or wait for it to be ready
|
||||
DoWithExistingInstance(sender, whatToDoWithInstanceWhenItsReady);
|
||||
}
|
||||
|
||||
public static void DoWithSceneInstance<S>(MonoBehaviour sender, Action<S> whatToDoWithInstanceWhenItsReady) where S : SceneSingleton
|
||||
{
|
||||
DoWithExistingInstance(sender, whatToDoWithInstanceWhenItsReady);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs an action on an existing instance if and when it exists and ready
|
||||
/// </summary>
|
||||
/// <typeparam name="S"></typeparam>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="whatToDoWithInstanceWhenItsReady"></param>
|
||||
private static void DoWithExistingInstance<S>(MonoBehaviour sender, Action<S> whatToDoWithInstanceWhenItsReady) where S : UnitySingleton
|
||||
{
|
||||
var type = typeof(S);
|
||||
|
||||
var isInstanceNotExistOrReady = true;
|
||||
|
||||
// An instance of this type exists
|
||||
if (instances.ContainsKey(type))
|
||||
{
|
||||
var instance = instances[type] as S;
|
||||
|
||||
if (instance && instance.IsInstanceReady)
|
||||
{
|
||||
isInstanceNotExistOrReady = false;
|
||||
|
||||
// Call the action with the existing instance
|
||||
whatToDoWithInstanceWhenItsReady(instance);
|
||||
}
|
||||
}
|
||||
|
||||
// An instance of this type does not exist, we have to wait for it to initialize
|
||||
if (isInstanceNotExistOrReady)
|
||||
{
|
||||
if (!instanceListeners.ContainsKey(type))
|
||||
{
|
||||
instanceListeners.Add(type, new Dictionary<MonoBehaviour, Action<UnitySingleton>>());
|
||||
}
|
||||
|
||||
if (!instanceListeners[type].ContainsKey(sender))
|
||||
{
|
||||
instanceListeners[type].Add(sender, null);
|
||||
}
|
||||
|
||||
instanceListeners[type][sender] += singleton => whatToDoWithInstanceWhenItsReady(singleton as S);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unity Functions
|
||||
protected sealed override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
var type = GetType();
|
||||
|
||||
var needToDestroy = false;
|
||||
|
||||
// There's already an instance of my type
|
||||
if (instances.ContainsKey(type))
|
||||
{
|
||||
// The existing instance is not this instance so we've got a conflict (There can only be one!)
|
||||
if (instances[type] != this)
|
||||
{
|
||||
if (this is CodeGeneratedSingleton)
|
||||
{
|
||||
throw new Exception("There's already an instance for " + type.Name);
|
||||
}
|
||||
|
||||
if (this is SceneSingleton)
|
||||
{
|
||||
if (DontDestroySingleton)
|
||||
{
|
||||
// [this] is not the single instance (Singleton) so we actually DO need to destroy it
|
||||
needToDestroy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// There's no instance of my type and I'm a CodeGeneratedSingleton
|
||||
// It should have been created via code so if I don't exist in the instance collection it means I was created on a scene
|
||||
else if (this is CodeGeneratedSingleton)
|
||||
{
|
||||
throw new NotSupportedException(string.Format("{0} is a {1} and needs to be created via code, and not placed on a scene!", type.Name, typeof(CodeGeneratedSingleton).Name));
|
||||
}
|
||||
|
||||
if (needToDestroy)
|
||||
{
|
||||
Debug.LogWarning(string.Format("There's already a {0} instance on the current scene, there's no point in staying.. goodbye.. I'm gonna go now :(", type.Name));
|
||||
|
||||
Destroy(this);
|
||||
}
|
||||
else if (this is SceneSingleton)
|
||||
{
|
||||
RegisterAsSingleInstanceAndInit();
|
||||
|
||||
SetReadyAndNotifyAfterRegistering();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this if the singleton won't be ready immediately after registering as single instance
|
||||
/// </summary>
|
||||
protected virtual void SetReadyAndNotifyAfterRegistering()
|
||||
{
|
||||
DeclareAsReady();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
var type = GetType();
|
||||
|
||||
// There's already an instance of my type but it's me - remove me
|
||||
if (instances.ContainsKey(type) && instances[type] == this)
|
||||
{
|
||||
instances.Remove(type);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Virtuals
|
||||
protected virtual void InitAfterRegisteringAsSingleInstance() { }
|
||||
protected virtual bool DontDestroySingleton { get { return false; } }
|
||||
#endregion
|
||||
}
|
||||
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/UnitySingleton.cs.meta
vendored
Normal file
11
Assets/ThirdParty/IronSourceAdQuality/Scripts/Singletons/UnitySingleton.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac12af7b0ebf6409c935fad7857982be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user