public TaskWrapper <OperationStatus <T> > TryPop( ) { Func <OperationStatus <T> > deque = () => { T returnedItem; bool isReturned = _Queue.TryDequeue(out returnedItem); if (isReturned) { return(OperationStatusFactory.CreateSuccess <T>(returnedItem)); } return(OperationStatusFactory.CreateError <T>(ErrorCode.NoDataReceived)); }; var sf = new SafeFunc <OperationStatus <T> >(deque, null); return(TaskWrapper <OperationStatus <T> > .Run(() => sf.SafeInvoke())); }
private void SetDraggedPosition(PointerEventData eventData) { float limited_y = (eventData.position.y < limit_f ? limit_f : eventData.position.y); limited_y = (limited_y > Screen.height - limit_f ? Screen.height - limit_f : limited_y); float limited_x = (eventData.position.x < limit_f ? limit_f : eventData.position.x); //limited_x = (limited_x > Screen.width - CommonData.S_JIGSAW_RIGHT_LIMIT_X ? Screen.width - CommonData.S_JIGSAW_RIGHT_LIMIT_X : limited_x); //limited_x = (limited_x > CommonData.S_JIGSAW_RIGHT_LIMIT_WORLD_X ? CommonData.S_JIGSAW_RIGHT_LIMIT_WORLD_X : limited_x); Vector2 cur_drag_screen_pos = new Vector2(limited_x, limited_y); Vector3 cur_globalMousePos; Vector3 could_offset = Vector3.zero; if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_canvas, cur_drag_screen_pos, eventData.pressEventCamera, out cur_globalMousePos)) { Vector3 last_globalMousePos; if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_canvas, m_last_drag_screen_pos, eventData.pressEventCamera, out last_globalMousePos)) { Vector3 offset_ = cur_globalMousePos - last_globalMousePos; could_offset = DragAbleMoving.SafeInvoke(offset_); var rt = this.gameObject.transform.parent; cur_globalMousePos = last_globalMousePos + could_offset; Vector3 offset = cur_globalMousePos - m_begin_global_mouse_pos; rt.position = m_begin_pos + offset; rt.rotation = m_canvas.rotation; cur_drag_screen_pos = RectTransformUtility.WorldToScreenPoint(FrameMgr.Instance.UICamera, cur_globalMousePos); m_last_drag_screen_pos = cur_drag_screen_pos; } } }
// 初始化IAP; private void InitUnityPurchase() { if (IsInitialized()) { return; } Debug.Log("UNITY IAP start InitUnityPurchase"); var module = StandardPurchasingModule.Instance(); // The FakeStore supports: no-ui (always succeeding), basic ui (purchase pass/fail), and // developer ui (initialization, purchase, failure code setting). These correspond to // the FakeStoreUIMode Enum values passed into StandardPurchasingModule.useFakeStoreUIMode. module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser; var builder = ConfigurationBuilder.Instance(module); Debug.Log("UNITY IAP after create builder"); // Set this to true to enable the Microsoft IAP simulator for local testing. builder.Configure <IMicrosoftConfiguration>().useMockBillingSystem = true; m_IsGooglePlayStoreSelected = Application.platform == RuntimePlatform.Android && module.appStore == AppStore.GooglePlay; Debug.Log("UNITY IAP will get products1"); if (m_Usr_Get_Products.IsNull) { return; } Debug.Log("UNITY IAP will get products2"); var all_products = m_Usr_Get_Products.SafeInvoke(); Debug.Log("UNITY IAP after get products"); if (null == all_products) { return; } Debug.Log("UNITY IAP all products count = " + all_products.Count); if (0 == builder.products.Count) { foreach (var item in all_products) { #if UNITY_IOS && PLATFORM_ID builder.AddProduct(item.m_unique_platform_id, item.m_type); #else builder.AddProduct(item.m_charge_id.ToString(), item.m_type, item.m_cross_platform_ids); #endif } } //var catalog = ProductCatalog.LoadDefaultCatalog(); //foreach (var product in catalog.allValidProducts) //{ // if (product.allStoreIDs.Count > 0) // { // var ids = new IDs(); // foreach (var storeID in product.allStoreIDs) // { // ids.Add(storeID.id, storeID.store); // } // builder.AddProduct(product.id, product.type, ids); // } // else // { // builder.AddProduct(product.id, product.type); // } //} //builder.AddProduct(C_ITEM_0, ProductType.Consumable); #if RECEIPT_VALIDATION string appIdentifier; #if UNITY_5_6_OR_NEWER appIdentifier = Application.identifier; #else appIdentifier = Application.bundleIdentifier; #endif validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), UnityChannelTangle.Data(), appIdentifier); #endif //初始化; UnityPurchasing.Initialize(this, builder); }