Beispiel #1
0
 //Invoked when the initialization process has failed.
 //@param description - string - contains information about the failure.
 void InterstitialAdLoadFailedEvent(IronSourceError error)
 {
     LDebug.Log("==InterstitialAdLoadFailedEvent");
     if (error != null)
     {
         LDebug.Log(error.getDescription());
     }
     if (InterstitialLoadEventHandler != null)
     {
         InterstitialLoadEventHandler(false);
     }
 }
Beispiel #2
0
 //interstitial读取失败
 private void OnInterstitialFailedEvent(string adUnitId, string error)
 {
     if (error != null)
     {
         LDebug.Log("OnInterstitialFailedEvent " + error);
     }
     if (InterstitialLoadEventHandler != null)
     {
         InterstitialLoadEventHandler(false);
     }
     LDebug.Log("mopub调试——interstitial读取失败, id:" + adUnitId);
     LDebug.Log("error-----" + error);
 }
Beispiel #3
0
    //购买不同商品结束后的处理方法 对应定义的商品
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
        foreach (var prod in PurchaserDataModel.Instance.ProductsDict)
        {
            // A consumable product has been purchased by this user.
            if (String.Equals(args.purchasedProduct.definition.id, prod.Value.BuyID, StringComparison.Ordinal))
            {
                LDebug.Log(string.Format("ProcessPurchase: Succeed : '{0}'", args.purchasedProduct.definition.id));

                ProcessPurchaseEventHandler?.Invoke(prod.Value.BuyID);

                var     product      = m_StoreController.products.WithID(prod.Value.BuyID);
                string  receipt      = product.receipt;
                string  currency     = product.metadata.isoCurrencyCode;
                int     amount       = decimal.ToInt32(product.metadata.localizedPrice * 100);
                Receipt receiptClass = LitJson.JsonMapper.ToObject <Receipt>(receipt);
                ProcessPurchaseReceiptEventHandler?.Invoke(currency, prod.Value.BuyID, amount, receiptClass);

                // Return a flag indicating whether this product has completely been received, or if the application needs
                // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
                // saving purchased products to the cloud, and when that save is delayed.
                return(PurchaseProcessingResult.Complete);
            }
            else if (!string.IsNullOrEmpty(prod.Value.AlternativeBuyID) && String.Equals(args.purchasedProduct.definition.id, prod.Value.AlternativeBuyID, StringComparison.Ordinal))
            {
                LDebug.Log(string.Format("ProcessPurchase: Succeed : '{0}'", args.purchasedProduct.definition.id));

                ProcessPurchaseEventHandler?.Invoke(prod.Value.AlternativeBuyID);

                var     product      = m_StoreController.products.WithID(prod.Value.AlternativeBuyID);
                string  receipt      = product.receipt;
                string  currency     = product.metadata.isoCurrencyCode;
                int     amount       = decimal.ToInt32(product.metadata.localizedPrice * 100);
                Receipt receiptClass = LitJson.JsonMapper.ToObject <Receipt>(receipt);
                ProcessPurchaseReceiptEventHandler?.Invoke(currency, prod.Value.AlternativeBuyID, amount, receiptClass);

                // Return a flag indicating whether this product has completely been received, or if the application needs
                // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
                // saving purchased products to the cloud, and when that save is delayed.
                return(PurchaseProcessingResult.Complete);
            }
        }

        LDebug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));

        // Return a flag indicating whether this product has completely been received, or if the application needs
        // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
        // saving purchased products to the cloud, and when that save is delayed.
        return(PurchaseProcessingResult.Pending);
    }
Beispiel #4
0
    private void Initialized(ProductCollection productCollection)
    {
        LDebug.Log("IAP total count ==>" + productCollection.all.Length);

        for (int i = 0; i < productCollection.all.Length; i++)
        {
            var product = productCollection.all[i];

            LDebug.Log("IAP product storeSpecificId ==>" + product.definition.storeSpecificId);
            LDebug.Log("IAP availableToPurchase ==>" + product.availableToPurchase);

            if (product.definition.storeSpecificId.StartsWith("buy"))
            {
                continue;
            }

            //包含在ProductsDict中的都是正是商品,打折商品ID不会出现在ProductDict中
            if (ProductsDict.ContainsKey(product.definition.storeSpecificId))
            {
                //真正后台配置商品
                ProductsDict[product.definition.storeSpecificId].Name        = product.metadata.localizedTitle;
                ProductsDict[product.definition.storeSpecificId].Price       = product.metadata.localizedPriceString;
                ProductsDict[product.definition.storeSpecificId].Description = product.metadata.localizedDescription;
                ProductsDict[product.definition.storeSpecificId].ProductType = product.definition.type;
            }
            else
            {
                var alternativeItem = ProductsDict.Where(e => e.Value.AlternativeBuyID == product.definition.storeSpecificId);
                //如果该ID被设置为一个打折商品ID
                if (alternativeItem.Count() > 0)
                {
                    var target = alternativeItem.First();
                    target.Value.AlternativePrice = product.metadata.localizedPriceString;
                }
                else
                {
                    ProductsDict.Add(product.definition.storeSpecificId, new PurchaserStoreItem(product.definition.storeSpecificId)
                    {
                        Name        = product.metadata.localizedTitle,
                        Price       = product.metadata.localizedPriceString,
                        Description = product.metadata.localizedDescription,
                        ProductType = product.definition.type,
                    });
                }
            }

            LDebug.Log("IAP localizedTitle ==>" + product.metadata.localizedTitle);
            LDebug.Log("IAP storeSpecificId ==>" + product.definition.storeSpecificId);
        }
    }
Beispiel #5
0
    public override void HideBanner(bool destroy)
    {
#if IRONSOURCE
        LDebug.Log(">>>>HideBanner");
        if (destroy)
        {
            IronSource.Agent.destroyBanner();
        }
        else
        {
            IronSource.Agent.hideBanner();
        }
#endif
    }
Beispiel #6
0
        public void Install()
        {
            _allRegisterUIDict  = new Dictionary <string, string>();
            _stackCurrentUI     = new Stack <BaseUI>();
            _dictLoadedAllUIs   = new Dictionary <string, BaseUI>();
            _dictCurrentShowUIs = new Dictionary <string, BaseUI>();

            TransRoot   = GameObject.FindGameObjectWithTag(UISysDefine.SYS_TAG_ROOTCANVAS).transform;
            TransNormal = UnityHelper.FindTheChildNode(TransRoot, UISysDefine.SYS_TAG_NORMALCANVAS);
            TransFixed  = UnityHelper.FindTheChildNode(TransRoot, UISysDefine.SYS_TAG_FIXEDCANVAS);
            TransPopUp  = UnityHelper.FindTheChildNode(TransRoot, UISysDefine.SYS_TAG_POPUPCANVAS);
            TransGlobal = UnityHelper.FindTheChildNode(TransRoot, UISysDefine.SYS_TAG_GLOBALCANVAS);

            RectransRoot   = TransRoot.GetComponent <RectTransform>();
            RectransNormal = TransNormal.GetComponent <RectTransform>();
            RectransFixed  = TransFixed.GetComponent <RectTransform>();
            RectransPopUp  = TransPopUp.GetComponent <RectTransform>();
            RectransGlobal = TransGlobal.GetComponent <RectTransform>();

            _fadeImage = UnityHelper.FindTheChildNode(TransGlobal, "Image_fadeBG").GetComponent <Image>();

            try
            {
                if (_fadeImage == null)
                {
                    LDebug.LogWarning("Image_fadeBG 未定义");
                }
                else if (!_fadeImage.gameObject.activeInHierarchy)
                {
                    LDebug.LogWarning("Image_fadeBG 未启用");
                }

                _fadeImage.raycastTarget = false;
                _fadeImage.gameObject.SetActive(true);
            }
            catch (Exception e)
            {
                LDebug.LogError("Image_fadeBG 错误");
            }

            //Mask蒙版初始化
            var ss = UIMaskManager.Instance;

            UICam        = UnityHelper.FindTheChildNode(TransRoot, "UICamera").GetComponent <Camera>();
            CanvasScaler = TransRoot.GetComponent <CanvasScaler>();
            GameObject.DontDestroyOnLoad(TransRoot.gameObject);

            AssemblyReflection();
        }
Beispiel #7
0
    //
    // --- IStoreListener
    //
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        // Purchasing has succeeded initializing. Collect our Purchasing references.
        LDebug.Log("OnInitialized: PASS");

        // Overall Purchasing system, configured with products for this application.
        m_StoreController = controller;
        // Store specific subsystem, for accessing device-specific store features.
        m_StoreExtensionProvider = extensions;

        if (InitializedEventHandler != null)
        {
            InitializedEventHandler(m_StoreController.products);
        }
    }
Beispiel #8
0
    public override void ShowRewarded()
    {
#if IRONSOURCE
        LDebug.Log("==ShowRewardedVedio");

        if (IsRewardedVideoAvailable())
        {
            IronSource.Agent.showRewardedVideo();
        }
        else if (RewardShowEventHandler != null)
        {
            RewardShowEventHandler(false);
        }
#endif
    }
Beispiel #9
0
    /// <summary>
    /// 创建置灰材质球
    /// </summary>
    /// <returns></returns>
    private static Material GetGrayMat()
    {
        if (grayMat == null)
        {
            Shader shader = Resources.Load <Shader>("Shaders/UI/UIGrey");
            if (shader == null)
            {
                LDebug.LogWarning("未发现Shader Custom/UI-Gray");
                return(null);
            }
            Material mat = new Material(shader);
            grayMat = mat;
        }

        return(grayMat);
    }
Beispiel #10
0
 private void StartHotFix(Queue <IHotFix> hotFixesQueue)
 {
     //是否需要热更
     if (FrameworkConfig.Instance.UseRemotePersistantPath)
     {
         if (string.IsNullOrEmpty(FrameworkConfig.Instance.RemoteUrlConfig))
         {
             LDebug.LogErrorFormat(">>REMOTE_IP: {0} 无效!", FrameworkConfig.Instance.RemoteUrlConfig);
             return;
         }
         LitTool.MonoBehaviour.StartCoroutine(IStartHotFix(hotFixesQueue));
     }
     else
     {
         MsgManager.Instance.Broadcast(InternalEvent.END_LOAD_REMOTE_CONFIG);
     }
 }
Beispiel #11
0
    private void BuyFailEventHandler(BuyFailReason obj)
    {
        switch (obj)
        {
        case BuyFailReason.NotInit:
            LDebug.LogError("Purchase Fail->Purchase not initialized");
            break;

        case BuyFailReason.ProductError:
            LDebug.LogError("Purchase Fail->Not purchasing product, not found or not available");
            break;

        case BuyFailReason.Other:
            LDebug.LogError("Purchase Fail->Other");
            break;
        }
        BuyFailEvent?.Invoke(obj);
    }
Beispiel #12
0
    public override void ShowInterstitial()
    {
#if MOPUB
        LDebug.Log("IsIntersititialReady " + IsIntersititialReady());

        if (IsIntersititialReady())
        {
#if UNITY_ANDROID
            if (DataModel.Instance.CurrentLevel <= 20)
            {
                MoPub.ShowInterstitialAd(_interstitialAdUnits[1]);
                LDebug.Log("===>MoPub.ShowInterstitialAd _interstitialAdUnits[1]");
            }
            else
            {
                MoPub.ShowInterstitialAd(_interstitialAdUnits[0]);
                LDebug.Log("===>MoPub.ShowInterstitialAd _interstitialAdUnits[0]");
            }
#elif UNITY_IOS
            if (DataModel.Instance.CurrentLevel <= 20)
            {
                MoPub.ShowInterstitialAd(_interstitialAdUnits[1]);
                LDebug.Log("===>MoPub.ShowInterstitialAd _interstitialAdUnits[1]");
            }
            else
            {
                MoPub.ShowInterstitialAd(_interstitialAdUnits[0]);
                LDebug.Log("===>MoPub.ShowInterstitialAd _interstitialAdUnits[0]");
            }
#endif
        }
        else
        {
            InterstitialShowEventHandler?.Invoke(false);
        }
#else
        InterstitialShowEventHandler?.Invoke(false);
#endif
    }
Beispiel #13
0
    public override void Init()
    {
#if IRONSOURCE
        IronSource.Agent.init(appKey, IronSourceAdUnits.REWARDED_VIDEO, IronSourceAdUnits.INTERSTITIAL, IronSourceAdUnits.BANNER);
        IronSource.Agent.shouldTrackNetworkState(true);
        IronSource.Agent.setConsent(true);
#if DEBUG
        IronSource.Agent.validateIntegration();
        IronSource.Agent.setAdaptersDebug(true);
        LDebug.Log(IronSource.pluginVersion());
        LDebug.Log(IronSource.unityVersion());
#endif
#endif

        LitFramework.LitTool.LitTool.DelayPlayFunction(0.1f, () =>
        {
            //if (AdManager.Instance.UseAds)
            //    CreateBanner();
            CreateInterstitial();
            CreateRewarded();
        });
    }
Beispiel #14
0
        /// <summary>
        /// www加载
        /// </summary>
        /// <param name="filePath">包含IP地址在内(网络请求时)的完整地址</param>
        /// <param name="callBack">加载完成后的回调</param>
        /// <returns></returns>
        public static string WWWLoadingWithWaiting(string wwwFilePath, Action <WWW> callBack = null)
        {
            LDebug.Log(wwwFilePath);
            string resutl = null;
            WWW    www    = new WWW(wwwFilePath);

            while (!www.isDone)
            {
            }

            if (www.error != null)
            {
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    throw new Exception(string.Format("WWW Error: {0}  filePath: {1}  ", www.error, wwwFilePath));
                }
                else
                {
                    Debug.LogError("WWW Error: " + www.error);
                }
            }

            if (www.isDone)
            {
                if (callBack != null)
                {
                    callBack.Invoke(www);
                }
            }

            resutl = www.text;
            www.Dispose();
            www = null;

            return(resutl);
        }
Beispiel #15
0
 //激励视频跳转其他应用
 private void OnRewardedVideoLeavingApplicationEvent(string adUnitId)
 {
     LDebug.Log("激励视频跳转其他应用,id:" + adUnitId);
 }
Beispiel #16
0
 //视频单击回调
 private void OnRewardedVideoClickedEvent(string adUnitId)
 {
     LDebug.Log("视频单击回调,id:" + adUnitId);
 }
Beispiel #17
0
 //视频激活的时候回调
 private void OnRewardedVideoShownEvent(string adUnitId)
 {
     LDebug.Log("视频激活的时候回调,id:" + adUnitId);
 }
Beispiel #18
0
        public IEnumerator HotFixExecute()
        {
            LDebug.Log("开始检测更新:" + CONFIG_NAME);
            //1、下载最新的资源配置信息
            bool   canGoFurther   = true;
            string wrongFileName  = string.Empty;
            string localContent   = null;
            string remoteFilePath = CONFIG_NAME;

            //发送下载XX文件事件
            MsgManager.Instance.Broadcast(InternalEvent.HANDLING_REMOTE_RES, new MsgArgs(remoteFilePath, InternalEvent.RemoteStatus.Download));

            string localFilePath = AssetPathManager.Instance.GetPersistentDataPath(remoteFilePath, false);

            //2、根据本地是否存在资源配置信息,如果不存在,则视为远程更新流程不执行
            if (DocumentAccessor.IsExists(localFilePath))
            {
                string remoteContent  = null;
                byte[] contentByteArr = null;

                LDebug.Log("Remote update..." + FrameworkConfig.Instance.RemoteUrlConfig + "/" + remoteFilePath + " 开始读取", LogColor.yellow);
                //远程主配置文件获取
                yield return(DocumentAccessor.ILoadAsset(FrameworkConfig.Instance.RemoteUrlConfig + remoteFilePath, callBack: (UnityWebRequest e) =>
                {
                    LDebug.Log("Remote update..." + remoteFilePath + "读取完成", LogColor.yellow);
                    remoteContent = e.downloadHandler.text;
                    contentByteArr = e.downloadHandler.data;
                },
                                                         errorCallBack: (UnityWebRequest e) =>
                {
                    LDebug.LogError("Remote Error..." + e + ": " + remoteFilePath);
                    if (!string.IsNullOrEmpty(e.error))
                    {
                        canGoFurther = false; return;
                    }
                }));


                //因为加载出问题导致无法继续时,目前先使用中断后续步骤,并弹窗提醒的方式搞
                if (!canGoFurther)
                {
                    MsgManager.Instance.Broadcast(InternalEvent.REMOTE_UPDATE_ERROR, new MsgArgs(remoteContent, remoteFilePath));
                    yield break;
                }


                //本地主配置文件获取
                DocumentAccessor.LoadAsset(localFilePath, (string e) => { localContent = e; });


                ////本地配置表默认全更新。
                //string[] str = remoteContent.Split( "\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries );
                //string[] localFileContent = localContent.Split( "\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries );
                //var toDelete = localFileContent.Where( a => !str.Contains( a ) );

                //foreach ( var item in toDelete )
                //{
                //    FileInfo fileInfo = new FileInfo( AssetPathManager.Instance.GetPersistentDataPath( item, false ) );
                //    if ( fileInfo.Exists ) fileInfo.Delete();
                //    LDebug.Log( ">>>Delete " + item, LogColor.red );
                //    LDebug.Log( ">>>Delete Result " + DocumentAccessor.IsExists( AssetPathManager.Instance.GetPersistentDataPath( item, false ) ), LogColor.red );
                //}

                //for ( int w = 0; w < str.Length; w++ )
                //{
                //    LDebug.Log( "Remote update..." + str[ w ] + "开始读取" );
                //    yield return DocumentAccessor.ILoadAsset( FrameworkConfig.Instance.RemoteUrlConfig + str[ w ], ( UnityWebRequest e ) =>
                //    {
                //        LDebug.Log( "Remote update..." + str[ w ] + "读取完成", LogColor.yellow );
                //        DocumentAccessor.SaveAsset2LocalFile( AssetPathManager.Instance.GetPersistentDataPath( str[ w ], false ), e.downloadHandler.data );
                //    } );
                //}

                ////更新文档
                //DocumentAccessor.SaveAsset2LocalFile( localFilePath, contentByteArr );
                //LDebug.Log( "检测更新完成:" + CONFIG_NAME );

                //本地配置表默认增量更新。修改为增量更新后,后续的逻辑跟HOTFIXAB是一样的
                Dictionary <string, ABVersion> remoteABVersionsDic = ResolveABContent(remoteContent);
                Dictionary <string, ABVersion> localABVersionsDic  = ResolveABContent(localContent);

                //需要删除的对象
                var toDelete = localABVersionsDic.Where(a => !remoteABVersionsDic.ContainsKey(a.Key));
                foreach (var item in toDelete)
                {
                    FileInfo fileInfo = new FileInfo(AssetPathManager.Instance.GetPersistentDataPath(item.Key, false));
                    if (fileInfo.Exists)
                    {
                        fileInfo.Delete();
                    }
                    LDebug.Log(">>>Delete " + item.Key, LogColor.red);
                    LDebug.Log(">>>Delete Result " + DocumentAccessor.IsExists(AssetPathManager.Instance.GetPersistentDataPath(item.Key, false)), LogColor.red);
                }

                //需要更新的对象:可以根据需求拓展对version的使用规则。
                //默认是更新版本号更高或者新增加的对象。
                var toUpdate = remoteABVersionsDic.Where(a => !localABVersionsDic.ContainsKey(a.Key) || a.Value.Version > localABVersionsDic[a.Key].Version);
                foreach (var item in toUpdate)
                {
                    LDebug.Log("Remote update..." + FrameworkConfig.Instance.RemoteUrlConfig + "/" + item.Key + " 开始读取", LogColor.yellow);
                    yield return(DocumentAccessor.ILoadAsset(FrameworkConfig.Instance.RemoteUrlConfig + "/" + item.Key, (UnityWebRequest e) =>
                    {
                        LDebug.Log("Remote update..." + item.Key + "读取完成", LogColor.yellow);
                        DocumentAccessor.SaveAsset2LocalFile(AssetPathManager.Instance.GetPersistentDataPath(item.Key, false), e.downloadHandler.data);
                    }, (e) =>
                    {
                        LDebug.LogError("Remote Error..." + e + ": " + remoteFilePath);
                        if (!string.IsNullOrEmpty(e.error))
                        {
                            canGoFurther = false; wrongFileName = item.Key; return;
                        }
                    }));

                    // 因为加载出问题导致无法继续时,目前先使用中断后续步骤,并弹窗提醒的方式搞
                    if (!canGoFurther)
                    {
                        break;
                    }
                }

                // 因为加载出问题导致无法继续时,目前先使用中断后续步骤,并弹窗提醒的方式搞
                if (!canGoFurther)
                {
                    LDebug.LogError("Remote Update Abort..." + wrongFileName + " : " + remoteFilePath);
                    MsgManager.Instance.Broadcast(InternalEvent.REMOTE_UPDATE_ERROR, new MsgArgs(remoteContent, remoteFilePath, wrongFileName));
                    yield break;
                }

                //更新文档
                DocumentAccessor.SaveAsset2LocalFile(localFilePath, contentByteArr);
                LDebug.Log("检测更新完成:" + CONFIG_NAME);
            }
        }
Beispiel #19
0
 /// <summary>
 /// 点击返回事件
 /// </summary>
 public virtual void OnBackPushed()
 {
     LDebug.Log("关闭ui:" + AssetsName);
     UIManager.Instance.Close(AssetsName);
 }
Beispiel #20
0
 //interstitial关闭
 private void OnInterstitialDismissedEvent(string adUnitId)
 {
     //MoPub.RequestInterstitialAd(_interstitialAdUnits[0]);
     LDebug.Log("mopub调试——interstitial关闭");
 }
Beispiel #21
0
 //Fired when a banner ad collapses back to its initial size
 private void OnAdCollapsedEvent(string adUnitId)
 {
     LDebug.Log("mopub调试——OnAdCollapsedEvent, id:" + adUnitId);
 }
Beispiel #22
0
 //单击banner
 private void OnAdClickedEvent(string adUnitId)
 {
     LDebug.Log("mopub调试——单击banner, id:" + adUnitId);
 }
Beispiel #23
0
 //banner读取失败
 private void OnAdFailedEvent(string adUnitId, string error)
 {
     LDebug.Log("mopub调试——banner读取失败, id:" + adUnitId);
 }
Beispiel #24
0
        private void Awake()
        {
            // Make this GameObject immortal if the user requests it.
            if (this._dontDestroyOnLoad)
            {
                Object.DontDestroyOnLoad(this.gameObject);
            }

            this.group = this.transform;

            // Default name behavior will use the GameObject's name without "Pool" (if found)
            if (this.poolName == "")
            {
                // Automatically Remove "Pool" from names to allow users to name prefabs in a
                //   more development-friendly way. E.g. "EnemiesPool" becomes just "Enemies".
                //   Notes: This will return the original string if "Pool" isn't found.
                //          Do this once here, rather than a getter, to avoide string work
                this.poolName = this.group.name.Replace("Pool", "");
                this.poolName = this.poolName.Replace("(Clone)", "");
            }

            if (this.logMessages)
            {
                Debug.Log(string.Format("SpawnPool {0}: Initializing..", this.poolName));
            }

            // Only used on items defined in the Inspector
            for (int i = 0; i < this.perPrefabPoolOptions.Count; i++)
            {
                //if (this.perPrefabPoolOptions[i].prefab == null)
                //{
                //    Debug.LogWarning(string.Format("Initialization Warning: Pool '{0}' " +
                //              "contains a PrefabPool with no prefab reference. Skipping.",
                //               this.poolName));
                //    continue;
                //}

                //// Init the PrefabPool's GameObject cache because it can't do it.
                ////   This is only needed when created by the inspector because the constructor
                ////   won't be run.
                //this.perPrefabPoolOptions[i].inspectorInstanceConstructor();
                //this.CreatePrefabPool(this.perPrefabPoolOptions[i]);
                if (this.perPrefabPoolOptions[i].Pools == null)
                {
                    Debug.LogWarning(string.Format("Initialization Warning: Pool '{0}' " +
                                                   "contains a PrefabPool with no prefab reference. Skipping.",
                                                   this.poolName));
                    continue;
                }
                List <PrefabPool> sorts = this.perPrefabPoolOptions[i].Pools;
                for (int j = 0; j < sorts.Count; j++)
                {
                    try
                    {
                        sorts[j].inspectorInstanceConstructor();
                        this.CreatePrefabPool(sorts[j]);
                    }
                    catch (System.Exception)
                    {
                        LDebug.LogError(string.Format("==>对象池预制件丢失!  池类型:{0}  Index: {1}", this.perPrefabPoolOptions[i].SortSpawnName, i));
                        throw;
                    }
                }
            }

            //perPrefabPoolOptions.Clear();
            //perPrefabPoolOptions = null;
            // Add this SpawnPool to PoolManager for use. This is done last to lower the
            //   possibility of adding a badly init pool.
            PoolManager.Pools.Add(this);
        }
Beispiel #25
0
    void OnGUI()
    {
        //必选项:类名
        GUILayout.Label("脚本类名(UI+类名) 例如:UIMain");
        uiScriptsName = EditorGUILayout.TextField(uiScriptsName);

        //选填
        GUILayout.Label("类说明,建议写UI界面类型,例如:主界面");
        uiSummary = EditorGUILayout.TextField(uiSummary);

        uiNodeType    = ( UINodeTypeEnum )EditorGUILayout.EnumPopup("挂载节点", uiNodeType);
        uiShowMode    = ( UIShowModeEnum )EditorGUILayout.EnumPopup("窗体显示方式", uiShowMode);
        uiTransparent = ( UITransparentEnum )EditorGUILayout.EnumPopup("窗体背后的遮罩透明度", uiTransparent);

        EditorGUILayout.Space();

        //勾选项
        useOnEnable_OnDisable = EditorGUILayout.Toggle("OnEnable/OnDisable", useOnEnable_OnDisable);
        useDefaultExitBtn     = EditorGUILayout.Toggle("退出按钮", useDefaultExitBtn);
        if (useDefaultExitBtn)
        {
            useOnEnable_OnDisable = useDefaultExitBtn ? true : EditorGUILayout.Toggle("启用OnEnable/OnDisable", useOnEnable_OnDisable);
        }
        useAnimRoot = EditorGUILayout.Toggle("动画控制器", useAnimRoot);
        if (useAnimRoot)
        {
            animStartID = EditorGUILayout.TextField("    弹出动画ID", animStartID);
            animCloseID = EditorGUILayout.TextField("    关闭动画ID", animCloseID);
        }

        EditorGUILayout.Space();

        using (new BackgroundColorScope(Color.green))
        {
            if (GUILayout.Button("创建脚本+UI预制件+注册绑定", GUILayout.Height(40)))
            {
                _saveLocalFileInfo = new FileInfo(Application.dataPath + "/Editor/" + GlobalEditorSetting.JSON_FILE_NAME);

                if (CheckClassNameValid())
                {
                    isDirty = true;

                    EditorUtility.DisplayProgressBar("生成UI模块", "", 1f);

                    //CS 脚本
                    UICreateParse cs        = new UICreateParse();
                    string        csOutPath = Application.dataPath + "/Scripts/UI";
                    if (!FrameworkConfig.Instance.UseHotFixMode)
                    {
                        csOutPath = Application.dataPath + "/Scripts/UI";
                    }
                    else
                    {
                        csOutPath = Application.dataPath + "/Scripts/ILRuntime/HotFixLogic/UI";
                    }
                    EditorMenuExtention.CreateCSFile(csOutPath, uiScriptsName + ".cs", cs.CreateCS(this));
                    AssetDatabase.Refresh();

                    //预制件
                    newCanvas            = new GameObject("Canvas_" + uiScriptsName.Substring(2), typeof(Canvas)).GetComponent <Canvas>();
                    newCanvas.renderMode = RenderMode.ScreenSpaceOverlay;

                    var canvasScaler = newCanvas.gameObject.AddComponent <CanvasScaler>();
                    canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;

                    var graphics = newCanvas.gameObject.AddComponent <GraphicRaycaster>();
                    graphics.ignoreReversedGraphics = true;
                    graphics.blockingObjects        = GraphicRaycaster.BlockingObjects.None;

                    GameObject animTrans = new GameObject("Container_Anim", typeof(RectTransform));
                    animTrans.transform.SetParent(newCanvas.transform);
                    var recTrans = animTrans.GetComponent <RectTransform>();
                    recTrans.sizeDelta                = Vector2.zero;
                    recTrans.anchorMin                = Vector2.zero;
                    recTrans.anchorMax                = Vector2.one;
                    recTrans.anchoredPosition         = Vector2.zero;
                    animTrans.transform.localPosition = Vector3.zero;
                    animTrans.transform.localScale    = Vector3.one;

                    if (useAnimRoot)
                    {
                        //DOTEEN插件未集成在编辑器库中,引出到库外部使用
                        CreateAnimationComponentEvent?.Invoke(animTrans, animStartID, animCloseID);
                    }

                    if (useDefaultExitBtn)
                    {
                        GameObject btnExit = new GameObject("Btn_Exit", typeof(RectTransform));
                        btnExit.AddComponent <CanvasRenderer>();
                        btnExit.AddComponent <Image>().maskable = false;
                        btnExit.AddComponent <Button>();
                        btnExit.transform.SetParent(animTrans.transform);
                        btnExit.transform.localPosition = Vector3.zero;
                        btnExit.transform.localScale    = Vector3.one;
                    }

                    //Layer设定
                    ChangeUILayer(newCanvas.transform, "UI");

                    //预制件自注册
                    RigisterUIPath(uiScriptsName);

                    AssetDatabase.Refresh();
                }
                else
                {
                    EditorUtility.DisplayDialog("类名错误", "类名应该不为空、空格,并且以UI开头", "哦");
                }
            }
        }

        EditorGUILayout.Space();

        using (new BackgroundColorScope(Color.green))
        {
            if (GUILayout.Button("仅创建脚本", GUILayout.Height(40)))
            {
                _saveLocalFileInfo = new FileInfo(Application.dataPath + "/Editor/" + GlobalEditorSetting.JSON_FILE_NAME);

                if (CheckClassNameValid())
                {
                    //CS 脚本
                    UICreateParse cs        = new UICreateParse();
                    string        csOutPath = Application.dataPath + "/Scripts/UI";

                    if (!FrameworkConfig.Instance.UseHotFixMode)
                    {
                        csOutPath = Application.dataPath + "/Scripts/UI";
                    }
                    else
                    {
                        csOutPath = Application.dataPath + "/Scripts/ILRuntime/HotFixLogic/UI";
                    }


                    EditorMenuExtention.CreateCSFile(csOutPath, uiScriptsName + ".cs", cs.CreateCS(this));
                    AssetDatabase.Refresh();
                }
                else
                {
                    EditorUtility.DisplayDialog("类名错误", "类名应该不为空、空格,并且以UI开头", "哦");
                }
            }
        }

        EditorGUILayout.Space();

        using (new BackgroundColorScope(Color.yellow))
        {
            if (GUILayout.Button("更新UI配置", GUILayout.Height(40)))
            {
                _saveLocalFileInfo = new FileInfo(Application.dataPath + "/Editor/" + GlobalEditorSetting.JSON_FILE_NAME);

                //============JSON文件取出============//
                ResPathTemplate rpt = null;
                //如果文件存在,则读取解析为存储类,写入相关数据条后写入JSON并保存
                if (DocumentAccessor.IsExists(Application.dataPath + "/Editor/" + GlobalEditorSetting.JSON_FILE_NAME))
                {
                    var content = DocumentAccessor.ReadFile(Application.dataPath + "/Editor/" + GlobalEditorSetting.JSON_FILE_NAME);

                    rpt = JsonMapper.ToObject <ResPathTemplate>(content);
                }
                //如果文件不存在,则新建存储类,并保存相关的数据,然后写入JSON并保存
                else
                {
                    rpt = new ResPathTemplate();
                }
                //=================================//

                //每次都重新写入ResPath
                Dictionary <string, string> resPathSumList = new Dictionary <string, string>();
                foreach (var item in rpt.UI)
                {
                    var sum = item.Value.Split('|');
                    if (sum.Length > 1 && !string.IsNullOrEmpty(sum[1]))
                    {
                        resPathSumList.Add(item.Key.ToUpper(), sum[1]);
                    }
                }
                rpt.UI.Clear();

                //============存入UI配置============//

                List <string> allResourcesPath = new List <string>();
                RecursionAction("Assets", allResourcesPath);

                foreach (var childPath in allResourcesPath)
                {
                    DirectoryInfo folder = new DirectoryInfo("Assets" + childPath + "/" + GlobalEditorSetting.UI_PREFAB_PATH);

                    if (!folder.Exists)
                    {
                        continue;
                    }

                    foreach (FileInfo file in folder.GetFiles())
                    {
                        string ss = file.Extension.ToUpper();
                        if (ss.Contains(".PREFAB") && file.FullName.Contains("Canvas"))
                        {
                            var result = file.Name.Split('.')[0];
                            var key    = "UI" + result.Split('_')[1].ToUpper();
                            rpt.UI.Add(key, GlobalEditorSetting.UI_PREFAB_PATH + result);

                            if (resPathSumList.ContainsKey(key))
                            {
                                rpt.UI[key] += "|" + resPathSumList[key];
                            }
                        }
                    }
                }

                //=================================//

                //============JSON文件存入============//
                using (StreamWriter sw = _saveLocalFileInfo.CreateText())
                {
                    var result = JsonMapper.ToJson(rpt);
                    sw.Write(result);
                }
                //=================================//

                //============更新并保存CS============//
                //更新并保存CS
                ResPathParse rpp = new ResPathParse();

                if (!FrameworkConfig.Instance.UseHotFixMode)
                {
                    EditorMenuExtention.CreateCSFile(Application.dataPath + "/Scripts", GlobalEditorSetting.OUTPUT_RESPATH, rpp.CreateCS(rpt));
                }
                else
                {
                    EditorMenuExtention.CreateCSFile(Application.dataPath + "/Scripts/ILRuntime/HotFixLogic", GlobalEditorSetting.OUTPUT_RESPATH, rpp.CreateCS(rpt));
                }

                AssetDatabase.Refresh();
            }
        }

        //汇总编译
        while (isDirty && !EditorApplication.isCompiling)
        {
            isDirty = false;

            EditorUtility.ClearProgressBar();
            LDebug.Log(" 成功生成UI预制件! ");

            if (!FrameworkConfig.Instance.UseHotFixMode)
            {
                //反射生成脚本组件
                var asmb = System.Reflection.Assembly.Load("Assembly-CSharp");
                var t    = asmb.GetType("Assets.Scripts.UI." + uiScriptsName);
                if (null != t)
                {
                    newCanvas.gameObject.AddComponent(t);
                }
                else
                {
                    LDebug.LogError("UI脚本绑定失败");
                }
            }

            string localPath = "Assets/Resources/" + GlobalEditorSetting.UI_PREFAB_PATH + newCanvas.gameObject.name + ".prefab";
            //预防重名
            localPath = AssetDatabase.GenerateUniqueAssetPath(localPath);
            PrefabUtility.SaveAsPrefabAssetAndConnect(newCanvas.gameObject, localPath, InteractionMode.UserAction);

            AssetDatabase.Refresh();
        }
    }
Beispiel #26
0
 //加载
 private void OnRewardedVideoLoadedEvent(string adUnitId)
 {
     LDebug.Log("激励视频广告读取,id:" + adUnitId);
 }
Beispiel #27
0
        /// <summary>
        /// Extracts the content from a .zip file inside an specific folder.
        /// </summary>
        /// <param name="fileZipPath">eg: AssetPathManager.Instance.GetStreamAssetDataPath("test.zip", false)</param>
        /// <param name="outputFolder">AssetPathManager.Instance.GetStreamAssetDataPath("", false)</param>
        /// <param name="password"></param>
        public static void ExtractZipContent(string fileZipPath, string outputFolder, string password = null)
        {
            ZipFile file = null;

            try
            {
                FileStream fs = File.OpenRead(fileZipPath);
                file = new ZipFile(fs);

                if (!string.IsNullOrEmpty(password))
                {
                    // AES encrypted entries are handled automatically
                    file.Password = password;
                }

                foreach (ZipEntry zipEntry in file)
                {
                    if (!zipEntry.IsFile)
                    {
                        // Ignore directories
                        continue;
                    }

                    string entryFileName = zipEntry.Name;
                    // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
                    // Optionally match entrynames against a selection list here to skip as desired.
                    // The unpacked length is available in the zipEntry.Size property.

                    // 4K is optimum
                    byte[] buffer    = new byte[4096];
                    Stream zipStream = file.GetInputStream(zipEntry);

                    // Manipulate the output filename here as desired.
                    string fullZipToPath = Path.Combine(outputFolder, entryFileName);
                    string directoryName = Path.GetDirectoryName(fullZipToPath);

                    if (directoryName.Length > 0)
                    {
                        Directory.CreateDirectory(directoryName);
                    }

                    // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
                    // of the file, but does not waste memory.
                    // The "using" will close the stream even if an exception occurs.
                    using (FileStream streamWriter = File.Create(fullZipToPath))
                    {
                        StreamUtils.Copy(zipStream, streamWriter, buffer);
                    }
                }
            }
            catch (Exception e)
            {
                LDebug.LogError(" Zip Error >> " + e);
            }
            finally
            {
                if (file != null)
                {
                    file.IsStreamOwner = true; // Makes close also shut the underlying stream
                    file.Close();              // Ensure we release resources
                }
            }
        }
Beispiel #28
0
 //播放失败
 private void OnRewardedVideoFailedToPlayEvent(string adUnitId, string error)
 {
     LDebug.Log("激励视频广告播放失败,id:" + adUnitId);
     LDebug.Log("激励视频广告播放失败,error:" + error);
 }
Beispiel #29
0
 //申请插屏过期
 private void OnInterstitialExpiredEvent(string adUnitId)
 {
     //重新申请
     //MoPub.RequestInterstitialAd(_interstitialAdUnits[0]);
     LDebug.Log("mopub调试——interstitial读取失败, id:" + adUnitId);
 }
Beispiel #30
0
 //申请视频过期
 private void OnRewardedVideoExpiredEvent(string adUnitId)
 {
     //重新申请
     MoPub.RequestRewardedVideo(_rewardedVideoAdUnits[0]);
     LDebug.Log("激励视频申请视频过期,id:" + adUnitId);
 }